Howdy
I'm working on a delay line, similar to the one in the Juce demo. However, when I start to work on interpolation, I get crazy values out of my delay buffer.
First some .h file stuff...
class DelayFeed { public: DelayFeed(); ~DelayFeed(); AudioSampleBuffer delayBuf; float* delayData; ... double process(float input);
So I have an audioSampleBuffer and in the constructor, I do this:
DelayFeed::DelayFeed() : delayBuf(1, 44100){ rptr = 0; wptr = 0; delayBuf.clear(); delayData = delayBuf.getSampleData(0);
Now if I go through this and pull out values from the delayData, I get usable results. I can even change the delay time and while there's a click, I still get good data.
The problem comes when I try to do interpolation. I have isolated the problem to pulling the index above the lower index.
rpi = (int)floor(rptr); //integer value to use as array index float diff = rptr - rpi; output = delayData[rpi + 1];// should be: diff * delayData[rpi] +(1.f - diff)*delayData[rpi + 1];
I try to take the value at the index before, and the value at the index AFTER the 'interpolated index'...but that index AFTER is always garbage. I thought the delayBuf.clear() would basically initialise my data array to all 0's.
Am I just using the audio buffer fundamentally wrong? There is a more code involved and I can post more if needed.
If yall have any ideas, do let me know.
Thanks