# Please help, need an example of IIRFilter

**URL:** <https://forum.juce.com/t/please-help-need-an-example-of-iirfilter/11673>\
**Category:** General JUCE discussion\
**Created:** [October 16, 2013, 11:03pm UTC](https://forum.juce.com/t/please-help-need-an-example-of-iirfilter/11673 "2013-10-16T23:03:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jensomat](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jensomat](https://forum.juce.com/u/jensomat)\
**Post date:** [October 16, 2013, 11:03pm UTC](https://forum.juce.com/t/please-help-need-an-example-of-iirfilter/11673/1 "2013-10-16T23:03:14Z")

</div>

Hi,

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&nbsp;IIRCoefficients class.

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

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

processingBuffer ( ...&nbsp;)  
{  
coL.makeHighShelf( ... );  
coR.makeHighShelf( ... );

filterL.setCoefficients(coL);  
filterR.setCoefficients(coR);

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

&nbsp;

thanks  
Jens

&nbsp;

---

<div class="post-metadata">

**Author:** ![jensomat](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jensomat](https://forum.juce.com/u/jensomat)\
**Post date:** [October 17, 2013, 7:23am UTC](https://forum.juce.com/t/please-help-need-an-example-of-iirfilter/11673/2 "2013-10-17T07:23:03Z")

</div>

you can delete my posting,

thanks.

---

<div class="post-metadata">

**Author:** ![fireplayer](https://avatars.discourse-cdn.com/v4/letter/f/48db29/32.png) [@fireplayer](https://forum.juce.com/u/fireplayer)\
**Post date:** [October 26, 2013, 6:20pm UTC](https://forum.juce.com/t/please-help-need-an-example-of-iirfilter/11673/3 "2013-10-26T18:20:00Z")

</div>

Please Help with filter

here is what I am doing:

//Previous set

m\_sampleRate = 44100;  
m\_freq = 100;  
IIRCoefficients =&nbsp;IIRCoefficients::makeLowPass (m\_sampleRate, m\_freq);  
m\_filter.setCoefficients( ic );

&nbsp;

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

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

&nbsp; &nbsp; m\_filter.processSamples (dataLeft, nSamples);  
&nbsp;&nbsp; &nbsp;m\_filters.processSamples (dataRight, nSamples);  
}  
  
I am asking again.&nbsp;This is not working for me. Anybody know why?

---

<div class="post-metadata">

**Author:** ![IvanC](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ivanc/32/685_2.png) [@IvanC](https://forum.juce.com/u/IvanC)\
**Post date:** [January 5, 2015, 8:12am UTC](https://forum.juce.com/t/please-help-need-an-example-of-iirfilter/11673/4 "2015-01-05T08:12:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fireplayer](https://avatars.discourse-cdn.com/v4/letter/f/48db29/32.png) [@fireplayer](https://forum.juce.com/u/fireplayer)\
**Post date:** [January 6, 2015, 2:39pm UTC](https://forum.juce.com/t/please-help-need-an-example-of-iirfilter/11673/5 "2015-01-06T14:39:03Z")

</div>

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,&nbsp;makeHighPass (freq range)

makeLowShelf,&nbsp;makeHighShelf,&nbsp;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.

Thanks

---

<div class="post-metadata">

**Author:** ![krepssound](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@krepssound](https://forum.juce.com/u/krepssound)\
**Post date:** [January 8, 2015, 3:48pm UTC](https://forum.juce.com/t/please-help-need-an-example-of-iirfilter/11673/6 "2015-01-08T15:48:14Z")

</div>

There is no default setting for&nbsp;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);
```

&nbsp;

---

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [October 7, 2015, 4:30pm UTC](https://forum.juce.com/t/please-help-need-an-example-of-iirfilter/11673/7 "2015-10-07T16:30:00Z")

</div>

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