Ladder Filter

I want to use the the Ladder Filter without using a processor chain.
How do I create a Ladder Filter?

juce::dsp::LadderFilter <float>ladderFilter;  // declare

ladderFilter = juce::dsp::LadderFilter() // create ???

The first line creates the LadderFilter, it has a default constructor:

You’ll just need to use LadderFilter::prepare() in your prepareToPlay() callback before you start using it

And, to avoid the usual mistakes :

-A separate filter instance is likely needed for each audio channel. (Unless the filter happens to directly support stereo or more channels operation, but that usually hasn’t been the case with the JUCE DSP classes.)
-The filter or flters must be member variables in some suitable class. (Your AudioProcessor subclass or whatever you are using). You cannot for example just create them on the fly in the audio processing function.


Ok, thanks.

But now what parameter(s) do I invoke dsp::LadderFilter::process(const ProcessContext &context) with?

void MainComponent::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
    auto* leftBuffer  = bufferToFill.buffer->getWritePointer (0, bufferToFill.startSample);
    auto* rightBuffer = bufferToFill.buffer->getWritePointer (1, bufferToFill.startSample);

    for (auto sample = 0; sample < bufferToFill.numSamples; ++sample)
        leftBuffer[sample] = rightBuffer[sample] = (random.nextFloat() * 2.0f) - 1.0f

        ladderFilter.process(/* ??? */);

Ok, thanks.

With a ProcessContext, which takes an AudioBlock which should reference your bufferToFill.buffer… The intertwining of the old and new audio APIs is pretty confusing to me so I may not be the best person to be answering :slight_smile:

You’ll probably want to check out the documentation for the dsp module, as it introduces a lot of new classes and such for processing audio, and you’ll need to use these for any of the DSP module processors:

Thanks for the help.