Skip to content
Digital Signal Processing

FIR filter design with the window method

Impulse response of the ideal low-pass filter with proof, the Gibbs phenomenon, Hann, Hamming and Blackman windows, the Kaiser window with its design formulas, linear phase proved.

The most direct way to design an FIR filter is to start from the ideal filter, compute its impulse response and shorten it. This is the window method: simple, robust and still widely used. In this lesson we derive the impulse response of the ideal low-pass filter, see why truncation creates Gibbs oscillations, compare the classic windows and the Kaiser window with its design formulas, and prove that an FIR filter with symmetric coefficients has linear phase.

The ideal low-pass filter

The ideal low-pass filter has gain 1 for |\omega| \lt  \omega_c and 0 elsewhere, in the period [-\pi, \pi].

Theorem. Its impulse response is

    \[ h_d[n] = \frac{\sin(\omega_c n)}{\pi n},\qquad h_d[0] = \frac{\omega_c}{\pi} \]

Proof. With the inverse DTFT formula:

    \[ h_d[n] = \frac{1}{2\pi}\int_{-\omega_c}^{\omega_c}e^{j\omega n}\,d\omega = \frac{1}{2\pi}\cdot\frac{e^{j\omega_c n} - e^{-j\omega_c n}}{jn} = \frac{\sin(\omega_c n)}{\pi n} \]

and for n = 0 the integral is simply 2\omega_c/(2\pi). ∎

This response is infinite in both directions and non-causal: no real filter can implement it. So only N = 2L + 1 central samples are kept and everything is delayed by L, making the filter causal: h[n] = h_d[n - L]\,w[n], where w[n] is the window, zero outside 0 \le n \le N - 1.

The Gibbs phenomenon

Multiplying by the window in time means convolving the ideal response with the window’s transform in frequency. For the rectangular window this transform is the kernel of the previous lesson, with a main lobe 4\pi/N wide and high side lobes. The convolution has two effects:

  • a transition band roughly as wide as the main lobe, which narrows as N increases;
  • ripples in the passband and stopband, due to the side lobes. The highest is about 9 % of the jump, and it does not decrease as N grows: the ripples become denser but not smaller. This is the Gibbs phenomenon, the same as for truncated Fourier series.

For a filter with the rectangular window the maximum stopband attenuation therefore stays around 21 dB, whatever the length: too little for almost every application.

Windows

The solution is to use windows that taper smoothly to zero at the edges: the side lobes of their transform are much lower, at the price of a wider main lobe, i.e. a slower transition for the same N.

WindowMain lobe widthHighest side lobeFilter attenuation
rectangular4\pi/N−13 dB21 dB
Hann8\pi/N−31 dB44 dB
Hamming8\pi/N−41 dB53 dB
Blackman12\pi/N−57 dB74 dB

The Hamming window, for example, is w[n] = 0.54 - 0.46\cos(2\pi n/(N-1)).

Response in decibels of a 41-tap low-pass filter with the rectangular window and with the Hamming window
With the rectangular window (red) the transition is steeper but the stopband stays around minus 21 decibels; with the Hamming window (blue) the transition is wider but the attenuation exceeds 50 decibels.

The Kaiser window

Fixed windows force a choice from a table. The Kaiser window has a parameter \beta that continuously adjusts the trade-off between main-lobe width and side-lobe height, and empirical design formulas. Given the required attenuation A = -20\log_{10}\delta in decibels (with \delta the tolerance, the same in passband and stopband) and the transition width \Delta\omega = \omega_s - \omega_p:

    \[ \beta = \begin{cases} 0.1102\,(A - 8.7) & A \gt  50 \\ 0.5842\,(A - 21)^{0.4} + 0.07886\,(A - 21) & 21 \le A \le 50 \end{cases},\qquad N \approx \frac{A - 8}{2.285\,\Delta\omega} + 1 \]

Example. Passband up to 0.3\pi, stopband from 0.42\pi with 50 dB. Then \Delta\omega = 0.12\pi \approx 0.377 and N \approx 42/0.861 + 1 \approx 50 taps. With the Hamming window, which guarantees the 50 dB, one would need 8\pi/N \approx 0.12\pi, i.e. about 67 taps: the Kaiser window saves a quarter. The cutoff is placed in the middle of the transition, \omega_c = 0.36\pi.

Linear phase

Theorem. If the coefficients of a length-N FIR filter are symmetric, h[n] = h[N - 1 - n], then

    \[ H(e^{j\omega}) = e^{-j\omega(N-1)/2}A(\omega) \]

with A(\omega) real: the phase is linear and the group delay is (N-1)/2 samples.

Proof. Let M = (N-1)/2 be the centre. Factor out e^{-j\omega M}: H = e^{-j\omega M}\sum_n h[n]e^{-j\omega(n - M)}. In the sum, the terms n and N - 1 - n have the same coefficient and opposite exponents, \mp j\omega(n - M), so together they give 2h[n]\cos(\omega(n - M)), which is real. If N is odd the central term h[M] remains, also real. So the sum is a real number A(\omega). ∎

A(\omega) can change sign, and then the phase jumps by \pi: it is still piecewise linear, and the group delay is constant. A filter designed with windows is symmetric by construction (the centred ideal response and the windows are even), so it always has linear phase. This is the main advantage of FIR filters over IIR ones, together with guaranteed stability: an FIR filter has no poles away from the origin.

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x