
There are 7 messages in this thread.
You are currently looking at messages 0 to 7.
Good evening everyone, unfortunaatly I didn't find any answer in google. Designing a digital audio synthesizer, how do I handle the fast change of filter coefficients? For now I implemented say 4 coefficients sets for a lowpass filter, with (say) cutoff freqs of 5000, 3000, 1000, 500 hz. I can't generate and keep in memory 128 (MIDI.... ) different coefficient sets, but even if my sets are all 8 tap, I can see no linearity in their values. Should I just interpolate between the values for each tap? Thanks in advance, Alex______________________________
On Dec 1, 12:51=A0pm, "mot56k" <alessandro.sacc...@gmail.com> wrote:
> Good evening everyone,
> unfortunaatly I didn't find any answer in google. Designing a digital
> audio synthesizer, how do I handle the fast change of filter coefficients=
?
> For now I implemented say 4 coefficients sets for a lowpass filter, with
> (say) cutoff freqs of 5000, 3000, 1000, 500 hz.
> I can't generate and keep in memory 128 (MIDI.... ) different coefficient
> sets, but even if my sets are all 8 tap, I can see no linearity in their
> values. Should I just interpolate between the values for each tap?
i'm trying to understand if you're referring to FIR or IIR filters.
IIR filters have feedback and are more touchy. really nasty
transitions of coefs can make IIR filters go temporarily unstable
until the transition settles down (to a stable set). it could cause a
nasty hiccup in the audio output. also, when coefficient slewing
becomes a real issue, it makes a difference which form of IIR filter
you use. you might want to consider less efficient (but better
behaved) architectures like the Chamberlin "State-Variable filter" or
the Lattice or normalized Ladder structures. the Direct Form 1 is
more efficient, but might not be what you want here.
are you slewing your coefs every sample? how are you slewing them?
linearly? or like a first-order LPF? especially if you're doing
fixed point processing ("mot56k"?), you might have to worry about your
coefs getting stuck on a slightly wrong value unless you do noise-
shaping (or error feedback).
for FIR, i don't think it makes much difference as long as your
summation doesn't get saturated.
r b-j
______________________________
>are you slewing your coefs every sample? how are you slewing them?
>linearly? or like a first-order LPF? especially if you're doing
>fixed point processing ("mot56k"?), you might have to worry about your
>coefs getting stuck on a slightly wrong value unless you do noise-
>shaping (or error feedback).
>
thanks Robert,
I am working on a floating point SHARC platform. I am using IIR filters,
in the standard way. If you can speculate further on this, please post a
follow-up. I will take a look for sure at the Chamberlin and lattice
filters, I am just moving my first steps in these things.
The problem is that I can just find examples (for example the ones that
ship with the EZ-KIT) of trivial filters with a precise and hard coded set
of parameters.
There should be a standard way used in floating point audio applications
(EQs, synths, etc) to update in real-time the behaviour of a filter..
thanks
alex
______________________________On Dec 1, 5:12=A0pm, "mot56k" <alessandro.sacc...@gmail.com> wrote:
> >are you slewing your coefs every sample? =A0how are you slewing them?
> >linearly? =A0or like a first-order LPF? =A0especially if you're doing
> >fixed point processing ("mot56k"?), you might have to worry about your
> >coefs getting stuck on a slightly wrong value unless you do noise-
> >shaping (or error feedback).
>
> thanks Robert,
> I am working on a floating point SHARC platform. I am using IIR filters,
> in the standard way.
i presume either the Direct Form 1 (DF1) or the DF2. i would
recommend the 1 over the 2 even though you don't have the danger of
clipping that you would have with a fixed-point DF2, i think there
might be a slight numerical issue in a very resonant filter (with
poles very close to the unit circle and zeros very close to those
poles) even in floating-point with the DF2 that is less of a problem
with the DF1. well, maybe not. however, the state-variable or the
lattice filters might be a little better.
> If you can speculate further on this, please post a
> follow-up. I will take a look for sure at the Chamberlin and lattice
> filters, I am just moving my first steps in these things.
> The problem is that I can just find examples (for example the ones that
> ship with the EZ-KIT) of trivial filters with a precise and hard coded se=
t
> of parameters.
google "Audio EQ Cookbook" for quick and dirty formulae for getting
the coefficients.
> There should be a standard way used in floating point audio applications
> (EQs, synths, etc) to update in real-time the behaviour of a filter..
this is called coefficient slewing. the coefficients are sliding from
one value to another because the more salient *parameters* of the
filter (such as the resonant frequency or the degree of resonance) are
varying.
so the first issue you need to settle is how fast are these ostensibly
more salient (to the user) parameters are changing. from that, you
need to decide how often (expressed first in ms or seconds, later
convert to samples) you need to calculate your coefficients from the
parameters. if computational cost is of no matter, you can do it
every sample. but that would cost a lot of machine instructions
reducing the number of instantiations or simultaneous channels of
audio you can process (or some other audio effect you might wanna do -
nothing is free).
so then you've figgered out how often (in samples), you need to
recalculate and update your coefs. call that period of time a
"frame". you have your current instantaneous values of your operating
coefficients and you are sliding to "target" coefs (the ones you just
recalculated). then your operating coefs will slide from the values
they had at the previous frame to the target coefs by the end of the
new frame. there are essentially two common ways to do it: 1. linear
slewing or 2. LPF filtered slewing (usually a simple one-pole LPF).
they are both about equally expensive and both need a state and some
kind of rate for the slewing.
for linear slewing (1), you calculate the difference between the
target value and the current value and divide that by the number of
samples of a frame and that is the little delta increment. you only
need to compute that delta once per frame.
for LPF filtered slewing (2), you compute that difference (between the
target and current coef value), multiply by some positive slew rate
coef (a coef of a coef!) which is between 0 and 1, and add that to the
current value of the filter coef. but, especially for fixed-point,
there could be a danger of the coef getting close to the final target
value and getting stuck before it can actually get there (called
"limit cycling"). it shouldn't really be a problem for a SHArC (32 or
40-bit floats) and if the target coef keeps varying because the filter
parameters continue to be modulated, it shouldn't really be a
problem. for the 56K you have to worry about it and do "error
shaping" a.k.a. "fraction saving" so that the coef doesn't limit
cycle.
> thanks
yer welcome.
r b-j
______________________________mot56k schrieb: > Good evening everyone, > unfortunaatly I didn't find any answer in google. Designing a digital > audio synthesizer, how do I handle the fast change of filter coefficients? > For now I implemented say 4 coefficients sets for a lowpass filter, with > (say) cutoff freqs of 5000, 3000, 1000, 500 hz. > I can't generate and keep in memory 128 (MIDI.... ) different coefficient > sets, but even if my sets are all 8 tap, I can see no linearity in their > values. Should I just interpolate between the values for each tap? > Thanks in advance, > Alex Hi Alex, I hope this can help you: Considering IIR biquad filters we have the z-Domain transfer function H(z) = (L0*z^2 + L1*z + L2) / (z^2 + K1*z + K2) The coresponding filter function/algorithem in the descret time domain is: y(n) = L0*x(n) + L1*x(n-1) + L2*x(n-2) - K1*y(n-1) - K2*y(n-2) where x is the input and y the output signal. "n" means the current sample, "n-1" is the sample one time slot back in time, "n-2" is two time slot back. This formula is normaly known as direct form 1 oder DF1. You have to program this once to implement a filter. To change a filters transfer function only the koefficients L0, L1, L2, K1, K2 has to be recalculated For a simple 2nd order lowpass this is: K = tan(wg/(2*Fa)) wg = 2*Pi*fg fg is cut frequency Fa is sample freq. L0 = K^2 / (1 + sqrt(2)*K + K^2) L1 = 2*K^2 / (1 + sqrt(2)*K + K^2) L2 = K^2 / (1 + sqrt(2)*K + K^2) L1 = 2*(K^2 - 1) / (1 + sqrt(2)*K + K^2) L2 = (1 - sqrt(2)*K + K^2)/(1 + sqrt(2)*K + K^2) For a simple 2nd order highpass this is: L0 = 1 / (1 + sqrt(2)*K + K^2) L1 = -2 / (1 + sqrt(2)*K + K^2) L2 = 1 / (1 + sqrt(2)*K + K^2) L1 = 2*(K^2 - 1) / (1 + sqrt(2)*K + K^2) L2 = (1 - sqrt(2)*K + K^2)/(1 + sqrt(2)*K + K^2) If you're looking for a nice book to get familiar with this stuff my suggestion is "Digital Audio Signal Processing", Udo Zölzer there is also a german version available if you prefer. That's it. Good luck Sven______________________________
mot56k wrote: > Designing a digital audio synthesizer, how do I handle the fast > change of filter coefficients? Look at this paper and references therein for a start: Victor Kalinichenko, Smooth and Safe Parameter Interpolation of Biquadratic Filters in Audio Applications http://www.dafx.ca/proceedings/papers/p_057.pdf Martin -- Quidquid latine scriptum est, altum videtur.______________________________
Thanks everybody. I eventually made it in C++.. Merry Christmas >mot56k wrote: > >> Designing a digital audio synthesizer, how do I handle the fast >> change of filter coefficients? > >Look at this paper and references therein for a start: >Victor Kalinichenko, Smooth and Safe Parameter Interpolation of >Biquadratic Filters in Audio Applications >http://www.dafx.ca/proceedings/papers/p_057.pdf > > >Martin > >-- >Quidquid latine scriptum est, altum videtur. >______________________________