Csound Csound-dev Csound-tekno Search About

[Csnd] IIR filter problems

Date2008-12-07 22:41
From"Nik Francis"
Subject[Csnd] IIR filter problems
AttachmentsIIR_test.csd  
Is anyone familiar with IIR filter implementation in Csound?  I've attached code for what I think is a recursive difference equation (following instrument 2010 from the Csound Book).  I've used coefficients which should put a  pole pair at approx. +/-2khz, within the unit circle (|z| = 1/2).  So the filter should be stable, but when I run the code, it blows up.

Any clue on what is wrong?  I'm running the floats version of csound, but in any case,  the poles are far enough from the unit circle that coefficient errors shouldn't really matter, I think...

-Nik


Date2008-12-08 10:43
FromVictor Lazzarini
Subject[Csnd] Re: IIR filter problems
You definitely need kr=sr (ksmps=1) for feedback to work. I also think this
filter equation

ia = 2
aoutput = ainput-((2/ia)*cos(iw))*aprev1+((1/ia)^2)*aprev2

is unstable. If you are trying to do a 2nd-order allpole resonator,
then your coefficients signs are wrong. It should be

y[n] =  x[n] +2Rcos(w)y[n-1] - (R^2)y[n-2]

also note that with sharp resonances (R close to 1), the filter might
be very loud. With R=0.5 you won't get much of an effect. In addition
your input signal does not have much amplitude (1).


Victor


At 22:41 07/12/2008, you wrote:
>Is anyone familiar with IIR filter implementation in Csound?  I've 
>attached code for what I think is a recursive difference equation 
>(following instrument 2010 from the Csound Book).  I've used 
>coefficients which should put a  pole pair at approx. +/-2khz, 
>within the unit circle (|z| = 1/2).  So the filter should be stable, 
>but when I run the code, it blows up. Any clue on what is 
>wrong?  I'm running the floats version of csound, but in any 
>case,  the poles are far enough from the unit circle that 
>coefficient errors shouldn't really matter, I think... -Nik Send 
>bugs reports to this list. To unsubscribe, send email 
>sympa@lists.bath.ac.uk with body "unsubscribe csound"

Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth