Possible bug in LagrangeInterpolator::process()


I think I’ve bumped into a problem with LagrangeInterpolator. The comments for one version of process() say this:

/** Resamples a stream of samples.

[ stuff omitted ]
@param wrapAround if the stream exceeds available samples, it wraps back for
wrapAround samples. If wrapAround is set to 0, it will feed zeroes.

    @returns the actual number of input samples that were used

However, in the last line of the implementation, I find this:

    return ((int) (in - originalIn) + wrap) % wrap;

That line is always executed. If wrap is zero, the modulo operation will fail, right?


Thanks for spotting that! It needs indeed a check for 0.
Seems like people either use the unchecked version or use it for circular buffers.

I’ll fix that, since it is code I suggested a year back…


Good–you’re welcome, and thank you!