Highest quality realtime sample interpolation methods?

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

I want to make an effect plugin for adding random pitch fluctuation to a signal. What are the highest quality methods of interpolation I can reasonably use in realtime? I want to know what options are out there.

Post

tesselode wrote:I want to make an effect plugin for adding random pitch fluctuation to a signal. What are the highest quality methods of interpolation I can reasonably use in realtime? I want to know what options are out there.
For quality you generally want to go for some variation of sinc-interpolation.

Post

tesselode wrote:I want to know what options are out there.
Most common upsampling techniques, from worst to best:
* none
* Linear (2-point)
* Quadratic (4-point)
* Sinc (typically 8+ points)

Post

do people usually roll their own resampling code or go with an already existing c++ library?

Post

tesselode wrote:do people usually roll their own resampling code or go with an already existing c++ library?
I use libresample by Dominic Mazzoni (LGPL licensed). https://ccrma.stanford.edu/~jos/resampl ... tware.html
For a plugin, the license may not be suitable, though.
~stratum~

Post

Jeff McClintock wrote: * Quadratic (4-point)
If you have 4 points, then usually you would want to use cubic Catmull-Rom splines (aka. cubic Hermite interpolation, where the derivatives are estimates with two-sided differences). These have a fairly flat, monotonic (=safe for high-gain feedback loops) pass-band and the first side-bands are down some 40dB which is pretty decent for a simple cubic curve. Another possibility is using cubic B-splines for slightly better side-band attenuation, but these need a pre-emphasis filter to compensate for the high-frequency attenuation.

That said, if cubic polynomials won't cut it, people usually just go for sinc-interpolation, which (with long enough kernels) can approach the ideal results (in the time-invariant case, but slow modulation isn't really a huge deal).

Post

It should be noted that the longer the sinc kernel (= higher quality), the larger the latency. Even if cpu doesn't matter, there's no free lunch.

Post

hugoderwolf wrote:It should be noted that the longer the sinc kernel (= higher quality), the larger the latency. Even if cpu doesn't matter, there's no free lunch.
Well, yeah.. also this can become a limiting factor if you're trying to do pitched feedback loops for physical modeling or something similar.

Post

i've done windowed-sinc(), but i wonder, isn't it possible to move the sinc() center towards the beginning of the table, and have it ring towards the end (and window it like that) ?
that way it will look like an impulse response from a causal IR filter, right?

i've tried to do that, but i can't manage to come up with a window shape and phase-shift for the sinc() so that it looks smooth in the beginning
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!

irc.libera.chat >>> #kvr

Post

antto wrote:i've done windowed-sinc(), but i wonder, isn't it possible to move the sinc() center towards the beginning of the table, and have it ring towards the end (and window it like that) ?
that way it will look like an impulse response from a causal IR filter, right?

i've tried to do that, but i can't manage to come up with a window shape and phase-shift for the sinc() so that it looks smooth in the beginning
That's called a minimum phase fir if i'm not mistaken.

Post

jupiter8 wrote:
antto wrote:i've done windowed-sinc(), but i wonder, isn't it possible to move the sinc() center towards the beginning of the table, and have it ring towards the end (and window it like that) ?
that way it will look like an impulse response from a causal IR filter, right?

i've tried to do that, but i can't manage to come up with a window shape and phase-shift for the sinc() so that it looks smooth in the beginning
That's called a minimum phase fir if i'm not mistaken.
I don't think you can do it fully. At least the minimum phase BLEP in the Eli Brandt's original BLEP paper (which, at least intuitively, is an integral of what we want) still has a noticeable group delay. Also generally lots of people having reservations about minPhase BLEP, although in the context of interpolation the minimum phase property might be more tolerable.

I'm unsure whether an integral of a minimum phase response is also a minimum phase response though.

Also, talking about IIR minimum phase lowpasses, they still have a noticeable group delay in their passbands IIRC.

Post

antto wrote:i've done windowed-sinc(), but i wonder, isn't it possible to move the sinc() center towards the beginning of the table, and have it ring towards the end (and window it like that) ?
that way it will look like an impulse response from a causal IR filter, right?

i've tried to do that, but i can't manage to come up with a window shape and phase-shift for the sinc() so that it looks smooth in the beginning
Hi Antto, I have also wondered the same thing. I think you could try minimum phase transformation in the cepstral domain. There is a page on minblep with a code example of this transformation. I'll try to find it.

Also if you have some clever algorithm to find the zeros of a linear phase kernel you can reflect any zeros outside the unit circle back into it.

Perhaps even truncate a minimum phase IIR?

For the record I havent actually tried any of those ideas out. :)

Post

antto wrote:i wonder, isn't it possible to move the sinc() center towards the beginning of the table, and have it ring towards the end (and window it like that) ?
that way it will look like an impulse response from a causal IR filter, right?
Yes it is possible using cepstral methods! I have played about with it, but I think it's a dead end. As you probably know there are several options for approximating an ideal low pass (which is what an sinc is):

- linear phase fir
- minimum phase fir
- minimum phase iir

The sinc function is useful as a cheap way to create a low pass linear phase fir, but it's not optimal. You can use optimised fir design methods to get smaller linear phase fir low pass filters for resampling.

Using minimum phase firs as a low pass filter for resampling doesn't seem sensible when anything you can do with a minimum phase fir from a resampling standpoint, you can do better and faster with elliptical iir filters.

Elliptical iirs for minimum phase low pass are great as you can tune all the important characteristics for resampling. Orfanidis has some great matlab code for creating low pass filters and he takes advantage of and factors in the fact iirs generated via a bilinear transform for resampling have narrower transition bands than their analogue counterparts.

Post

keithwood wrote:Using minimum phase firs as a low pass filter for resampling doesn't seem sensible when anything you can do with a minimum phase fir from a resampling standpoint, you can do better and faster with elliptical iir filters.
How about non integer resampling ratios?

Plus even for integer ratios certainly anything above, say, a x2 ratio a FIR can be optimised to out perform an elliptical IIR. The higher the ratio the bigger the gains for FIR over IIR.

Post

matt42 wrote:How about non integer resampling ratios?

Plus even for integer ratios certainly anything above, say, a x2 ratio a FIR can be optimised to out perform an elliptical IIR. The higher the ratio the bigger the gains for FIR over IIR.
Well that shows me for implying iirs are always better than firs :-) I believe that firs are faster when they a small and iirs are faster when the design criteria (passband ripple, stopband attenuation and transition width) are strict enough that you just can't design a small fir. I'd be interested to know what design parameters people are happy to get away with to keep their firs small.

Post Reply

Return to “DSP and Plugin Development”