# Can't Update Filter IIR::Coeffs In Plugin?

**URL:** https://forum.juce.com/t/cant-update-filter-iir-coeffs-in-plugin/38286
**Category:** Audio Plugins
**Created:** [March 26, 2020, 1:39pm UTC](https://forum.juce.com/t/cant-update-filter-iir-coeffs-in-plugin/38286 "2020-03-26T13:39:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sulkyoptimism](https://avatars.discourse-cdn.com/v4/letter/s/a587f6/32.png) [@Sulkyoptimism](https://forum.juce.com/u/Sulkyoptimism)
#### Post date: [March 26, 2020, 1:39pm UTC](https://forum.juce.com/t/cant-update-filter-iir-coeffs-in-plugin/38286/1 "2020-03-26T13:39:28Z")

</div>

Hi there,

I know this may be a stupid question but i have been rooting around on this site for days and days now trying to find an answer to why i cant seem to update my IIR::filters mid session after opening my plugin. I think the problem lies within when and where im trying to update them but i cannot find a working way of doing it at all. So where and how would one update these filters?

Any help would be appreciated.

in Processor.h: (This is the type of filter etc that i am using)

```
private:
OwnedArray<dsp::IIR::Coefficients<float>> m_Low_LoMid_XOArray;
OwnedArray<dsp::IIR::Coefficients<float>> m_LoMid_Mid_XOArray;
OwnedArray<dsp::IIR::Coefficients<float>> m_Mid_MidHi_XOArray;
OwnedArray<dsp::IIR::Coefficients<float>> m_MidHi_High_XOArray;

dsp::ProcessorDuplicator<dsp::IIR::Filter<float>, dsp::IIR::Coefficients<float>>Low_LP;
dsp::ProcessorDuplicator<dsp::IIR::Filter<float>, dsp::IIR::Coefficients<float>>Low_LP2;

```

in Processor.cpp: (This function seems to work fine upon prepare to play etc)

```
void DistortionTest2AudioProcessor::UpdateFilters()
{
//Inbuilt, comment out to use GUI Update
_Low_MidLoXO = *TreeState.getRawParameterValue("F1");
_MidLo_MidXO = *TreeState.getRawParameterValue("F2");
_Mid_MidHiXO = *TreeState.getRawParameterValue("F3");
_MidHi_HighXO = *TreeState.getRawParameterValue("F4");

//Dont change
float f1 = _Low_MidLoXO;
float f2 = _MidLo_MidXO;
float f3 = _Mid_MidHiXO;
float f4 = _MidHi_HighXO;

if (bands >= 2) //Per band
{
	ReferenceCountedArray<dsp::IIR::Coefficients<float>> Low_LPCoeffs = dsp::FilterDesign<float>::designIIRLowpassHighOrderButterworthMethod(f1, SampRate, 1); //Create a butterworth filter coeff structure
	ReferenceCountedArray<dsp::IIR::Coefficients<float>> LoMid_HPCoeffs = dsp::FilterDesign<float>::designIIRHighpassHighOrderButterworthMethod(f1, SampRate, 1); //and the opposing highpass

	for (auto Coeff : Low_LPCoeffs)
		m_Low_LoMid_XOArray.add(new dsp::IIR::Coefficients<float>(*Coeff)); //Add those coeffs to an array per xo

	for (auto Coeff : LoMid_HPCoeffs)
		m_Low_LoMid_XOArray.add(new dsp::IIR::Coefficients<float>(*Coeff));

	*Low_LP.state = *m_Low_LoMid_XOArray[0]; //update the xo's filters with the new coeffs (one coeff per pair)
	*Low_LP2.state = *m_Low_LoMid_XOArray[0];
	*LoMid_HP.state = *m_Low_LoMid_XOArray[1];
	*LoMid_HP2.state = *m_Low_LoMid_XOArray[1];

```

Editor.cpp: (The issue i think is finding the right place for the call? But it doesnt work here which i thought it should.)

```
void DistortionTest2AudioProcessorEditor::FreqChange()
{
processor.UpdateFilters();
}

```

Like i say sorry for such a stupid question but if anyone knows where i am going wrong or can point me towards the correct resource i’d be appreciative.

Thanks again,  
Sulkyoptimism

---

<div class="post-metadata">

### Author: ![joshlberry](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@joshlberry](https://forum.juce.com/u/joshlberry)
#### Post date: [December 3, 2021, 2:51pm UTC](https://forum.juce.com/t/cant-update-filter-iir-coeffs-in-plugin/38286/2 "2021-12-03T14:51:56Z")

</div>

Hi! Did you ever get to the bottom of this? Also hitting this wall trying to change the coefficients of Butterworth filters!

---

<div class="post-metadata">

### Author: ![Sulkyoptimism](https://avatars.discourse-cdn.com/v4/letter/s/a587f6/32.png) [@Sulkyoptimism](https://forum.juce.com/u/Sulkyoptimism)
#### Post date: [December 3, 2021, 3:25pm UTC](https://forum.juce.com/t/cant-update-filter-iir-coeffs-in-plugin/38286/3 "2021-12-03T15:25:51Z")

</div>

I cant quite remember, it was a university project so its been long forgotten, but i think i ended up using other filter types in JUCE, i’ll have a look for the code now. But no promises i can find it.

---

<div class="post-metadata">

### Author: ![joshlberry](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@joshlberry](https://forum.juce.com/u/joshlberry)
#### Post date: [December 3, 2021, 4:46pm UTC](https://forum.juce.com/t/cant-update-filter-iir-coeffs-in-plugin/38286/4 "2021-12-03T16:46:29Z")

</div>

Thanks! That would be amazing.
