Midi synth delay effect causing repeating click

Hello!

I have been struggling with getting my program to have a delay effect without a repeating clicking sound when I hold down a note. I have tried using the smoothing value function in JUCE on my delay parameters and even on the delay itself (which just caused the delay to not have any effect). I assume the clicking may be happening because i set my delay class functions inside a for loop ( for (int i=0; i<numberSamples; i++) {…} ) inside the process block. However I dont see where else I can place this as I use parameterized delay variables that have to be updated all the time. Would love to hear anybody’s thoughts on how I could go about fixing this.

Many Thanks!

such a thing is mostly caused by a bug in the coding, so if you want help for that: post the relevant section of your code

Thanks for the tip!

void ProjectAudioProcessor::processBlock (juce::AudioBuffer& buffer, juce::MidiBuffer& midiMessages)
{
buffer.clear(); // Clearing buffer
juce::ScopedNoDenormals noDenormals;

auto* left = buffer.getWritePointer(0);            //  Creating pointers for the left channel in the buffer
auto* right = buffer.getWritePointer(1);           //  Creating pointers for the left channel in the buffer

synth.renderNextBlock(buffer, midiMessages, 0, buffer.getNumSamples()); // Main synth process
int numSamples = buffer.getNumSamples();           // Get number of samples

for (int i=0; i<numSamples; i++)
{
   // Applying smoothing process on delay time
    smoothDelayTime.setTargetValue(*delayTimeParameter);
    float dT = smoothDelayTime.getNextValue();

    smoothDelayTime.setTargetValue(*feedbackParameter);
    float fB = smoothDelayTime.getNextValue();

    delay.setDelayTime(dT * sR);                           // Setting delay time in samples
    delay.setFeedback(fB);                                 // Setting feedback
    
    float delayProcess = delay.process(left[i]);
    float delayedSamples = 0.5 * (left[i] + delayProcess);   // Mixing delay into audio
    
    float monoMixL = delayedSamples;
    float monoMixR = delayedSamples;

    left[i] = monoMixL;                                    // Sending delayed mix to output
    right[i] = monoMixR;
}

}

the following lines should probably not be inside the loop: Only the getnextValue() calls need to be inside the loop. Not sure whether this causes the ticking though.

smoothDelayTime.setTargetValue(*delayTimeParameter);
smoothDelayTime.setTargetValue(*feedbackParameter);

Did not solve the ticking problem. But still good to know thank you!

1 Like

you should first try to have the delay running witout updating the params constantly.
So put

delay.setDelayTime(*delayTimeParameter);                           // Setting delay time in samples
delay.setFeedback(*feedbackParameter);

in front of the loop
Also: If you didn’t program the delay object yourself, read up or analyse how it exactly works.