[SOLVED] dsp::NoiseGate processSample exception

Hello all.

I am trying to implement the dsp:NoiseGate in the processor of an audio plug in.

In the prepareToPlay() method I have the following:

  juce::dsp::ProcessSpec spec;
        spec.sampleRate = sampleRate;
        spec.maximumBlockSize = samplesPerBlock;
        spec.numChannels = 1;
        noiseGate.prepare(spec);
        
        noiseGate.prepare(spec);
        noiseGate.setThreshold(-1.0); //50
        noiseGate.setAttack(5.0);
        noiseGate.setRelease(17.0);
        noiseGate.setRatio(1.0);

In the processBlock() I put the following:

 juce::dsp::AudioBlock<float> block{buffer};
        juce::dsp::ProcessContextReplacing<float> context{ block };        
        noiseGate.process(context);

This compiles but when running an exception appears triggered by the function processSample. The debugger ends on the line:

jassert (isPositiveAndBelow (channel, yold.size()));

Any suggestions?

Try this in the prepareToPlay code :

spec.numChannels = getTotalNumOutputChannels();

Some hosts process in stereo even if it looks like the track is in mono.

2 Likes

That actually worked! @xenakios you are a genius. I thought it was the number of input channels that was needed. Thanks!