I’ve been fooling around with the dsp module, and I’m not sure I fully understand how to effectively use the DelayLine to create a delay with multiple echos. My processBlock method (below) is quite simplistic, but works for a single delay.
Now I understand that its just essentially just a wrapper over a circular buffer with some handy math functions, but lets say I wanted to get 3 - 5 echoes gradually reducing in volume. Should I be keeping track of this manually in a separate buffer, or should I create additional delayLines with separate sample delay values and simply add the result from the pop sample into the main buffer using different gains? I feel like this method would use up additional memory unnecessarily. What is the standard for this sort of thing?
void BeatDelayAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
float time = *apvts.getRawParameterValue("time");
float samples = (samplerate * 2) * time;
const int bufferLength = buffer.getNumSamples();
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
auto* data = buffer.getWritePointer(channel);
for (int i = 0; i < bufferLength; i++)
{
delayLine->pushSample(channel, data[i]);
data[i] += delayLine->popSample(channel, samples, false);
}
}
}