A couple of questions about the LagrangeInterpolator


#1

Hi Jules,

 

I just used your code as basis to implement a Catmull-Rom interpolator (http://www.juce.com/forum/topic/catmull-rom-interpolator-based-lagrange-interpolator), and I have a couple of questions about the LagrangeInterpolator:

 

1. In the 'processAdding' method, line 200, the position value for the call to LagrangeHelpers::valueAtOffset is 'jmax (0.0f, 1.0f - (float) pos)', while in the 'process' method, line 132, the position value is '1.0f - (float)pos'. I guess that either the jmax call in 'processAdding' is unnecessary (or wrong), or that 'jmax' is lacking in 'processing'?

 

2. The 'pos' value is calculated in a different way whether you are sampling up or down (i.e. actualRatio < 1.0 or not). I don't quite understand why it is so, but I guess it has a reason. But are things working correctly if 'actualRatio' crosses 1.0 from one call to another?


#2

Thanks - it does seem like that jmax is maybe missing from the process method.

As for the pos variable: I'm fairly sure it's correct, but I remember it making my head hurt when I wrote it, so if you can prove it wrong, I wouldn't be completely surprised!


#3

I think there is an error with the pos or rather subSamplePos, if you switch between those ways. Lets say, we had a ratio < 1.0 before and created a subsample offset by that. If I now set the to be ratio == 1.0, the incoming samples will just be copied ignoring the subsample offset. I am pretty sure I can hear this, when using the algorithm on sine waves it clicks a little at the change.
So I commented out the ratio == 1 state and the clicks weren’t there anymore, at least going from ratio < 1.0 to ratio == 1.0. There is still a click going from ratio <= 1.0 to ratio > 1.0 with my plugin. It looks like subSamplePos is also treated a little differently there, but I don’t quite understand this enough to fix it so far.

It is not really audible with typical audio or other waveforms, though.

Here is my version of the interpolate function, I tested it for ratios up to 10 with sine waves and audio and heard no clicks, when going through the ratios, but I can’t give any guarantees:
LagrangeAlternative.txt (1.4 KB)


#4

Hi there - sorry, we just noticed this post. Thanks for the heads-up, I’ll take a look at this now!