Create low pass filter

Hello together,
I’m relatively new to the whole digital signal processing thing as I got a new module on that this semester. We already covered a bunch of filters such as Low-Pass, High-Pass, Notch, etc. Theoretically, I understand how all of these filters affect the audio signal, but now we need to design filters digitally in JUCE and I honestly don’t know how to start as we’re not allowed to use JUCE DSP’s inbuilt filters.

Let’s say, I want to create a simple first-order low pass filter plugin that is capable of handling varying cut-off frequencies (through a slider) at runtime. Referring to this video https://www.youtube.com/watch?v=uNNNj9AZisM, I’d like to design this as an FIR filter where the output is acquired by convolution using the current input and the impulse response.
I’ve seen that DSP provides functions to compute these input response coefficients, at least in IIR::Coefficients.

How could I design that filter assuming that I’m getting the raw data in the “processBlock” function in the audio processor?
Maybe it would be more efficient to design an IIR filter, so let me know that too, please.

Thanks in advance for your help!

Hi! Have a look at this to help get you moving in the right direction. https://www.earlevel.com/main/2012/12/15/a-one-pole-filter/

Thanks for your answer. Unfortunately, it is not working, so I’d like to double-check if I’m doing anything wrong.
My slider has a range of 0 - 20000 Hz. The default value for cut-off frequency is 500 Hz. There is an output when I put the slider to 0 Hz, but if the value is > 0 Hz, I don’t hear something at all.

So, I created a class for the one-pole filter as stated on the website you mentioned and my plugin processor holds an instance of it.
So I tried doing this:

void LowPassAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
   /*
  ...
  */

    for (int channel = 0; channel < totalNumInputChannels; ++channel)
    {
        auto* channelData = buffer.getWritePointer (channel);

        for(int sample = 0; sample < buffer.getNumSamples(); sample++)
        {
            channelData[sample] -= firstOrderLowPass->process(channelData[sample]);
        }
    }
}

So, is there a problem with the setting of cut-off frequency?

There’s quite a bit to unravel, and since this is an assignment I’d feel better pointing you in the right direction(s) rather than doing it for you.

First, you will need to have separate processing for each channel of audio that you’re processing. See this video for more info on what I mean: https://youtu.be/sn9DoNwKK7M

Then there’s connecting your slider to control the value of the cutoff and how to manage that. Find more about the audio processor value tree state here.

Part 1: https://youtu.be/nkQPsYOdIrk
Part 2: https://youtu.be/xgoSzXgUPpc

Have a look at this vid for basics on the audio callback / processing block: https://youtu.be/pv-JAB6ZLF8

Have a hack with this stuff and let us know how you get along! :slightly_smiling_face:

1 Like

Thanks very much for your comments and the videos. I’ve implemented the separate channel processing and the tree state by now, going to re-implement the low pass filter tomorrow :wink:

1 Like