Please help, need an example of IIRFilter



before updating Juce i could add a filter in a simple way and directly;

IIRFilter.makePeakFilter ( ... )

but now i don't understand how to manage this with the IIRCoefficients class.

this is what i tried, but i can't here any output:

juce::IIRFilter filterL, filterR;
IIRCoefficients coL, coR;

processingBuffer ( ... )
coL.makeHighShelf( ... );
coR.makeHighShelf( ... );


delayBufferL [Counter] = filterL.processSingleSampleRaw( delayBufferL [Counter] );
delayBufferR [Counter] = filterR.processSingleSampleRaw( delayBufferR [Counter] );





you can delete my posting,



Please Help with filter

here is what I am doing:

//Previous set

m_sampleRate = 44100;
m_freq = 100;
IIRCoefficients = IIRCoefficients::makeLowPass (m_sampleRate, m_freq);
m_filter.setCoefficients( ic );


void CEQProcessor::processBlock (AudioSampleBuffer &buffer, MidiBuffer &midiMessages)

    float *dataLeft = buffer.getSampleData (0);
    float *dataRight = buffer.getSampleData (1);
    int nSamples = buffer.getNumSamples();

    m_filter.processSamples (dataLeft, nSamples);
    m_filters.processSamples (dataRight, nSamples);

I am asking again. This is not working for me. Anybody know why?


Hi FirePlayer

Your code is not working because the state/temporary variables of your filter are shared by the left channel and the right channel, which is wrong. You should create for example two IIRFilter objects, one for the left, and one for the right, and do exactly the same thing than in your code with these two objects, it should be fine then.


Thank you Wolfen,

I am getting better results but becasue I don't know Audio math, it is not doing what I expect. I know this is a lot to ask but can you answer this.

What should be default JUCE settings and the range of values passed to: (Of course I know the samplerate)

makeLowPass, makeHighPass (freq range)

makeLowShelf, makeHighShelf, makePeakFilter (freq, q, and gain range)

As you can see I am not an audio guy, but I need a basic filter/eq for my app.



There is no default setting for frequency, use some frequency analysis vst if you are not sure what you are doing.

Code should work like this:

float *dataLeft = buffer.getWritePointer (0);
float *dataRight = buffer.getWritePointer (1);

int nSamples = buffer.getNumSamples();
IIRCoefficients ic = IIRCoefficients::makeLowPass (m_sampleRate, freq);

m_filterL.setCoefficients( ic );
m_filterR.setCoefficients( ic );

m_filterL.processSamples (dataLeft, nSamples);
m_filterR.processSamples (dataRight, nSamples);



...ignore ... wrong thread ...