Sign in

username:

password:



Not a member?

Search Online Books



Search tips

Free Online Books

Chapters

Chapter Contents:

Search Introduction to Digital Filters

  

Book Index | Global Index


Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?

  

Biquad Software Implementations

In matlab, an efficient biquad section is implemented by calling

        outputsignal = filter(B,A,inputsignal);
where

\begin{eqnarray*}
\texttt{B} &=& [g, g\beta_1, g\beta_2],\\
\texttt{A} &=& [1, a_1, a_2].
\end{eqnarray*}

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.

Figure B.10: C code implementing a biquad filter section.

 
  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;
      }
  }


Order a Hardcopy of Introduction to Digital Filters

Previous: The BiQuad Section
Next: Allpass Filter Sections

written by Julius Orion Smith III
Julius Smith's background is in electrical engineering (BS Rice 1975, PhD Stanford 1983). He is presently Professor of Music and Associate Professor (by courtesy) of Electrical Engineering at Stanford's Center for Computer Research in Music and Acoustics (CCRMA), teaching courses and pursuing research related to signal processing applied to music and audio systems. See http://ccrma.stanford.edu/~jos/ for details.


Comments


No comments yet for this page


Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )