Digital filters are delay-based processing units. In short: they affect a signal by overlapping it with delayed versions of the input - and output. The main application of filters in DSP is the shaping of the spectrum of signals. This can affect the magnitude spectrum by boosting or suppressing certain frequencies, or the phase spectrum by delaying specific frequencies. Equalizers, reverbs, oscillators and more can be realized with digital filters.
There are two basic categories of digital filters in signal processing:
- FIR Filters
- IIR Filters
For both FIR and IIR, the filter order is the maximum delay in samples that is caused by the filter.
FIR Filters¶
Finite Impulse Response (FIR) filters can be considered simple convolution processors. They are implemented without recursion, respectively feedback. And they have a finite impulse response.
FIR filters are allways stable and easy to design, yet they are more CPU expensive and can cause more delay. FIR filters can have linear phase. This property is desirable in many DSP applications.
Impulse Response¶
The impulse response (IR) of an FIR filter is just the filter coefficients. The following plot shows the impulse response for a 10th order FIR lowpass filter. All samples after sample 10 are 0 in this $h[n]$:
Frequency Response¶
The frequency response of the FIR filter is the Fourier transform of its impulse response $h[n]$:
$$ H(f) = \mathcal{F}\{ h[n] \} $$
The plots below show the magnitude response $|H(f)|$ and the phase response $\varphi(f)$ for the FIR low-pass. It has a cutoff frequency of $f_c = fs/4 = 4000 \mathrm{Hz}$ and a linear phase response.
IIR Filters¶
Infinite Impulse Response (IIR) filters are recursive computational structures. They have an infinite impulse response, that either converges to zero or - if unstable - to infinity. IIR filters are used for many time-critical operations, since they are less CPU hungry and create less delay.
In contrast to FIR filters, IIR filters can be unstable and alter the phase of signals in sometimes undesirable ways. Stable IIR filters cannot have a linear phase.
Impulse Response¶
The following plot shows the impulse for a 3rd order Butterworth lowpass filter. The recursion results in a convergence towards 0. The impulse response has more samples than the filter has coefficients.
Frequency Response¶
As for the FIR filter, the frequency response of the IIR filter is the DFT of the impulse response $h[n]$:
$$ H(f) = \mathcal{F}\{ h[n] \} $$
The plots below show the magnitude response $|H(f)|$ and the phase response $\varphi(f)$ for the IIR low-pass. The Butterworth-design has a steeper slope than the FIR filter with distinct ripples in the pass-band and a non-linear phase.