Problems with unstable filter (based on VA Filter Design pdf)
-
- KVRist
- Topic Starter
- 142 posts since 14 Dec, 2003
Hi guys. I'm having a problem I cannot seem to figure out.
I've been working on a new filter design based on information from Vadim's book, but it seems to go unstable and I can't really work out why.
I've cut down my design to the basics and put some code in a Gist:
https://gist.github.com/ValdemarOrn/859 ... fcbca0a541
It's a 4 pole cascade (ladder) filter, using Vadim's design for a zero-delay one pole filter. no non-linearities, and I've cut the code back to just the one pole block and the code that processes one sample tick.
You can see I limit the feedback to 3.9x, but when I raise the cutoff to about 550hz (using a 96Khz samplerate, g is ~0.02), and set the feedback to max, the signal slowly increases until it starts clipping. Setting the cutoff higher just drives the filter unstable quicker, and I have to reduce the feedback to compensate.
Is there an obvious failure in my code that you can spot? Do I need to somehow frequency compensate the feedback parameter? (I thought the gain at the cutoff was always sqrt(2)/2, resulting in an overall gain of (sqrt(2)/2)^4 = 1/4 at the point)
Any help would be appreciated.
Thanks!
I've been working on a new filter design based on information from Vadim's book, but it seems to go unstable and I can't really work out why.
I've cut down my design to the basics and put some code in a Gist:
https://gist.github.com/ValdemarOrn/859 ... fcbca0a541
It's a 4 pole cascade (ladder) filter, using Vadim's design for a zero-delay one pole filter. no non-linearities, and I've cut the code back to just the one pole block and the code that processes one sample tick.
You can see I limit the feedback to 3.9x, but when I raise the cutoff to about 550hz (using a 96Khz samplerate, g is ~0.02), and set the feedback to max, the signal slowly increases until it starts clipping. Setting the cutoff higher just drives the filter unstable quicker, and I have to reduce the feedback to compensate.
Is there an obvious failure in my code that you can spot? Do I need to somehow frequency compensate the feedback parameter? (I thought the gain at the cutoff was always sqrt(2)/2, resulting in an overall gain of (sqrt(2)/2)^4 = 1/4 at the point)
Any help would be appreciated.
Thanks!
-
- KVRian
- 1153 posts since 11 Aug, 2004 from Breuillet, France
The feedback isn't supposed to be higher than 4 if you want stability indeed... But that's when you have a (wait for it, wait for it) zero delay feedback filter !
Since you add a delay in the feedback in your implementation, the frequency response is changed, and the limit before instability is not the same anymore.
If you want your filter to behave correctly, you should read also the part about the ladder filter later in the book
Since you add a delay in the feedback in your implementation, the frequency response is changed, and the limit before instability is not the same anymore.
If you want your filter to behave correctly, you should read also the part about the ladder filter later in the book
- KVRAF
- 2554 posts since 4 Sep, 2006 from 127.0.0.1
Code: Select all
(x - z1_state) * g / (1 + g)
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!
irc.libera.chat >>> #kvr
..as long as it has BASS and it's LOUD!
irc.libera.chat >>> #kvr
- u-he
- 28044 posts since 8 Aug, 2002 from Berlin
That's the same, in C/C++ that is.antto wrote:i might be totally wrong, but maybe that's supposed to be ((x - z1_state) * g) / (1 + g)Code: Select all
(x - z1_state) * g / (1 + g)
-
- KVRist
- Topic Starter
- 142 posts since 14 Dec, 2003
Wolfen666 wrote:The feedback isn't supposed to be higher than 4 if you want stability indeed... But that's when you have a (wait for it, wait for it) zero delay feedback filter !
Since you add a delay in the feedback in your implementation, the frequency response is changed, and the limit before instability is not the same anymore.
Bah, yes, penny just dropped! sometimes you just need someone else to state the obvious. That was not a delay-less filter, because even if the individual low pass elements are zero-delay, the feedback introduces delay.
Well, I've updated my code, it now sounds pretty kick ass. (still needs lots of work, I indent to add gain compensation and some simple nonlinearities, I'll probably go with the "quick n dirty" approach Vadim describes in his book)
https://gist.github.com/ValdemarOrn/859 ... fcbca0a541
The thing I was missing was Eq. 4.3, page 63. The code in my Gist is obviously simplified and not optimized at all, but I hope the next person to read this might benefit from my mistakes.
Thanks for the response, Wolfen, much appreciated.
PS: For those interested, I'm working on a new synth, where this filter will eventually end up. The code is a mess right now, and the thing is far from feature complete, but for those who are curious, have a dig around: https://github.com/ValdemarOrn/Polyhedrus
All open source, will be MIT license when ready. I really wish more people would open source their plugins, it's a shame how prevalent closed source is in the audio industry