
5point spline interpollation
Type : interpollation References : Joshua Scholar, posted by David Waugh Code : //nMask = sizeofwavetable1 where sizeofwavetable is a power of two.
double interpolate(double* wavetable, int nMask, double location)
{
/* 5point spline*/
int nearest_sample = (int) location;
double x = location  (double) nearest_sample;
double p0=wavetable[(nearest_sample2)&nMask];
double p1=wavetable[(nearest_sample1)&nMask];
double p2=wavetable[nearest_sample];
double p3=wavetable[(nearest_sample+1)&nMask];
double p4=wavetable[(nearest_sample+2)&nMask];
double p5=wavetable[(nearest_sample+3)&nMask];
return p2 + 0.04166666666*x*((p3p1)*16.0+(p0p4)*2.0
+ x *((p3+p1)*16.0p0p2*30.0 p4
+ x *(p3*66.0p2*70.0p4*33.0+p1*39.0+ p5*7.0 p0*9.0
+ x *( p2*126.0p3*124.0+p4*61.0p1*64.0 p5*12.0+p0*13.0
+ x *((p3p2)*50.0+(p1p4)*25.0+(p5p0)*5.0)))));
}; 
Comments
Added on : 27/05/03 by joshscholarREMOVETHIS[ AT ]yahoo[ DOT ]com Comment : The code works much better if you oversample before interpolating. If you oversample enough (maybe 4 to 6 times oversampling) then the results are audiophile quality.
Added on : 26/08/10 by transmogrifox at yahoo dot com Comment : This looks old...but if anybody reads this:
What do you mean by oversample first? That is practically what you are doing with interpolation. For example, if you want to oversample 6x, you would interpolate 5 evenly spaced points in between p2 and p3 using 5 points at base frequency centered around p2. The 5point spline interpolation seems like a lower CPU algorithm than a good sinc interpolation, and as a bonus it does not have much of a transient response (only 5 samples worth).
My main target application for something like this is delay line interpolation where there is a concern regarding high frequency notch depth...5th order interpolation is certainly an improvement over linear interpolation :)
Added on : 04/10/12 by Josh Scholar Comment : By oversample I meant do a windowed sinc doubling oversample a couple times.
The point is that a 4 times oversample can be based on table values and only gives you points exactly 1/4, 1/2 and 3/4 between the samples.
Then the spline can be used to interpolate totally arbitrary points between those, say speeding up and slowing down as needed, at very high quality.
If you don't oversample first, you'll get an audible amount of aliasing, though not as much as a linear interpolation. Unless the source has a lot of roll off (which is equivalent to it being oversampled anyway).
Added on : 16/08/14 by chris[ DOT ]dannemiller[ AT ]gmail[ DOT ]com Comment : Can any explain the derivation of this?

Add your own comment
Comments are displayed in fixed width, no HTML code allowed! 



