oversampling?

ColinP
Posts: 1000
Joined: Mon Aug 03, 2020 7:46 pm

Re: oversampling?

Post by ColinP »

Many thanks Chris for your engagement in this thread and of course for you posting your code elsewhere.

You are clearly an expert in these matters.

Could you possibly go into more detail about what you mean by latency and why you consider it a serious problem? I think most of us think about problematic latency in terms of relatively large numbers of milliseconds but I suspect you are talking about latency measured in samples.

I also don't understand your point about linear interpolation introducing some high-frequency roll-off (unless you meant just in comparison with nearest neighbour). My understanding is that when using linear interpolation for fractional buffer access there is a risk of aliasing and that upsampling should reduce this as it generates data that, putting it crudely, is far "smoother" than produced by linear interpolation because it takes into account a larger number of adjacent samples in the filtering process.
User avatar
utdgrant
Posts: 625
Joined: Wed Apr 07, 2021 8:58 am
Location: Scotland
Contact:

Re: oversampling?

Post by utdgrant »

ColinP wrote: Sat Dec 16, 2023 6:03 pm I also don't understand your point about linear interpolation introducing some high-frequency roll-off (unless you meant just in comparison with nearest neighbour).
This is Zeit operating in the 'worst-case' scenario. i.e. When the fractional delay time is exactly 0.5 sample periods long. As you can see from the frequency analyser plot, there is a roll-off starting at around 10kHz. It drops to about -12dB at 20kHz and disappears completely at the Nyquist frequency (24kHz).
FractionalDelayRollOff.jpg
FractionalDelayRollOff.jpg (43.62 KiB) Viewed 48722 times
Remember that linear interpolation will always produce a value somewhere between the two surrounding sample values. This is in contrast to an analogue reconstruction filter. It will 'draw' the only possible waveform which fits through the replayed sample points, even if that means exceeding the voltage represented by two consecutive sample points.

It's always worth having a re-watch of Monty Montgomery's Digital Show & Tell.
______________________
Dome Music Technologies
ColinP
Posts: 1000
Joined: Mon Aug 03, 2020 7:46 pm

Re: oversampling?

Post by ColinP »

Just to be clear Grant are you saying that the frequency response shown in your graph is the result of simply taking the average of two adjacent samples?
User avatar
ChR_is
Posts: 116
Joined: Wed Sep 22, 2021 5:48 pm

Re: oversampling?

Post by ChR_is »

ColinP wrote: Sat Dec 16, 2023 6:03 pm Many thanks Chris for your engagement in this thread and of course for you posting your code elsewhere.

You are clearly an expert in these matters.
Thank you for your kind words :)
i wouldn't call myself an expert, but i did my fair share of research and development.
ColinP wrote: Sat Dec 16, 2023 6:03 pm Could you possibly go into more detail about what you mean by latency and why you consider it a serious problem? I think most of us think about problematic latency in terms of relatively large numbers of milliseconds but I suspect you are talking about latency measured in samples.
FIR filters will take some time to produce an output for the given input sample. that's the nature of convolution. when talking about audio processing in general that's seldomly an issue, because DAWs will compensate this latency with PDC (Plugin Delay Compensation). basically, a plugin can report its latency to the host and the host makes sure to delay all other processes for that number of samples so that everything is in sync afterwards. in Voltage Modular we do not have this luxury. being a virtual modular with flexible routing there is no chance VM can calculate the common latency for any point and delay signals accordingly. even sth as simple as a feedback loop would break that calculation. every module in VM introduces at single sample of latency at base. that's because there's two cycles: the input update cycle and the output update cycle. that's how virtual modulars operate and how they enable us to do flexible routing without care. there are certain processes that introduce further latency into the signal. the most prominent would be a simple delay. easy, that's deliberate. but other processing has inherent delays as well. FIR filtering can be seen as time domain convolution, which takes a certain number of samples to react to the input. as a rule of thumb it's the number of coefficients divided by the oversampling factor. so if your filter has 100 taps for 2x oversampling, that's 50 samples of delay per FIR filter.. for a processor that upsamples the input and downsamples the outputs that's 100 samples. when you mix a delayed signal with the original signal you'll get a comb filter. in case of 100 samples that'd be 48000 samples/sec / 100 samples => 480 1/sec == 480 hz. and that's per module. as you can see, that'll cause a multitude of problems in a modular environment where signals can be split up and recombined arbitrarily.

ColinP wrote: Sat Dec 16, 2023 6:03 pm I also don't understand your point about linear interpolation introducing some high-frequency roll-off (unless you meant just in comparison with nearest neighbour). My understanding is that when using linear interpolation for fractional buffer access there is a risk of aliasing and that upsampling should reduce this as it generates data that, putting it crudely, is far "smoother" than produced by linear interpolation because it takes into account a larger number of adjacent samples in the filtering process.
put simply, a 1 pole low-pass is essentially linear interpolation and vice versa. a simple 1 pole linearly interpolates between the current value and the last output produced by itself. but actually every interpolation is filtering. we do not know what values are between the samples.. well actually we know, a perfect sinc would provide us with the values, but since a perfect sinc does not exist, we do not know. everything else will somehow dilute the actual content between the sample points. and linear interpolation will do just that as well.
Grant is right on here:
utdgrant wrote: Sat Dec 16, 2023 7:25 pm Remember that linear interpolation will always produce a value somewhere between the two surrounding sample values. This is in contrast to an analogue reconstruction filter. It will 'draw' the only possible waveform which fits through the replayed sample points, even if that means exceeding the voltage represented by two consecutive sample points.

It's always worth having a re-watch of Monty Montgomery's Digital Show & Tell.
btw. that video is a mandatory watch. ;) one of my favorite pieces of media on the whole wide web.

however, linear interpolation cannot exceed the value range given by its two control points. that's possible with higher order interpolation though.
ColinP
Posts: 1000
Joined: Mon Aug 03, 2020 7:46 pm

Re: oversampling?

Post by ColinP »

utdgrant wrote: Sat Dec 16, 2023 7:25 pm Remember that linear interpolation will always produce a value somewhere between the two surrounding sample values. This is in contrast to an analogue reconstruction filter. It will 'draw' the only possible waveform which fits through the replayed sample points, even if that means exceeding the voltage represented by two consecutive sample points.
Yup, which is why I'm arguing that using linear interpolation for fractional access of a buffer can produce aliasing! Lerping completely ignores the surrounding context and only takes into account two samples.
User avatar
ChR_is
Posts: 116
Joined: Wed Sep 22, 2021 5:48 pm

Re: oversampling?

Post by ChR_is »

ColinP wrote: Sat Dec 16, 2023 8:40 pm
utdgrant wrote: Sat Dec 16, 2023 7:25 pm Remember that linear interpolation will always produce a value somewhere between the two surrounding sample values. This is in contrast to an analogue reconstruction filter. It will 'draw' the only possible waveform which fits through the replayed sample points, even if that means exceeding the voltage represented by two consecutive sample points.
Yup, which is why I'm arguing that using linear interpolation for fractional access of a buffer can produce aliasing! Lerping completely ignores the surrounding context and only takes into account two samples.
how would that introduce aliasing? where's the discontinuity in the signal? that would only apply if you modulate the read head at sufficient rates (like audio-rate modulation). in that case i'd suggest a higher order interpolation like 3rd order hermite spline which can produce a continuous signal down to the second derivative.

to re-iterate, you are not reading the buffer as a continuous signal, you are sampling the buffer.
User avatar
ChR_is
Posts: 116
Joined: Wed Sep 22, 2021 5:48 pm

Re: oversampling?

Post by ChR_is »

here's an example:
Linear interpolation between two bandlimited signals
Linear interpolation between two bandlimited signals
BlendingBetweenBandlimitedWaveforms.png (799.74 KiB) Viewed 48708 times
here i am linearly interpolating between two audio signals. without modulating the blend amount, we're sampling both signals and mix them at 50/50. since both input values are bandlimited, the output is bandlimited as well. linear interpolation is a linear process.

the same holds true if you interpolate the values in a buffer. think about the buffer as two copies of the same signal that's delayed by a sample. as long as you don't modulate, there's no cause for aliasing. just a little low-passing.
ColinP
Posts: 1000
Joined: Mon Aug 03, 2020 7:46 pm

Re: oversampling?

Post by ColinP »

Chris, our posts crossed.

On the latency issue I'm trying to picture a practical situation where an audio delay of 100 samples would be a serious problem. But then my focus is usually on control signals where propagation delays can have great consequence.

I can see that doing a dry/wet mix would be problematic if done via independent paths but don't most effects modules do dry/wet mix onboard where any latency can be easily compensated for?

I'm not sure why you don't see why buffer lerping can introduce aliasing. Surely there is discontinuity if the lerped signal diverges from the signal that would result if we had infinite buffer resolution.

One thing we can all agree on is how excellent Monty's video is!

I have to be up and on the go in six hours so time for bed...
User avatar
ChR_is
Posts: 116
Joined: Wed Sep 22, 2021 5:48 pm

Re: oversampling?

Post by ChR_is »

ColinP wrote: Sat Dec 16, 2023 9:00 pm Chris, our posts crossed.

On the latency issue I'm trying to picture a practical situation where an audio delay of 100 samples would be a serious problem. But then my focus is usually on control signals where propagation delays can have great consequence.

I can see that doing a dry/wet mix would be problematic if done via independent paths but don't most effects modules do dry/wet mix onboard where any latency can be easily compensated for?
you can only compensate within a single module, but not across multiple modules. and you do not have control over other modules. so if you module has latency, but other modules do not or do have different latency, you can never sync up. all modulation will be somewhat late for example. and stuff like that quickly adds up. your oscillator needs oversampling, so here's delay. now you want some mojo, so you add distortion.. more latency. maybe a filter? analog filter modules need oversampling as well, more latency. a saturating mixer? more latency. and so on.. in the end it doesn't matter if it doesn't matter to you. in my experience latency quickly becomes an issue in flexible routing environments such as virtual modular.
if you don't think that's an issue, then that's perfectly fine as well. :)
ColinP wrote: Sat Dec 16, 2023 9:00 pm I'm not sure why you don't see why buffer lerping can introduce aliasing. Surely there is discontinuity if the lerped signal diverges from the signal that would result if we had infinite buffer resolution.
that's because lerping does not add any harmonic content that could alias. lerping is a linear process. if both input signals are bandlimited, the result must be bandlimited as well.
here's another example:
linear buffer interpolation example
linear buffer interpolation example
LinearBufferInterpolation_2.png (721.22 KiB) Viewed 48702 times
here i simulate a buffer by feeding a signal and the same signal delayed by a single sample into this blend module which does linear interpolation. i think we can agree that this is a two sample buffer. it contains the current value and the past value. i can linear interpolate this buffer without producing any additional harmonics. in fact you can see the low-passing of the linear interpolation here.
you will get aliasing if you iterate over a linear interpolated buffer. e.g. use a LUT and a phasor as an oscillator. but a delay does not move by itself. the delay always samples the same point in time sample by sample. and when the input is bandlimited, that point is guaranteed to be bandlimited as well.
User avatar
utdgrant
Posts: 625
Joined: Wed Apr 07, 2021 8:58 am
Location: Scotland
Contact:

Re: oversampling?

Post by utdgrant »

ColinP wrote: Sat Dec 16, 2023 8:40 pm Yup, which is why I'm arguing that using linear interpolation for fractional access of a buffer can produce aliasing! Lerping completely ignores the surrounding context and only takes into account two samples.
There's "aliasing" and there's "aliasing", though. Linear Interpolation appears to be very forgiving, and you only seem to get a low-pass filter response. I couldn't hear (or see) the generation of nasty sidebands getting reflected around the Nyqist frequency.
SineWaveLerp0.5.jpg
SineWaveLerp0.5.jpg (78.49 KiB) Viewed 48701 times
______________________
Dome Music Technologies
Post Reply

Return to “Module Designer”