DSPRelated.com
Forums

Avoid huge peaks when changing biquad filter coefficients on the fly

Started by jungledmnc May 13, 2012
Hi,

I'm using biquad audio filters (various ones, resonant and non-resonant,
higher order... just anything) in a somehow modulated filter and I simply
change the filter coefficients after every sample. In 99% it works very
well, but sometimes when the changes are too quick (like jumping from 50Hz
to 5kHz with sr 44100, especially for resonant filters) the filter gets
temporarily unstable and generates a short burst of signal sometimes
reaching like +300dB (a lot....). It cannot obviously be avoided by
clearing the filter state (previous inputs and outputs). Any idea how to
fix this?

Thanks in advance, 
jungledmnc
jungledmnc <jungledmnc@n_o_s_p_a_m.gmail.com> wrote:

>I'm using biquad audio filters (various ones, resonant and non-resonant, >higher order... just anything) in a somehow modulated filter and I simply >change the filter coefficients after every sample. In 99% it works very >well, but sometimes when the changes are too quick (like jumping from 50Hz >to 5kHz with sr 44100, especially for resonant filters) the filter gets >temporarily unstable and generates a short burst of signal sometimes >reaching like +300dB (a lot....). It cannot obviously be avoided by >clearing the filter state (previous inputs and outputs). Any idea how to >fix this?
You could try using a lattice structure. Steve
>jungledmnc <jungledmnc@n_o_s_p_a_m.gmail.com> wrote: > >>I'm using biquad audio filters (various ones, resonant and non-resonant, >>higher order... just anything) in a somehow modulated filter and I
simply
>>change the filter coefficients after every sample. In 99% it works very >>well, but sometimes when the changes are too quick (like jumping from
50Hz
>>to 5kHz with sr 44100, especially for resonant filters) the filter gets >>temporarily unstable and generates a short burst of signal sometimes >>reaching like +300dB (a lot....). It cannot obviously be avoided by >>clearing the filter state (previous inputs and outputs). Any idea how to >>fix this? > >You could try using a lattice structure. > > >Steve >
Thanks, seems that this is something I completely omitted in my life so far :). Can you recommend me some ebook/paper or something? (I was googling a lot, but nothing useful so far...)
"jungledmnc" <jungledmnc@n_o_s_p_a_m.gmail.com> writes:

> Hi, > > I'm using biquad audio filters (various ones, resonant and non-resonant, > higher order... just anything) in a somehow modulated filter and I simply > change the filter coefficients after every sample. In 99% it works very > well, but sometimes when the changes are too quick (like jumping from 50Hz > to 5kHz with sr 44100, especially for resonant filters) the filter gets > temporarily unstable and generates a short burst of signal sometimes > reaching like +300dB (a lot....). It cannot obviously be avoided by > clearing the filter state (previous inputs and outputs). Any idea how to > fix this?
I think I remember seeing a technique in which the coefficients themselves are filtered, so that there are no abrupt changes. You might try search the JAES for an article on this. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
>Hi, > >I'm using biquad audio filters (various ones, resonant and non-resonant, >higher order... just anything) in a somehow modulated filter and I simply >change the filter coefficients after every sample. In 99% it works very >well, but sometimes when the changes are too quick (like jumping from
50Hz
>to 5kHz with sr 44100, especially for resonant filters) the filter gets >temporarily unstable and generates a short burst of signal sometimes >reaching like +300dB (a lot....). It cannot obviously be avoided by >clearing the filter state (previous inputs and outputs). Any idea how to >fix this? > >Thanks in advance, >jungledmnc >
Do you update 'all' coefficients for a given filter at the same time, or they get updated one after the other, maybe through some SPI port or something like that. You might essentially be going through an unstable filter while doing your update.
On Sun, 13 May 2012 16:55:57 -0400, Randy Yates wrote:

> "jungledmnc" <jungledmnc@n_o_s_p_a_m.gmail.com> writes: > >> Hi, >> >> I'm using biquad audio filters (various ones, resonant and >> non-resonant, higher order... just anything) in a somehow modulated >> filter and I simply change the filter coefficients after every sample. >> In 99% it works very well, but sometimes when the changes are too quick >> (like jumping from 50Hz to 5kHz with sr 44100, especially for resonant >> filters) the filter gets temporarily unstable and generates a short >> burst of signal sometimes reaching like +300dB (a lot....). It cannot >> obviously be avoided by clearing the filter state (previous inputs and >> outputs). Any idea how to fix this? > > I think I remember seeing a technique in which the coefficients > themselves are filtered, so that there are no abrupt changes. You might > try search the JAES for an article on this.
That will help as long as the coefficients change significantly slower than the time constants of the filter -- otherwise, squeezing things in a ramp or whatever will be the same as squeezing in one step. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
On Sun, 13 May 2012 21:32:51 -0500, gretzteam wrote:

>>Hi, >> >>I'm using biquad audio filters (various ones, resonant and non-resonant, >>higher order... just anything) in a somehow modulated filter and I >>simply change the filter coefficients after every sample. In 99% it >>works very well, but sometimes when the changes are too quick (like >>jumping from > 50Hz >>to 5kHz with sr 44100, especially for resonant filters) the filter gets >>temporarily unstable and generates a short burst of signal sometimes >>reaching like +300dB (a lot....). It cannot obviously be avoided by >>clearing the filter state (previous inputs and outputs). Any idea how to >>fix this? >> >>Thanks in advance, >>jungledmnc >> >> > Do you update 'all' coefficients for a given filter at the same time, or > they get updated one after the other, maybe through some SPI port or > something like that. You might essentially be going through an unstable > filter while doing your update.
If he's using a filter architecture where the two state variables are the current output and the previous one, or are (essentially) the current output and the current output slope, then going from high-frequency filter to a low frequency one at just the wrong part of the sine wave would cause a huge transient. Using states that represent output and something like "quadrature of the output at the filter's natural frequency" would save you from the amplitude wingwazzles -- is this what Steve Pope was suggesting with his lattice filters? -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
Yes, exactly. Let's say i'm just using 12db/oct low-pass, but the frequency
and Q is just jumping from one place to another every sample. Do you think
lattice filters would solve it? Where can I find some reasonable info about
conversion from direct/transposed forms?
On Sun, 13 May 2012 12:36:01 -0500, "jungledmnc"
<jungledmnc@n_o_s_p_a_m.gmail.com> wrote:

>I'm using biquad audio filters ... and I simply >change the filter coefficients after every sample. ... Any idea how to >fix this?
I've encountered two ways that work well: 1. Run two filters in parallel, one with the old coefficient set and the other with the new. Slowly crossfade the outputs to transition from the old to the new. 2. Instead of changing the coefficients directly, solve for the poles and zeroes, move them incrementally, and then recompute the coefficients according to the new pole and zero locations at every step along their paths. Not only does this provide a smooth transition, it allows you to explicitly avoid unstable pole locations during the transition. Greg
On Mon, 14 May 2012 07:10:16 -0500, jungledmnc wrote:

> Yes, exactly. Let's say i'm just using 12db/oct low-pass, but the > frequency and Q is just jumping from one place to another every sample. > Do you think lattice filters would solve it? Where can I find some > reasonable info about conversion from direct/transposed forms?
I'm not up on all the different filter topologies' names when they're used for signal processing -- that tends to be an audio DSP thing, and I tend to do more control and communications work. So I can't answer your question -- I keep waiting for Steve Pope to get back on and educate us all!! Try Googling with some combinations of keywords that include "IIR", "lattice" and maybe "form". I don't think you want to ask for a conversion from your direct-form filter to lattice: I think you just want to go back a step to the point where you're "asking" for a cutoff at a certain frequency and designing forward from there. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com