How to use the dsp::NoiseGate?

Hi!
I need help to understand how to use the dsp::NoiseGate class. I can’t seem to get it to work, and I’m not entirely sure what the setThreshold method expects. The gate is initialized as a class member with the default constructor and I’m setting these parameters in my prepareToPlay method along with an processing buffer I will use later on:

processingBuffer.setSize(numInputChannels, samplesPerBlockExpected, false, true);
// ...

juce::dsp::ProcessSpec spec;
spec.sampleRate = sampleRate;
spec.maximumBlockSize = samplesPerBlockExpected;
spec.numChannels = numOutputChannels;

noiseGate.prepare(spec);
noiseGate.setThreshold(-1.0); //50
noiseGate.setAttack(5.0);
noiseGate.setRelease(17.0);
noiseGate.setRatio(1.0);

Then, in my getNextAudioBlock method I am making a copy of my audio buffer since I’m doing some processing later. Here is where I’m trying to apply the noise gate, giving it a process context to work on.

if (bufferToFill.buffer->getNumChannels() > 0)
{
    int numSamples = bufferToFill.buffer->getNumSamples(); // To make sure copied buffer size is the same.

    // Copies actual buffer into a buffer for processing.
    for (int i = 0; i < processingBuffer.getNumChannels(); ++i)
    {
        processingBuffer.copyFrom(i, 0, bufferToFill.buffer->getReadPointer(i), numSamples);
    }
    
    // HERE is the noise gate!
    juce::dsp::AudioBlock<float> block{ processingBuffer };
    juce::dsp::ProcessContextReplacing<float> context{ block };
    noiseGate.process(context);
    
    auto* channelData = processingBuffer.getReadPointer(0, bufferToFill.startSample);
    auto* outBuffer = processingBuffer.getWritePointer(0, bufferToFill.startSample);
    
    // Puts samples into non-const buffer.
    for (unsigned int i = 0; i < numSamples; ++i)
    {
        outBuffer[i] = channelData[i];
    }

    // Applies filter.
    hiPassFilter.processSamples(outBuffer, numSamples);

    // Puts samples into FFT fifo after processing.
    for (unsigned int i = 0; i < numSamples; ++i)
    {
        fft.pushNextSampleIntoFifo(outBuffer[i]);
    }

    // Just for audio output. Can be removed --
    for (int i = 0; i < processingBuffer.getNumChannels(); ++i)
    {
        bufferToFill.buffer->copyFrom(i, 0, processingBuffer, i, 0, numSamples);
    }

    auto* read = bufferToFill.buffer->getReadPointer(0, bufferToFill.startSample);
    auto* write_l = bufferToFill.buffer->getWritePointer(0, bufferToFill.startSample);
    auto* write_r = bufferToFill.buffer->getWritePointer(1, bufferToFill.startSample);
    for (unsigned int i = 0; i < numSamples; ++i)
    {
        write_l[i] = read[i] * gainSlider.getValue();
        write_r[i] = read[i] * gainSlider.getValue();
    }
    // -- can be removed
}
// ...

First I thought that the threshold would be expecting negative dB values, like with a gate in a DAW, and after digging through the juce_NoiseGate.cpp file it looked like I was right. But I have tried setting the threshold to a number of values, both positive and negative, without results. Please help me understand this class :grinning:

Edit: I added some more of the getNextAudioBlock method.