Charles Henry czhenry at gmail.com
Sun Jun 15 18:19:49 CEST 2008

```On Tue, Jun 10, 2008 at 10:29 AM, cyrille henry
<cyrille.henry at la-kitchen.fr> wrote:

> well, i think the tabread4~ interpolation is a lagrange interpolator (but
> i'm may be wrong).
> at least with tabread4~, the 1st derivative is not continuous, while it
> should be with a cubic interpolation.

The Lagrange interpolation scheme is not continuous, because it fits a
polynomial through 4 points (-1, 0 ,1 , 2) and interpolates between 0
and 1.  But when it goes to the next 4 points (0, 1, 2, 3), it fits
another polynomial and interpolates between 1 and 2.  So, the
discontinuity in 1st derivative is at each sample.

>
> i program a cubic interpolation, and the shape of the waveform is really
> different.
>
> please compile the object and look at the help patch to see the difference.
>
> i can also send waveforme picture if needed.

I'm having trouble compiling, due to the garray_getfloatwords symbol.
Which version of Pd are you using?

I'd like to see the waveform and test it out.  Here's my analysis of key points

(a=x[-1], b=x[0], c=x[1], d=x[2])

83   	a0 = d - c - a + b;
84 		a1 = a - b - a0;
85 		a2 = c - a;
86 		*out++ = ((a0*frac+a1)*frac+a2)*frac+b;

At frac=0, output should be b.  Check!

At frac=1, output should be c

((a0*1+a1)*1+a2)*1+b
=a0+a1+a2+b
=d-c-a+b  +  a-b-(d-c-a+b)  +  c-a  +  b
=d-c-a+b  +  a-b-d+c+a-b  +  c-a +  b
=d-c-a+b  +  2a-2b+c-d  +  c-a  +  b
=c

Check!

1st derivatives:

At frac=0,
d/dx f(x) = c-a

(This quantity really ought to be (c-a)/2, but let's see how the rest comes out)

At frac=1,

d/dx f(x) = 3*(d-c-a+b) + 2*(a-b-d+c+a-b) + c-a
=d-b

So, we've got 1st derivatives that match between samples.  Check!

This looks like a really good plan.  I might suggest some new
coefficients to try:

a0=(3b-a-3c+d)/2
a1=a-5b/2+2c-d/2
a2=(c-a)/2

The only difference is the 1st derivatives are (c-a)/2 and (d-b)/2,
respectively.

Maybe you could try a 5th-degree polynomial next and set the 2nd
derivatives for continuity.  This would involve 4-points as before,
but it might introduce a ripple in the interpolation (cubic
interpolation can't do that, since it only has two critical points).

I'm not keen on doing the spectral analysis, because it would take
about 4 hours, to do it by hand.

There's something I would like to see (once I can compile it).  I made
a patch (attached) a while back to view the tabread4~ interpolation
function (impulse response).  Give it a try if you're inclined to do
so, because it might surprise you.

Chuck

>
>
> cyrille
>
>
>>
>> Chuck
>>
>> _______________________________________________
>> Pd-list at iem.at mailing list
>> UNSUBSCRIBE and account-management ->
>> http://lists.puredata.info/listinfo/pd-list
>>
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...