Login / Register 0 items | $0.00 New @ KVR
User avatar
tesselode
KVRist
 
81 posts since 18 Jan, 2018

Postby tesselode; Sun Mar 04, 2018 3:57 pm Highest quality realtime sample interpolation methods?

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
 
4979 posts since 11 Feb, 2006, from Helsinki, Finland

Postby mystran; Sun Mar 04, 2018 4:21 pm Re: Highest quality realtime sample interpolation methods?

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.
Image <- plugins | forum
Jeff McClintock
KVRist
 
281 posts since 30 Jan, 2005, from New Zealand

Postby Jeff McClintock; Sun Mar 04, 2018 11:34 pm Re: Highest quality realtime sample interpolation methods?

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
 
81 posts since 18 Jan, 2018

Postby tesselode; Mon Mar 05, 2018 12:53 am Re: Highest quality realtime sample interpolation methods?

do people usually roll their own resampling code or go with an already existing c++ library?
stratum
KVRAF
 
1845 posts since 29 May, 2012

Postby stratum; Mon Mar 05, 2018 1:36 am Re: Highest quality realtime sample interpolation methods?

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
 
4979 posts since 11 Feb, 2006, from Helsinki, Finland

Postby mystran; Mon Mar 05, 2018 2:08 am Re: Highest quality realtime sample interpolation methods?

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).
Image <- plugins | forum
hugoderwolf
KVRist
 
176 posts since 1 Apr, 2009, from Bochum, Germany

Postby hugoderwolf; Mon Mar 05, 2018 1:38 pm Re: Highest quality realtime sample interpolation methods?

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
 
4979 posts since 11 Feb, 2006, from Helsinki, Finland

Postby mystran; Mon Mar 05, 2018 1:58 pm Re: Highest quality realtime sample interpolation methods?

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.
Image <- plugins | forum
User avatar
antto
KVRAF
 
2499 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
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
 
9376 posts since 17 Sep, 2002, from Gothenburg Sweden

Postby jupiter8; Tue Mar 06, 2018 12:15 pm Re: Highest quality realtime sample interpolation methods?

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
 
954 posts since 11 Apr, 2002
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
 
1032 posts since 9 Jan, 2006
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
 
58 posts since 24 Dec, 2015, from Bristol, UK

Postby keithwood; Wed Mar 07, 2018 12:10 pm Re: Highest quality realtime sample interpolation methods?

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
 
1032 posts since 9 Jan, 2006
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
 
58 posts since 24 Dec, 2015, from Bristol, UK

Postby keithwood; Thu Mar 08, 2018 4:32 am Re: Highest quality realtime sample interpolation methods?

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.
Next

Moderator: KVR Moderators (Main)

Return to DSP and Plug-in Development