[PD] better tabread4~

Matt Barber brbrofsvl at gmail.com
Wed Jun 25 17:32:10 CEST 2008


For what it's worth, here's supercollider's cubic interpolation
function, which differs from csound's and Pd's, which I believe are
equivalent:

static float cubicinterp(float x, float y0, float y1, float y2, float y3)
{
	// 4-point, 3rd-order Hermite (x-form)
	float c0 = y1;
	float c1 = 0.5f * (y2 - y0);
	float c2 = y0 - 2.5f * y1 + 2.f * y2 - 0.5f * y3;
	float c3 = 0.5f * (y3 - y0) + 1.5f * (y1 - y2);

	return ((c3 * x + c2) * x + c1) * x + c0;
}


Matt

> Date: Tue, 24 Jun 2008 23:50:06 -0500
> From: "Charles Henry" <czhenry at gmail.com>
> Subject: Re: [PD] better tabread4~
> To: "Mathieu Bouchard" <matju at artengine.ca>, pd-list at iem.at
> Message-ID:
>        <518fe7b20806242150yf1f3f1aicf129039778260b2 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Tue, Jun 24, 2008 at 9:24 PM, Mathieu Bouchard <matju at artengine.ca> wrote:
>
>> I don't think that more than one alternative will be necessary. For 4-point
>> table lookups that go through all the original points, I don't know why
>> anyone would aim lower than a C2 piecewise-polynomial. Unfortunately, it
>> would be somewhat too late to just call it [tabread4~]. Or not.
>
> How low is too low? hmmm....
> tabread4~ is deficient as Cyrille pointed out, because the resulting
> function is not continuously differentiable (thanks for the
> correction).  So, what characteristics would be best for a "fast"
> interpolating function?
>
> When we have an interval between samples, we wish to fit a polynomial
> (because it's fast, I guess) that satisfies our constraints.
> We could specify the polynomial has the same values at x[-1],x[0],
> x[1], x[2] (tabread4~).  Four constraints, determines a cubic
> polynomial, works out as a linear algebra problem.
>
> or we could set x[0],x[1] and x'[0]=(x[1]-x[-1])/2 and x'[1]=(x[2]-x[0])/2
> again, 4 constraints, cubic polynomial, etc...
>
> or another 4 point scheme, with continuous 2nd derivative
> setting x[0], x[1], x'[0]=(x[1]-x[-1])/2 and x'[1]=(x[2]-x[0])/2
> and x''[0]=x[1]-2*x[0]+x[-1] and x''[1]=x[2]-2*x[1]+x[0]
> 6 constraints, 5th degree polynomial
>
> and if you additionally wanted it to actually go through x[-1] and
> x[2], it would be 7th degree
>
> So, even for 4-point interpolation, there are some options that could
> all be called tabread4~.
>
> But not all possibilities are worth analyzing... I'm not even sure
> what kind of method to use to narrow the field.
>
> Chuck
>




More information about the Pd-list mailing list