iOS IIRFilter problems - Juce Assertion Failure


#1

I’m having trouble with IIRFilter in an iOS Audio Application.

I used the setCoefficients method on a slider change, but when I move the slider, I get crackling and then the app freezes and I get a Juce Assertion Failure:

08 PM

Here is where I change the coefficients to correspond to the frequency slider:

I checked the assertion in juce_IIRFilter.cpp:

But I don’t see how it’s failing. I’ve set the range for the lpfSlider to be from 20 to 20k in the MainContentComponenet constructor here:

and from what I read, iOS audio data from the microphone is sampled at 44.1 kHz.

Here is where I define the global sample rate, fs, in prepareToPlay():

So why is this assertion failing?

Anyone know what’s going on here?

Thanks!


#2

Update:

I just set the max slider value to 10k instead of 20k, and I’m not getting the Assertion Error anymore. It still doesn’t make sense to me since 20k is still less than than 44.1k/2. Also, I double checked that the sample rate was 44.1k, and it was.


#3

Well if the sample rate was indeed 44.1k then I have no idea why an assertion is being triggered there. However, sample rates of 24000 and 22050 Hz are common, so i suspect that might be the cause.


#4

This is what I initially thought, too.

But then I printed off the sample rate from preparetoplay() to be sure, and it was 44100.

Weird.


#5

You should look at its value in the debugger, when you hit the assertion. That would be pretty conclusive.


#6

You were right, t0m. I checked the sample rate again and it was 22050. It was definitely 44100 sometimes, though. I suppose it’s programmed to change based on certain performance parameters?

Anyway, issue resolved. I just set the slider max to be dependent on the sample rate. Thanks for your help!