DC Block
Overview
DC Blocking Filter
Filters out DC levels.
Description
This multi-channel module is implemented as a first order IIR filter. Since the filter is operating at very low frequencies, an FIR filter would be prohibitively long. The maximum normalized cut on frequency is ⅓ or (sample rate)/6. The lower the cut on frequency is the longer it will take the filter to stabilize from transients. A good practice is to keep the cut on frequency as high as possible. For example, if the operating frequency range of your system is 20 Hz to 20,000 Hz, there is no need to set the cut on frequency to 0.01 Hz. The filter will respond better to transients if your cut on frequency were set to 1 Hz.
The frequency roll off is 20 dB per decade. The phase response roll-off is 20 dB per decade beyond the cut on frequency.
A typical use for this module would be to filter microphone outputs which are notorious for having a DC bias.
Variables
fc - Cut on frequency of the high pass filter. fc should not be greater than Niquist/3.
Examples
Basic Example
The signal flow below shows a simple usage example. A 20 Hz tone is generated with an offset of 1. The display shows the unfiltered signal(blue) and the DC Blocked signal(black).
DC Block vs Butterworth
If you are wondering, why not use a butterworth filter instead of a DC Block module? Here is your answer. The signal flow below is almost the same setup as in the example above. The difference is that we have added a butterworth filter in parallel with the DC Block filter. Both filters have the same cut-on frequency. The graph shows a very compelling reason why a butterworth filter will not work here. The DC block output is shown in black and the butterworth output is shown in blue. A butter worth filter does a good job of implementing a crossover filter but falls apart at very low frequencies.
Inspector
The inspector for this module can be viewed by double clicking the module in Designer. The cut on frequency fc can be changed in real time. But there is no smoothing. You may hear pops and cracks as you change it.
Module Pack
Standard
ClassID
classID = 233
Type Definition
typedef struct _ModuleDcBlock
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
FLOAT32 fc; // Cut on freq for highpass filter
FLOAT32 coeff; // coefficents for dc blocking filter.
FLOAT32* filterStates; // State variable, 1 per channel
} ModuleDcBlockClass;
Variables
Properties
| Name | Type | Usage | isHidden | Default Value | Range | Units |
|---|---|---|---|---|---|---|
| fc | float | parameter | 0 | 0.1 | 0:20 | Hz |
| coeff | float | derived | 1 | -1 | Unrestricted | |
| filterStates | float* | state | 1 | [1 x 1] | Unrestricted |
Pins
Input Pins
| Name | in |
| Description | Input signal |
| Data type | float |
| Channel range | Unrestricted |
| Block size range | Unrestricted |
| Sample rate range | Unrestricted |
| Complex support | Real and Complex |
Output Pins
| Name | out |
| Description | Filterd Output signal |
| Data Type | float |
Matlab Usage
File Name: dc_block_module.m
M = dc_block_module(NAME)
Implements a 1st order DC blocking filter.
Arguments:
NAME - name of the module
Copyright (c) 2026 DSP Concepts, Inc.