Max cutoff of filter

What is the max cutoff frequency for a low pass filter that can be used with either the juce::IIRFilter or the juce::dsp::StateVariableFilter::Filter. I assumed it would be sampleRate / 2.

Docs don’t say anything, but the IIRFilter has the following assert: jassert (frequency > 0 && frequency <= static_cast<float> (sampleRate * 0.5));

However, when my cutoff frequency gets close to sampleRate / 2, the IIRFilter seems to feedback and get out of control.

I tried the StateVariableFilter, but when the cuttoff gets high, it either gives me noise as output or a DC signal. Also, the StateVariableFilter doesn’t have notch – is there any plan to add that?

Any idea what I should limit my max cut off too?

Sounds like a root loci problem. Direct forms can have issues close to Nyquist when the pole locations get packed together closer than the numeric precision of the signal type. Are you using double or single precision floats?

The state variable filter has a little issue where you scale the input by a rather tiny gain to normalize the frequency response, and its inversely related to the square of the cutoff. So it makes sense you’d have noise issues at high cutoffs.

I think 20kHz is reasonable if you don’t want to mess with different filter topologies.

2 Likes

IIRFilter isn’t a template class, so it’s float only. I was using floats with StateVariableFilter as well. I’ll try capping my frequency at 20k.