### 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 , which corresponds to an adaptation time-constant of approximately samples. A smaller 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].

#### Exercise

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 , , and . Set and verify that you get a gain of . Set 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