Biquad Software Implementations
In matlab, an efficient biquad section is implemented by calling
outputsignal = filter(B,A,inputsignal);where
A complete C++ class implementing a biquad filter section is included in the free, open-source Synthesis Tool Kit (STK) [15]. (See the BiQuad STK class.)
Figure B.10 lists an example biquad implementation in the C programming language.
typedef double *pp; // pointer to array of length NTICK typedef word double; // signal and coefficient data type typedef struct _biquadVars { pp output; pp input; word s2; word s1; word gain; word a2; word a1; word b2; word b1; } biquadVars; void biquad(biquadVars *a) { int i; dbl A; word s0; for (i=0; i<NTICK; i++) { A = a->gain * a->input[i]; A -= a->a1 * a->s1; A -= a->a2 * a->s2; s0 = A; A += a->b1 * a->s1; a->output[i] = a->b2 * a->s2 + A; a->s2 = a->s1; a->s1 = s0; } } |
Next Section:
The Biquad Allpass Section
Previous Section:
The BiQuad Section