Highest quality realtime sample interpolation methods?
- KVRist
- Topic Starter
- 94 posts since 19 Jan, 2018
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.
- KVRAF
- 7897 posts since 12 Feb, 2006 from Helsinki, Finland
For quality you generally want to go for some variation of sinc-interpolation.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.
-
Jeff McClintock Jeff McClintock https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=56398
- KVRist
- 414 posts since 30 Jan, 2005 from New Zealand
Most common upsampling techniques, from worst to best:tesselode wrote:I want to know what options are out there.
* none
* Linear (2-point)
* Quadratic (4-point)
* Sinc (typically 8+ points)
-
- KVRAF
- 2256 posts since 29 May, 2012
I use libresample by Dominic Mazzoni (LGPL licensed). https://ccrma.stanford.edu/~jos/resampl ... tware.htmltesselode wrote:do people usually roll their own resampling code or go with an already existing c++ library?
For a plugin, the license may not be suitable, though.
~stratum~
- KVRAF
- 7897 posts since 12 Feb, 2006 from Helsinki, Finland
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.Jeff McClintock wrote: * Quadratic (4-point)
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).
- KVRist
- 296 posts since 1 Apr, 2009 from Hannover, Germany
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.
- KVRAF
- 7897 posts since 12 Feb, 2006 from Helsinki, Finland
Well, yeah.. also this can become a limiting factor if you're trying to do pitched feedback loops for physical modeling or something similar.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.
- KVRAF
- 2554 posts since 4 Sep, 2006 from 127.0.0.1
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 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
..as long as it has BASS and it's LOUD!
irc.libera.chat >>> #kvr
- KVRAF
- 9453 posts since 17 Sep, 2002 from Gothenburg Sweden
That's called a minimum phase fir if i'm not mistaken.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
-
- KVRAF
- 1607 posts since 12 Apr, 2002
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.jupiter8 wrote:That's called a minimum phase fir if i'm not mistaken.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
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.
-
- KVRian
- 1273 posts since 9 Jan, 2006
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.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
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.
- KVRist
- 91 posts since 24 Dec, 2015 from Bristol, UK
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):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?
- 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.
-
- KVRian
- 1273 posts since 9 Jan, 2006
How about non integer resampling ratios?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.
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.
- KVRist
- 91 posts since 24 Dec, 2015 from Bristol, UK
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.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.