HI guys,
I’m trying to create a ping-pong delay with a state variable filter. I’ve set up my ping pong with the filter using the dsp module, however the filter is filtering the full signal when I only want it to filter the delayed signal. I’ve used an audio block but when I try use the delayBuffer instead of the original buffer the track automutes within my DAW. Ive tried a variety if different thing but still cant seem to get to grips with it. Would greatly appreciate some help. Thanks Jack
void BasicDelayAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
buffer.clear(i, 0, buffer.getNumSamples());
// channelData is an array of length numSamples which contain
// the audio for one channel
float *channelDataL = buffer.getWritePointer(0);
float *channelDataR = buffer.getWritePointer(1);
// delayData is the circular buffer for implementing the delay
float* delayDataL = delayBuffer.getWritePointer(0);
float* delayDataR = delayBuffer.getWritePointer(1);
for (int i = 0; i < buffer.getNumSamples(); ++i)
{
float sample1 = channelDataL[i];
float sample2 = channelDataR[i];
if (ppWidth == 0.0)
{
channelDataL[i] = channelDataL[i];
channelDataR[i] = channelDataR[i];
}
else
{
if (ppSartingPoint == 0)
{
float ppPanning = (ppWidth + 1.0) / 2.0;
channelDataL[i] = channelDataL[i] * (1.0 - ppPanning);
channelDataR[i] = channelDataR[i] * ppPanning;
}
else
{
float ppPanning = ((-1 * ppWidth) + 1.0) / 2.0;
channelDataL[i] = channelDataL[i] * (1.0 - ppPanning);
channelDataR[i] = channelDataR[i] * ppPanning;
}
}
// Calculate the next output sample (current input sample + delayed version)
float outputSampleL = (channelDataL[i] + (wetDry * delayDataR[readIndex]));
float outputSampleR = (channelDataR[i] + (wetDry * delayDataL[readIndex]));
// Write the current input into the delay buffer along with the delayed sample
delayDataL[writeIndex] = channelDataL[i] + (delayDataR[readIndex] * feedback);
delayDataR[writeIndex] = channelDataR[i] + (delayDataL[readIndex] * feedback);
// Increment the read index then check to see if it's greater than the buffer length
// If so wrap back around to zero
if (++readIndex >= delayBufferLength)
readIndex = 0;
// Same with write index
if (++writeIndex >= delayBufferLength)
writeIndex = 0;
if (ppSartingPoint == 0)
// Assign output sample computed above to the output buffer
{
channelDataL[i] = outputSampleL + sample1 * ppWidth;
channelDataR[i] = outputSampleR;
}
else
{
channelDataL[i] = outputSampleL;
channelDataR[i] = outputSampleR + sample2 * ppWidth;
}
}
juce::dsp::AudioBlock<float> output (buffer);
updateFilter();
stateVariableFilter.process(dsp::ProcessContextReplacing<float> (output));
}