Writing a program to implement an arbitrary combination of poles and zeros, as described in Chapter 14, is now a straightforward endeavor. Equation 14.18 on page 267 shows how to implement all the zeros simultaneously, and Equation 14.21 on page 268 shows how to implement all the poles simultaneously.

Actually calculating the filter coefficients and implementing the filter require several capabilities. First, the filter coefficients are nothing but the coefficients of polynomials with a given set of roots. We therefore need a routine that can multiply polynomials together. We also need two structures: one to define the poles and zeros required and one, to be used by the filtering routine itself, that defines the filter. Finally, of course, we must write the filter routine.

Perhaps it is not obvious, but the filter routine requires some sort of buffer to contain a list of previous inputs and filter outputs. A filter with *m* zeros requires knowledge of the *m* previous inputs. A filter with *n* poles requires knowledge of the *n* previous outputs. Efficient handling of these buffers is important to the execution speed of the filtering routines.

Despite the innocuous appearance of the equations for the poles and zeros, difficulties caused by roundoff errors or even overflow can occur, especially if the poles are particularly sharp (with very small damping terms). In such cases, the order of the poles and zeros can be important, not ...

Start Free Trial

No credit card required