ProcessorDuplicator - how to?

Thanks, I appreciate that!

Yes, I was staring at it, but it confuses me. Can the ProcessorChain actually chain mono and Duplicators after each other?
Or is a Processor already able to process multiple channels, and the Duplicator is only needed, if you need different states for each channel? - It annoys me, that I can only guess instead of understanding it.

I tired this setup now, wrapping several ProcessorDuplicators into one ProcessorChain, but fun fact, I can’t hear anything:

using Stereo    = dsp::ProcessorDuplicator<dsp::IIR::Filter<float>, dsp::IIR::Coefficients<float>>;
using Equalizer = dsp::ProcessorChain<dsp::IIR::Filter<float>, dsp::IIR::Filter<float>>;
dsp::ProcessorChain<Stereo, Stereo> filter;

void FilterProcessor::prepareToPlay (double sr, int samplesPerBlock)
{
    sampleRate = sr;
    dsp::ProcessSpec spec;
    spec.sampleRate = sr;
//    spec.maximumBlockSize = samplesPerBlock;
//    spec.numChannels = getTotalNumInputChannels();

    updateCoefficients();
    filter.prepare (spec);
}

void FilterProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
    dsp::AudioBlock<float>              ioBuffer (buffer);
    dsp::ProcessContextReplacing<float> context  (ioBuffer);
    filter.process (context);
}

void FilterProcessor::releaseResources()
{
    filter.reset();
}

void FilterProcessor::updateCoefficients ()
{
    const float loFreq = *(state.getRawParameterValue (paramLoFreq));
    const float loQ    = *(state.getRawParameterValue (paramLoQ));
    const float hiFreq = *(state.getRawParameterValue (paramHiFreq));
    const float hiQ    = *(state.getRawParameterValue (paramHiQ));

    auto loCoeff = dsp::IIR::Coefficients<float>::makeLowShelf (sampleRate, loFreq, loQ, 0.25);
    filter.get<0>  ().state = loCoeff;
    auto hiCoeff = dsp::IIR::Coefficients<float>::makeHighShelf (sampleRate, hiFreq, hiQ, 0.25);
    filter.get<1>  ().state = hiCoeff;

    loCoeff->getMagnitudeForFrequencyArray (frequencies.data(), magnitudes.data(), frequencies.size(), sampleRate);
    std::vector<double> mags (frequencies.size());
    hiCoeff->getMagnitudeForFrequencyArray (frequencies.data(), mags.data(), frequencies.size(), sampleRate);
    FloatVectorOperations::multiply (magnitudes.data(), mags.data(), static_cast<int> (frequencies.size()));
}

Is that the right approach at all?

Thanks,
Daniel

1 Like