3 min read
On this page

Digital Filters

Digital filters modify the frequency content of a signal. They are the most important building blocks in DSP.

FIR vs IIR filter comparison flowchart

FIR Filters (Finite Impulse Response)

Output depends only on current and past inputs (no feedback).

y[n] = Σₖ₌₀ᴹ h[k] · x[n-k] = h[0]x[n] + h[1]x[n-1] + ... + h[M]x[n-M]

Properties: Always stable (no poles outside origin). Can have linear phase (symmetric coefficients → constant group delay → no phase distortion). Higher order needed for sharp transitions.

Linear Phase

If h[n] = h[M-n] (symmetric), the filter has linear phase:

H(e^(jω)) = |H(e^(jω))| · e^(-jωM/2)

All frequencies are delayed by the same amount (M/2 samples). Critical for audio, communications, and any application where waveform shape matters.

FIR Design Methods

Window method: Start with ideal (rectangular) frequency response → inverse DFT → truncate to M+1 coefficients → multiply by window function (Hamming, Kaiser, etc.).

Frequency sampling: Specify desired frequency response at N points → inverse DFT → obtain filter coefficients.

Parks-McClellan (Remez exchange): Optimal equiripple design. Minimizes the maximum approximation error (minimax). The standard for high-quality FIR filter design.

Specification: passband edge, stopband edge, passband ripple, stopband attenuation
→ Parks-McClellan algorithm → optimal FIR coefficients

IIR Filters (Infinite Impulse Response)

Output depends on inputs AND past outputs (feedback/recursion).

y[n] = Σₖ₌₀ᴹ bₖx[n-k] - Σₖ₌₁ᴺ aₖy[n-k]

Properties: Can achieve sharp transitions with fewer coefficients than FIR. May be unstable (poles must be inside unit circle). Cannot have exactly linear phase. More efficient for a given frequency selectivity.

Classical IIR Filter Types

Butterworth: Maximally flat magnitude in passband. No ripple. Smooth rolloff. Gentle transition.

Chebyshev Type I: Equiripple in passband. Steeper rolloff than Butterworth for same order. Flat in stopband.

Chebyshev Type II: Flat passband. Equiripple in stopband. Less common.

Elliptic (Cauer): Equiripple in both passband and stopband. Sharpest possible transition for a given order. Most efficient but most phase distortion.

| Filter | Transition Width | Passband | Stopband | Phase | |---|---|---|---|---| | Butterworth | Widest | Flat | Flat | Smoothest | | Chebyshev I | Moderate | Ripple | Flat | Moderate | | Chebyshev II | Moderate | Flat | Ripple | Moderate | | Elliptic | Narrowest | Ripple | Ripple | Worst |

IIR Design Methods

Impulse invariance: Sample the impulse response of an analog prototype. Preserves the impulse response but causes aliasing for non-bandlimited prototypes.

Bilinear transform: Map the s-plane to the z-plane via z = (1 + sT/2)/(1 - sT/2). No aliasing but frequency warping (nonlinear frequency mapping). Apply pre-warping to correct critical frequencies.

Filter Structures

Direct Form I

Implement the difference equation directly. Two delay lines (one for x, one for y). 2(M+N) delays.

Direct Form II

Combine the delay lines. Only max(M,N) delays. More efficient but more sensitive to quantization.

Cascade (Second-Order Sections)

Factor H(z) into biquad sections (second-order IIR filters). Each biquad:

H_k(z) = (b₀ + b₁z⁻¹ + b₂z⁻²) / (1 + a₁z⁻¹ + a₂z⁻²)

Advantages: More robust to coefficient quantization. Easier to tune individual sections. Standard in audio (parametric EQ = cascade of biquads).

Parallel Form

Sum of second-order sections (partial fraction decomposition). Each section implements one pole pair.

Lattice Structure

Based on reflection coefficients. Numerically robust. Natural for speech coding (vocal tract model).

Multirate Filters and Filter Banks

Analysis filter bank: Split a signal into multiple frequency bands (e.g., 32 subbands for MP3).

Synthesis filter bank: Reconstruct the signal from subbands.

Perfect reconstruction: Analysis + synthesis produces the original signal exactly (up to delay). Critical for audio codecs.

Quadrature Mirror Filter (QMF): Two-band filter bank. The analysis and synthesis filters are related by modulation.

Applications in CS

  • Audio: Equalizers (cascade of biquads), crossovers, noise reduction, echo cancellation, audio codecs.
  • Communications: Channel filters, pulse shaping (raised cosine), matched filters.
  • Biomedical: ECG/EEG filtering, noise removal from physiological signals.
  • Control systems: Digital controllers are IIR filters.
  • Image processing: 2D filters for blur, sharpen, edge detection.