ProcessorChain has no effect on output audio

I’m trying to apply a ProcessorChain to an AudioSource, no exception was thrown, file was played, but the sound has no different from the original regardless the argument of the IIR::makeLowPass i provided, here’s my code:

Initialise filter:

void AudioEngine::initFilters() {
    std::unique_ptr<dsp::ProcessSpec> processSpec = std::make_unique<dsp::ProcessSpec>();
    processSpec->numChannels = 2;
    processSpec->sampleRate = 44100;
    filterChain.get<0>().prepare(*processSpec);


    dsp::IIR::Coefficients<float>::Ptr coefficient = dsp::IIR::Coefficients<float>::makeLowPass(
            44100, 500.0f, 5.0f);
    *filterChain.get<0>().state = *coefficient;
}

Process buffer:

void AudioEngine::getNextAudioBlock(const AudioSourceChannelInfo &bufferToFill) {
    if (readerSource == nullptr) {
        bufferToFill.clearActiveBufferRegion();
        return;
    }

    dsp::AudioBlock<float> audioBlock(*bufferToFill.buffer);
    dsp::ProcessContextReplacing<float> context(audioBlock);

    filterChain.process(context);

    transportSource.getNextAudioBlock(bufferToFill);
}

Am i missing something

filterChain.process(context);
transportSource.getNextAudioBlock(bufferToFill);

Those are in the wrong order, you need to make the transport source produce the sound first and then use the filter on it.

1 Like