|
![](/i/fill.gif) |
>>> Next fun thing: Transforming from rectangular to polar coordinates. It's
>>> not as simple as you think it is.
>>
>
> What the whole arctangent thing? Oh, yeah... Thankfully most programming
> languages have a function called atan2 ;)
>
> Magnitude is simple to calculate, though. It's just the distance formula
> after all.
Actually, a complex log() will do it for you quite nicely. But that's
not my point; my point is that if you just transform all the poles and
zeros, the filter's response changes. The tricky part is transforming
from the s-domain to the z-domain while still keeping approximately the
same frequency response.
> I only wish I had this enthusiasm for mathematics when I was in school.
> It would have made my algebra, geometry and trig classes much more
> enjoyable.
Join the friggin' club! All we did in math classes at school was long
division. Pages and pages and pages of it. No wonder kids grow up
thinking that that's all there is to mathematics...
(Also, "hey, GET OFF MY LAWN!")
>> * If you place a pole and a zero on top of each other, mathematics says
>> they should cancel each other out. In the real world, this doesn't work
>> at all! (It's called a pole-zero cancellation, and you want to stay the
>> hell away from it.)
>
> Ooh, Hmm... lets see: 0/0 .... would that be a big fat "NaN"?
If you try to run a filter with a pole and a zero on top of each other,
what actually happens is that it's wildly unstable. The mathematics says
the two could cancel out and give you a flat response, but in reality
that's not what happens. (Regardless of what type of arithmetic you use
- whether it has a concept of NaN or not.)
>> * An IIR filter is a feedback loop. Feedback magnifies rounding errors.
>> So after you design your filter, you may find that it doesn't actually
>> have the frequency response it's supposed to have. (Depending on whether
>> you use fixed-point or floating-point arithmetic, and at what precision.)
>
> Right. I was having a bit of fun with this exact fact the other day with
> Falstad's filter applet. I pushed the filter to the point where it would
> rounding error slowly crept in. It was interesting to listen to as it
> started as white noise, but occasional harmonics would sneak in and
> dance around. Eventually the program would give up, claiming
> instability. I'm not sure when the applet decides the filter is
> unstable, My guess is when a result is infinite or NaN that's it. You
> can't adjust gain on that, and it doesn't translate to a finite integer
> very well. I suppose you could clip....
When a filter goes unstable, the output magnitude increases
exponentially. It can't be hard to detect; if the filter operates on
numbers +/-1 and you start getting numbers > 1,000, it's probably gone
wrong. ;-)
>> * The more poles a lowpass filter has, the better its frequency response
>> theoretically becomes. However, more poles increases the passband gain,
>> so you have to turn down the A-coefficients, while the extra poles keep
>> increasing the number and magnitude of the B-coefficients. Gradually you
>> end up with a filter that's less and less sensitive to its input
>> (A-coefficients), and has higher and higher gain in the feedback path
>> (B-coefficients). Can you spell "unstable"?
>
> Yep. With all filter types there's a limit to the number of pole/zero
> pairs you can use before the filter loses stability.
Only IIR filters have poles. Technically, if you take the Laplace or
Z-transform of an FIR filter, you'll find it has lots of zeros (one for
every point in the kernel) and no poles. But that's not a very useful
way to analyse an FIR filter...
> What's also extremely interesting is the fact that the poles/zeros of
> the IIR filter can be used to design that filter as an electronic circuit.
Filter design *began* with using the Laplace transform to design
analogue IIR filters. FIR filters are more or less only feasible with
digital electronics. They're much easier to design, they have far
superior precision, and they require a crapload more compute power.
If you want to make precision alterations to a signal, you want FIR. If
you want to make stuff that sounds cool, you want IIR. ;-)
Post a reply to this message
|
![](/i/fill.gif) |