How do I use dsp::ProcessorDuplicator with dsp::IIR:Filter correctly?

Hello forum :wave:

my plan is to apply parallel bandpass filters on an input signal using an array of ProcessorDuplicators. I’m getting an assertion failure in juce_ProcessorDuplicator.h:70:
jassert ((int) context.getInputBlock().getNumChannels() <= processors.size());

I have no idea what could be wrong with my code or how to set the number of processors correctly. Do you?

PluginProcessor.h:

AudioBuffer<float> audioAnalyseBuffer;
static const int filterCount = 22;
array<dsp::ProcessorDuplicator<dsp::IIR::Filter<float>, dsp::IIR::Coefficients<float>>, filterCount> modulatorFilterBank;

PluginProcessor.cpp:

prepareToPlay (double sampleRate, int samplesPerBlock)
{
    audioAnalyseBuffer.setSize(getTotalNumInputChannels(), samplesPerBlock);
    dsp::ProcessSpec spec;
    spec.sampleRate = sampleRate;
    spec.maximumBlockSize = samplesPerBlock;
    spec.numChannels = getTotalNumOutputChannels();

    for (int i = 0; i < modulatorFilterBank.size(); ++i) {
        modulatorFilterBank[i].reset();
        *modulatorFilterBank[i].state = *dsp::IIR::Coefficients<float>::makeBandPass(sampleRate, frequency, filterQ);
        modulatorFilterBank[i].prepare(spec);
    }
}

processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
    dsp::AudioBlock<float> audioInputBlock(buffer);
    dsp::AudioBlock<float> audioAnalyseBlock(audioAnalyseBuffer);

    for (int i = 0; modulatorFilterBank.size(); ++i) {
        // this is what causes the assertion failure:
        modulatorFilterBank[i].process(dsp::ProcessContextNonReplacing<float>(audioInputBlock, audioAnalyseBlock));
    }
}

I’ve tried replacing all the numChannels methods with a fixed value of 2, didn’t help.
Also I’ve std::cout << processor.size() right before the jassert. It prints 44 times 2, then once 0, followed by the assertion failure.

when I used dsp::StateVariableFilter before, it worked with my approach.
Do you have any hints or ideas what might be wrong?

Thanks a lot :pray:

To infinity… and beyond!

1 Like

oh, stupid me :see_no_evil:

Danke, Daniel!