quadratic or cubic interpolator

montagne's icon

Hi, I'm implementing a continuously variable delay line. Unfortunately I am currently using linear interpolation between samples, and it's prety awful. Does anybody know of a good object for quadratic or cubic interpolation of signals?
Thanks

nathan wolek's icon

On Dec 12, 2006, at 11:52 PM, Tim wrote:
> Hi, I'm implementing a continuously variable delay line.
> Unfortunately I am currently using linear interpolation between
> samples, and it's prety awful. Does anybody know of a good object
> for quadratic or cubic interpolation of signals?

I don't have an object for this, but I have some C code for an
allpass interpolation. Would that help? Or do you know how to code
externals?

-----
Nathan Wolek
nw@nathanwolek.com
http://www.nathanwolek.com

montagne's icon

I don't know if I'll have time to make an external, but the code may be helpful. How can I get it from you?
thx
tim.m

nathan wolek's icon

On Dec 13, 2006, at 1:16 PM, Tim wrote:
> I don't know if I'll have time to make an external, but the code
> may be helpful. How can I get it from you?

Here you go. Complete with reference on where I found the technique.

/
************************************************************************
********
float rbb_allpassInterp(float *in_array, float index, long bufferLength,
        float last_out, float *out_ptr)

inputs:            in_array -- name of array of input values
                index -- floating point index value to interpolate
                bufferLength -- length of in_array
                last_out -- value of last output from buffer
                out_ptr -- pointer to output location
description:    performs allpass interpolation on an input array and
returns the
    results to a location specified by a pointer; implements filter as
specified
    in Dattorro 2: J. Audio Eng. Soc., Vol 45, No 10, 1997 October
returns:        interpolated output
************************************************************************
********/
void rbb_allpassInterp(float *in_array, float index, long bufferLength,
        float last_out, float *out_ptr)
{
    // index = i.frac
    long index_i = (long)index;                    // i
    long index_iP1 = index_i + 1;                // i + 1
    float index_frac = index - (float)index_i;    // frac

    // make sure that index_iP1 is not out of range
    while (index_iP1 >= bufferLength) index_iP1 -= bufferLength;

    // formula as on bottom of page 765 of above Dattorro article
    *out_ptr = in_array[index_i] + index_frac * (in_array[index_iP1] -
last_out);
}

-----
Nathan Wolek
nw@nathanwolek.com
http://www.nathanwolek.com

montagne's icon

thanks for the code. It looks quite simple. Obviously a piece of cake in C (once you know) but the feedback aspect of the algorithm would make it pretty much impossible in MAX/MSP directly, I believe. Is that correct? From other posts I have seen it seems that a minimum feedback delay of 1 signal vector is required?
Thanks.

nathan wolek's icon

On Dec 14, 2006, at 8:49 AM, Tim wrote:
> Obviously a piece of cake in C (once you know) but the feedback
> aspect of the algorithm would make it pretty much impossible in MAX/
> MSP directly, I believe. Is that correct? From other posts I have
> seen it seems that a minimum feedback delay of 1 signal vector is
> required?

Yes. On both counts.

-------------------
Nathan Wolek, PhD --- nwolek@stetson.edu
Assistant Professor of Music Technology
Stetson University - DeLand, FL
http://www.nathanwolek.com