Ladder Filter


#1

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 ???

#2

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

https://docs.juce.com/master/classdsp_1_1LadderFilter.html

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


#3

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.


#4

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(/* ??? */);
    }
}

#5

Ok, thanks.


#6

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:

https://docs.juce.com/master/group__juce__dsp.html


#7

Thanks for the help.