Highest quality realtime sample interpolation methods?

DSP, Plug-in and Host development discussion.
User avatar
tesselode
KVRist
84 posts since 19 Jan, 2018

Post Sun Mar 04, 2018 3:57 pm

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.

mystran
KVRAF
5036 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Highest quality realtime sample interpolation methods?

Post Sun Mar 04, 2018 4:21 pm

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.
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

Jeff McClintock
KVRist
282 posts since 30 Jan, 2005 from New Zealand

Re: Highest quality realtime sample interpolation methods?

Post Sun Mar 04, 2018 11:34 pm

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)

User avatar
tesselode
KVRist
84 posts since 19 Jan, 2018

Re: Highest quality realtime sample interpolation methods?

Post Mon Mar 05, 2018 12:53 am

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

stratum
KVRAF
2120 posts since 29 May, 2012

Re: Highest quality realtime sample interpolation methods?

Post Mon Mar 05, 2018 1:36 am

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~

mystran
KVRAF
5036 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Highest quality realtime sample interpolation methods?

Post Mon Mar 05, 2018 2:08 am

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).
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

hugoderwolf
KVRist
176 posts since 1 Apr, 2009 from Bochum, Germany

Re: Highest quality realtime sample interpolation methods?

Post Mon Mar 05, 2018 1:38 pm

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.

mystran
KVRAF
5036 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Highest quality realtime sample interpolation methods?

Post Mon Mar 05, 2018 1:58 pm

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.
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

User avatar
antto
KVRAF
2499 posts since 4 Sep, 2006 from 127.0.0.1

Re: Highest quality realtime sample interpolation methods?

Post Tue Mar 06, 2018 11:15 am

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.freenode.net >>> #kvr

User avatar
jupiter8
KVRAF
9375 posts since 17 Sep, 2002 from Gothenburg Sweden

Re: Highest quality realtime sample interpolation methods?

Post Tue Mar 06, 2018 12:15 pm

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.

Z1202
KVRian
978 posts since 12 Apr, 2002

Re: Highest quality realtime sample interpolation methods?

Post Wed Mar 07, 2018 1:36 am

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.

matt42
KVRian
1072 posts since 9 Jan, 2006

Re: Highest quality realtime sample interpolation methods?

Post Wed Mar 07, 2018 3:31 am

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. :)

keithwood
KVRist
59 posts since 24 Dec, 2015 from Bristol, UK

Re: Highest quality realtime sample interpolation methods?

Post Wed Mar 07, 2018 12:10 pm

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.

matt42
KVRian
1072 posts since 9 Jan, 2006

Re: Highest quality realtime sample interpolation methods?

Post Wed Mar 07, 2018 5:26 pm

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.

keithwood
KVRist
59 posts since 24 Dec, 2015 from Bristol, UK

Re: Highest quality realtime sample interpolation methods?

Post Thu Mar 08, 2018 4:32 am

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.

Return to “DSP and Plug-in Development”