Problem with the state variable filter with low resonance and high frequency.

247 views
Skip to first unread message

Guillaume Riou

unread,
Jan 23, 2014, 7:53:49 PM1/23/14
to mozzi...@googlegroups.com
I recently started to tinker around with mozzi and I encountered a problem with the state variable filter.
When the cutoff frequency of the filter is high (around 3500) and the resonance value is high (so that the resonance of the filter is
near its lowest value) the sound degenerates into a noisy squeal. Am I doing something wrong ?

I use Hi-Fi mode if it changes anything.

Thank you.

Mr Sensorium

unread,
Jan 26, 2014, 7:05:09 AM1/26/14
to mozzi...@googlegroups.com
Hi Guillaume,

that's a characteristic of the filter, with lots of resonance it can distort.  The simple fix is to attenuate the input to the filter. 
If you're more adventurous you're welcome to redesign the filter to provide more headroom!

I've attached an example sketch where the filter would distort, but the input is shifted right to reduce its amplitude before filtering.

Tim
StateVariableFilter_HIFI.zip

Guillaume Riou

unread,
Jan 26, 2014, 11:11:00 AM1/26/14
to mozzi...@googlegroups.com
Thank you for the quick anwser. I know the filter will normally distort when the resonance is set to values around 1-10.
What I was talking about in my first post is a problem when the resonance is set to a high value (around 200) and the cutoff frequency is also set high (around 3900).
The result are not spikes at certain frequency. Past a certain cutoff value with the resonance set to 200, the signal degenerates to almost unpitched noise.

I have made a spreadsheet with a graphic of the values at which distortion starts to happen.

Guillaume
statevariable_distortion.ods

Mr Sensorium

unread,
Jan 26, 2014, 9:01:34 PM1/26/14
to mozzi...@googlegroups.com
Oh, sorry I misunderstood your question.

I tested the issue again and I see what you mean, with the sound turning into wide-band noise when the centre frequency is high and the filter is broad. 
Thanks for highlighting the issue. I expect it's due to overflows in the fixed-point maths in the filter code. 

I also tested it with the AUDIO_RATE set to 32768 in mozzi_config.h, which gave much better results, so if your sketch is not too cpu-intensive, this might be an option if you require high centre frequency and a broad filter curve.

At this point, it's a limitation of the code, as it is.
If you have time to contribute improved code for the filter, you are very welcome!

Tim

Guillaume Riou

unread,
Jan 26, 2014, 9:43:36 PM1/26/14
to mozzi...@googlegroups.com
Thanks you for your answer. I will try to find a workaround to this problem as I think my project will require all
the cpu can give. I would like to contribute to the library but I dont think I have enough experience with c++, signal processing and
fixed point maths to do much.

Thanks again for this wonderfull library and for the help.

Guillaume
Reply all
Reply to author
Forward
0 new messages