[PD] better tabread4~

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

=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


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

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:


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

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.


> 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...
Name: view_tabread4~_impulse_response.pd
Type: application/octet-stream
Size: 1181 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20080615/0c492a98/attachment.obj>

More information about the Pd-list mailing list