How to implement low pass and high pass filters for my plugin

Okay so for my plugin I have been looking into how to create a low pass and high pass filter for my plugin, I have looked into the documentation but have no idea for which file and where I need to implement it. so i assume this is one of the pieces of code to initiate the filter however i am unsure how to use it. dsp::IIR::Filter< SampleType >::Filter(Coefficients< NumericType > * coefficientsToUse);

also what do i put in the process block. i am new to c++; and audio programming so please explain well thanks.

this is the document i have been using.

Hey, here’s a tutorial I did on implementing the Juce DSP module IIR filter. Hope this helps get you going in the right direction :slightly_smiling_face:


thanks, ill have a look

hello, followed your tutorial exactly and watched the previous one about setting dsp up. i have a problem with getting the raw parameter loaded where the first parameter (no matter which i load first) the tree part of the code is always underlined red. what can cause this?

this is the code, note, only the word tree in the first line is underlined red, if i change the order it is still line one that has the error.
float lpRes = *tree.getRawParameterValue(“lpRes”);
float hpRes = *tree.getRawParameterValue(“hpRes”);
float hpFreq = *tree.getRawParameterValue(“high pass”);
float lpFreq = *tree.getRawParameterValue(“low pass”);

Even though this one is probably trivial, please make it a habit if you post problems, to give as much information as possible. Especially if you quote code from external resources, provide the code you are using at the moment.

In this case, undeclared identifier means, that the compiler doesn’t know of anything named tree. Most likely you wanted to add a member called tree of type AudioProcessorValueTreeState in the header pluginprocessor.h.

okay thanks, i think i solved it by using this code instead float
hpRes = *state->getRawParameterValue(“hpRes”);
float lpRes = *state->getRawParameterValue(“lpRes”);
float hpFreq = *state->getRawParameterValue(“high pass”);
float lpFreq = *state->getRawParameterValue(“low pass”);

i found things referenced to like this somewhere else in my code so thats what i thought would work

So it was a naming confusion… it is completely up to you if you call the AudioProcessorValueTreeState instance tree or state, just keep it consistent. So the error sneaked in by copying from two different examples.

One note: the getRawParameterValue() always has to traverse all parameters to find the right one. No big deal, since you probably have not too many parameters. But you do that at least 100 times a second, so you can save CPU by storing the pointer to the float rather than doing the lookup every time.

Have a float* member for each parameter and set it to point to the result of getRawParameterValue():

// private members of processor class:
float* hpRes;
float* lpRes;
float* hpFreq;
float* lpFreq;

// in constructor AFTER createAndAddParameter:
hpRes = state->getRawParameterValue(“hpRes”);
lpRes = state->getRawParameterValue(“lpRes”);
hpFreq = state->getRawParameterValue(“high pass”);
lpFreq = state->getRawParameterValue(“low pass”);

// in processBlock() use the variables with an *
foo = *hpFreq * bar;


okay thanks, ill look into doing that when i get the rest of the code working, solving one problem at a time atm :slight_smile:

The tutorial has worked well, however i want a low and a high pass filter, how do i implement two filters into the same project? i initialised both filters and controlled them in the same update filter functions and added two process context replacing into the process block and it creates random issues like it constantly outputting a volume of 1, or just fills the visualiser completely and this kept happening randomly. if you could explain how to have two filters it would be extremely helpful. thanks

Afaik there are many ways to do this, but 2 options come to my mind:
a) Implement the filters in a ProcessorChain: check the introduction to DSP tutorial, they make use of ProcessorChain and provide some code so you can study.
b) Use an AudioProcessorGraph, implement each filter in an AudioProcessor and cascade them in serial. Check this tutorial:

i think i got it thanks for the help