Hey,
I’m trying to apply a simple echo effect using an “echo buffer” (circular), and not sure how to deal with the read/write pointers native to AudioBuffer.
void AudioPoocessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
auto totalNumInputChannels = getTotalNumInputChannels();
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
auto *channelData = buffer.getWritePointer(channel);
for (int i = 0; i < buffer.getNumSamples(); ++i) {
auto echoReadPtr = echoBuffer.getReadPointer(channel, i);
auto echoWritePtr = echoBuffer.getWritePointer(channel, i);
// Calculate echo value and return to new echo
*echoWritePtr = channelData[i] += *echoReadPtr * *echoParameter;
// How do I increment the pointers??
}
}
}
I’ve been attempting to increment the pointers manually, but then resetting them (upon clearing the buffer) is complicated and starts needing multiple global variables… I get a feeling I’m doing something wrong here. Any guidance?