How to use juce::LinearInterpolator?

Hi,

I can’t find any examples. When I use speedRatio = 1.0, everything seems to be fine. But if I want to use different speeds then I hear just crackles and my sine looks like 512 samples is sine and the rest is just zero values.

I asked chatgpt and after two hours we come with it. But it still not working as expected:

// prepareSample:
float inputSample[2048]{}; // sine
float output[bufferSize]; // size equals to the buffer size. Basically 512 or 1024.
 juce::LinearInterpolator interpolator;
...
// render next block:
double speedRatio = 2.0;
auto sampleSize = 2048;
auto increment = interpolator.process(speedRatio, inputSample, outputSamples, bufferSize, sampleSize, 1);

  position += increment; // increment for some reason always 0 why?!?!

  if (position >= sampleSize) {
      position -= sampleSize;
      interpolator.reset();
  }

It looks like I misunderstood int wrapAround parameter. I used 1. Now I tried to use 2048 and it seems like generate now full sample. Here is on screenshot I used test 16.2343 speedRatio.

But why breaks? how to make the signal continuous by filling the output buffer? Any example?

Thank you!

wrapAround is the size of your input. Here indeed 2048

never call reset

@otristan thx. I forgot to put updated code. Yes I removed reset() but result you can see on screenshot above. In fact, it never entered this line, because the size was always returned less than sampleSize, it was 2047 max