Free Books

DC Blocker Software Implementations

In plain C, the difference equation for the dc blocker could be written as follows:

  y = x - xm1 + 0.995 * ym1;
  xm1 = x;
  ym1 = y;
Here, x denotes the current input sample, and y denotes the current output sample. The variables xm1 and ym1 hold once-delayed input and output samples, respectively (and are typically initialized to zero). In this implementation, the pole is fixed at $ R=0.995$, which corresponds to an adaptation time-constant of approximately $ 1/(1-R) = 200$ samples. A smaller $ R$ value allows faster tracking of ``wandering dc levels'', but at the cost of greater low-frequency attenuation.

A complete C++ class implementing a dc blocking filter is included in the free, open-source Synthesis Tool Kit (STK) [15]. (See the DCBlock STK class.)

For a discussion of issues and solutions related to fixed-point implementations, see [7].


Perform the bilinear transform defined above and calculate the coefficients of a first-order digital low shelving filter. Find the pole and zero as a function of $ B_0$, $ \omega_1$, and $ T$. Set $ z = 1$ and verify that you get a gain of $ 1+B_0$. Set $ z = -1$ and verify that you get a gain of 1 there.

Next Section:
Normalizing Two-Pole Filter Gain at Resonance
Previous Section:
DC Blocker Frequency Response