Hacker News new | ask | show | jobs
by TheOtherHobbes 2829 days ago
A typical implementation is simple - a couple of single sample delays, a couple of multiplications, some addition.

Deriving the coefficients and the design is not simple. There is math.

https://ccrma.stanford.edu/~jos/filters/Two_Pole.html

A characteristic equation called the Transfer Function defines what a filter (actually any circuit) does using polar complex numbers to represent the frequency and phase of an arbitrary input signal.

Basically the TF says "If you put a sine wave in, the circuit will change its amplitude and phase like this" - across all possible frequencies.

Filters are usually designed with a combination of poles and zeroes.

Poles are low-pass building blocks. Zeroes are high-pass building blocks.

Poles are a polynomial on the denominator of the Transfer Function, zeroes a polynomial on the numerator.

When you have your continuous Transfer Function you apply something called a z-transform, which gives you a form you can turn into a difference equation, which is basically the core equation for the filter, and another set of equations for calculating the coefficients.

Instead of deriving this from scratch you use standard forms which you can find on sites like the JOS tutorial I linked to, and dspguru.com.

But you do need to have some idea how all of this works - and also when this nice simple model stops working. (E.g. digital filters have issues close to the sampling rate, so good designs compensate for this and don't just use the difference equation blindly.)

1 comments

Thanks a lot. It seems this remains quite a challenge to turn those into working code though !