First time here? Check out the FAQ!
x

Is it possible to over sample in Kyma?

+1 vote
1,308 views
Hi,

i am looking for ways to over sample for example a feedback loop, but I can't find any way to do this.
is it possible to over sample specific sections of a patch?

best

paul
asked Mar 24, 2020 in General by paul-louis (210 points)

4 Answers

+1 vote
 
Best answer
Although there is not (yet) a way to run different parts of the signal flow diagram at different sample rates, there is a way to emulate oversampling (which it sounds like Alan & Pete may be doing?):

Imagine you have a stateless function f(x). To emulate n-times oversampling, you could make n copies of f(x) and let each one operate on a different time step, where there are now n time steps for each sample at the old SR.

Since the rest of the signal flow graph is feeding f(x) at SR, where do those n new samples come from (the time steps "in between" the actual input samples?)

To guess what the values are between the actual input samples, we can interpolate from one sample to the next. One simple way to do this would be to use linear interpolation. If your input samples are A and B, the n samples in between would be (A * (n - (i - 1)) + B * (i - 1)) / n

So the sample points  "in between" A and B would be:

x1 = A

x2 = (A * (n - 1)) + B) / n

...

xn = (A  + B * (n - 1)) / n

Now we can apply the function to each of the new time points:

f(x1), f(x2), .., f(xn)

which you can think of as n-samples of a signal running at SR*n.

To use the output of this higher rate signal in combination with the rest of the signal flow graph, you have to filter it at half of the sample rate (i.e., put it through lowpass filter whose cutoff is SR/2). For example, one simple (but not very high quality) way to low-pass filter the signal would be by averaging:

[f(x+1) + f(x+2) + .. + f(x + n)] / n

In other words, you could take the sum of the outputs of the n copies of f(x) and scale by 1/n and use this output with the rest of your signal flow graph.

The emulation could be improved by using a more complicated interpolation function on the input and a better low-pass filter on the SR*n signal output.
answered Mar 26, 2020 by ssc (Savant) (128,200 points)
selected Sep 13, 2020 by paul-louis
thanks a lot for the detailed answer, I get the idea but have some questions:

what is the variable "i" and how does the lowpass filter work by averaging?
how does a more complicated interpolation function could look like and as well a better lowpass filter? Is there some literature that explains this?

best
Paul
For more multi-rate signal processing techniques, you could start with the Wikipedia entries on upsampling (https://en.wikipedia.org/wiki/Upsampling) and downsampling (https://en.wikipedia.org/wiki/Downsampling_(signal_processing)).

Averaging is a low pass filter because it smooths out the faster changes in the waveform.

In (A * (n - (i - 1)) + B * (i - 1)) / n, the i is the number of the interpolated sample, ranging from 1 to n. (The time points in between the actual samples A and B)
thank you! I will have a read @alan_jackson do you have examples of you oversampling as a patch?
0 votes
Best you could do for now would be to raise the overall SR for the entire patch.
answered Mar 25, 2020 by ssc (Savant) (128,200 points)
ok thx, sounds like this could change in the future ;)
best
0 votes
I think it depends on what you're trying to do but you can do oversampling in Kyma. In the Kata we've just built a 3-times oversampling state variable filter.

We did this by kind of replicating the processing within our feedback loops three times and throwing away the first samples. That is a terrible explanation. Pete Johnston led us through the design and he would be a great person to explain how that works.

Pete? Where are you? (If you say "Hilbert Transform" three times he usually appears).
answered Mar 26, 2020 by alan-jackson (Virtuoso) (15,840 points)
ah thats sounds interesting, tell me more :) What is the Kata by the way?

best
+1 vote

In many cases you don't need to interpolate up because you are not staying at the higher sample rate but immediatly coming back down again and the error will be un noticable. Therefore you do the calculation three times with the same input sample repeated three times and when you output it you just take the last of the three calculations and egnore the other two.

in the attached diagram below, I start with a state variable filter and re arrange it so that inputs and feedback outputs are on the left and the output and feedback inputs are on the right. Then you can see what you need to do to to repeate it three times at the same time. 

I hope it makes sense.

StateVarOversample1.pdf

BTW in fact I think you may find that the error due to not interpolating cancels out. By not interpolating it is like adding a step wave to the signal which only contains frequencies at the higher sample rate (no aliasing). When you come back down in sample rate, those frequencies get dropped as the down sampleing is an exact sub division of the sample rate so you end up with the correct signal. The numbers may be different to the interpolated version, but may be more correct as if a non phase shift filter had been used.

 

answered Mar 29, 2020 by pete-johnston (Practitioner) (670 points)
thank you pete!
I am not really sure how to translate the schema to kyma but I guess i will figure it out!
thanks a lot
Hi Paul, It's quite simple, the circles with plus in are mixers the circles with plus but a little minus circle are mixers but with 0-1 in both levels hot fields, and the triangles are mixers with the Ff or 1/Q formular in the level fields , or if you need control at sample rate then these are product modules  and the result of the formula becomes the second input. I hope this makes sense.

BTW Alan will be posting the finished thing, but it has few extras like distortion option in the feed back, stereo, greater order of filter if needed, sample rate or non sample rate control.
Hi Paul, it took a bit longer than I thought but the filter with oversampling has just been shared here.
https://kyma.symbolicsound.com/library/kyma-kata-superhotfilter/#description

It may be hard to see what's going on with all the stuff needed for encapsulation but here is pdf of the basic idea.

Sorry still cannot attach file here (long live the old forum)
Pete, I think you can attach files to an Answer, just not to a Comment (in any case, glad you found a solution by uploading it to the Community Library)
No, it is the PDF drawing of how it works that I cannot upload. Alan uploaded the sound in the library.
Hi Pete, I think it ought to work if you do the following:
• Click Answer
• Click the link icon at the top of the editor (looks like a chain link)
• Click Upload
• Locate your PDF file on your disk
• Click Send it to server
• Click OK; it will paste a link to the file into the editor.
• Copy the link and discard the answer, add a comment and paste the link into the comment.

I tried it:
http://kyma.symbolicsound.com/qa/?qa=blob&qa_blobid=3736297234549392912

When people click on the link, it will download the PDF.

Hope this works for you. Thanks!
I have been focussing closely on this for a while,  in relation to my life's work to implement sample rate, zipper-free buffer indexing in Kyma for delay line design, buffer scrubbing, phase interpolation and stuff rather than filter design. Could I apply the PJ's over sampling technique as a way to inject values into a circulating phase accumulator for example?

I think I need to take my problem to the Kata clench of the International Guild of Kyma Makers...
Hi Cristian. Not so sure about lending the technique to other situations. The thing about the filter was that the sample rate in and sample rate out were the same so the oversampling errors canceled out. With other stuff that does a sort of sample rate convert (without immediately coming back) I think needs more attention as to adding a sort of oversampled filter were there wasn't one. Each case seems to need a different technique. I hope this makes sense.
...