Digital Filters
Digital Filters
DIGITAL FILTERS
4.1 Introduction
4.2 Linear Time-Invariant Filters
4.3 Recursive and non-Recursive Filters
7.4 Filtering, Convolution and Correlation Operations
7.5 Filter Structures
4.6 Design of FIR Filters
4.7 Design of Filterbanks
7.8 Design of IIR Filters
7.9 Issues in the Design and Implementation of a Digital Filter
4.1 Introduction
Filters are widely employed in signal processing and communication systems in
applications such as channel equalization, noise reduction, radar, audio
processing, video processing, biomedical signal processing, and analysis of
economic and financial data. For example in a radio receiver band-pass filters,
or tuners, are used to extract the signals from a radio channel. In an audio
graphic equalizer the input signal is filtered into a number of sub-band signals
and the gain for each sub-band can be varied manually with a set of controls to
change the perceived audio sensation. In a Dolby system pre-filtering and post-
filtering are used to minimize the effect of noise. In hi-fi audio a compensating
filter may be included in the preamplifier to compensate for the non-ideal
frequency-response characteristics of the speakers. Filters are also used to
create perceptual audio-visual effects for music, films and in broadcast studios.
The primary functions of filters are one of the followings:
(a) To confine a signal into a prescribed frequency band as in low-pass,
high-pass, and band-pass filters.
(b) To decompose a signal into two or more sub-bands as in filter-banks,
graphic equalizers, sub-band coders, frequency multiplexers.
(c) To modify the frequency spectrum of a signal as in telephone channel
equalization and audio graphic equalizers.
(d) To model the input-output relationship of a system such as
telecommunication channels, human vocal tract, and music synthesizers.
Depending on the form of the filter equation and the structure of
implementation, filters may be broadly classified into the following classes:
(a) Linear filters versus nonlinear filters.
(b) Time-invariant filters versus time-varying filters.
(c) Adaptive filters versus non-adaptive filters.
(d) Recursive versus non-recursive filters.
(e) Direct-form, cascade-form, parallel-form and lattice structures.
In this chapter we are mainly concerned with linear time-invariant (LTI) filters.
These are a class of filters whose output is a linear combination of the input and
Sec. 4.2 Linear Time Invariant Filters 3
whose coefficients do not vary with time. Time-varying and adaptive filters are
considered in later chapters.
A useful method of gaining insight into the behavior of a filter is the pole-
zero description of a filter. As described in Sec. X poles and zeros are the
roots of the denominator and numerator of the transfer function
respectively.
(d) Frequency Response. The frequency response of a filter describes how the
filter alters the magnitude and phase of the input signal frequencies. The
frequency response of a filter can be obtained by taking the Fourier
transform of the impulse response of the filter, or by simple substitution of
the frequency variable e jω for the z variable z = e jω in the z-transfer
function as
Y ( e jω )
H ( z = e jω ) = (4.5)
X ( e jω )
The frequency response of a filter is a complex variable and can be described
in terms of the filter magnitude response and the phase response of the filter.
N M
y (m)=∑ a k y (m − k ) + ∑ bk x(m − k ) (4.6)
k =1 k =0
where {ak, bk} are the filter coefficients, and the output y(m) is a linear
combination of the previous N output samples [y(m−1),…, y(m−N)], the present
input sample x(m) and the previous M input samples [x(m−1),…, x(m−M)]. The
characteristic of a filter is completely determined by its coefficients {ak, bk}.
Sec. 4.2 Linear Time Invariant Filters 5
For a time-invariant filter the coefficients {ak, bk} are constants calculated to
obtain a specified frequency response.
The filter transfer function, obtained by taking the z-transform of the
difference equation (4.6), is given by:
M
∑ bk z − k
k =0
H ( z )= N
(4.7)
1 − ∑ ak z −k
k =1
The frequency response of this filter can be obtained from Eq. (4.7) by
substituting the frequency variable e jω for the z variable, z = e jω , as
M
∑ bk e − jωk
H ( e jω ) = k =0
N
(4.8)
1 − ∑ ak e − jωk
k =1
and H2(z) is the transfer function of a feedback, all-pole, recursive filter given
by
1
H 2 ( z )= N
(4.11)
1 − ∑ a k z −k
k =1
M N
∑
k =0
bk x(m − k) ∑a y(m−k)
k=1
k
b0
x(m)
y(m)
z –1 z –1
b1 a1
z –1 z–1
b2 a2
.. ..
. .
bM–1 aN – 1
z–1 z –1
bM aN
Non-recursive Recursive
all-zero part all-pole part
Figure 4.1 Illustration of a direct-form pole-zero IIR filter showing the output is
composed of the sum of two vector products: a weighted combination of the input
samples [b0, …, bM][x(m), …, x(M-1)]T plus a weighted combination of the output
feedback [a1, …, aN][y(m-1), …, y(m-N)]T. T denotes transpose.
Sec. 4.3 Recursive and non Recursive Filters 7
x(m)
z –1 z –1 z –1
..
.
y(m)
m b1 b2 bM–1 bM bM/2
b0
Impulse Input
b0 bM m
Impulse Response
As shown in Fig 4.2 the output y(m) of a non-recursive filter is a function only
of the input signal x(m). The response of such a filter to an impulse consists of a
finite sequence of M+1 samples, where M is the filter order. Hence, the filter is
known as a Finite-Duration Impulse Response (FIR) filter. Other names for a
non-recursive filter include all-zero filter, feed-forward filter or moving average
(MA) filter a term usually used in statistical signal processing literature.
Fig 4.1 shows a direct form implementation of Eq. (4.13). In theory, when a
recursive filter is excited by an impulse, the output persists forever. Thus a
recursive filter is also known as an Infinite Duration Impulse Response (IIR)
filter. Other names for an IIR filter include feedback filters, pole-zero filters and
8 Chapter 5 Digital Filters
x(m ) g y(m )
z –1
a1
z –1
a2
a2
.. ..
. .
a N –1
a N –1
–1
z
aN
aN
g
H ( z) = N
(4.15)
1 − ∑ a k z −k
k =1
m m
x(1) x(0) h(k)
x(0)
Response to x(0)
m m
x(1) h(k-1)
Response to x(1)
m m
x(1)
x(2) h(k-2)
x(2) Response to x(2)
m m
y (m)=∑ h(k ) x (m − k )
Output signal
Figure 4.4 Illustration of the output of a filter in response to an input as the sum of the
impulse responses of the filter to individual input samples. This is the convolution of
input and the impulse response.
10 Chapter 5 Digital Filters
N
y ( m ) =∑ h ( k ) x ( m − k ) (4.16)
k =1
k k
h(k) h(k)
k k
Figure 4.5 A comparative illustration of convolution and correlation operations. Both
operations are sum product of two signals. The difference is that convolution
involves folding of one of the two signals.
Sec. 4.3 Recursive and non Recursive Filters 11
From Equations (4.16) and (4.18) the difference between convolution and
correlation is that in convolution of two signals, one of the two signals, say x(k),
is folded in time to become x(-k), as illustrated in Figure 4.9. Hence, the relation
between correlation and convolution can be expressed as
Conv (h(k ) x(k ) ) = Corr (h(k ) x(− k ) ) (4.19)
The Fourier transform of Equation 4.16, of convolution of two sequences h(k)
and x(k), gives Equation (4.17) in the frequency domain, repeated here
Y ( f ) =H ( f ) X ( f ) (4.20)
whereas the Fourier transform of Equation 4.18, of correlation of two sequences
h(k) and x(k), gives
R( f ) = H ( f ) X * ( f ) (4.21)
where the asterisk sign denotes complex conjugate. Note that the folding of a
signal in time domain is equivalent to a complex conjugate operation in the
frequency domain.
b0
+ y(m)
z –1
b1 + a1
z –1
b2 + a2
.. .. ..
. . .
bN + aM
where G is the filter gain and the poles (pks) and zeros (zks) are either complex
conjugate pairs or real-valued. The factorised terms in Equation (4.22) can be
grouped in terms of the complex conjugate pairs and expressed as cascades of
second order terms as
⎛ (1 − z1z −1 )(1 − z1* z −1 ) ⎞ ⎛ (1 − z2 z −1)(1 − z2* z −1) ⎞ ⎛ −1 −1 ⎞
⎟ × × ⎜ (1 − zM / 2 z )(1 − zM / 2 z ) ⎟
*
H ( z )= G⎜ ⎟×⎜ (4.23)
⎜ (1 − p z −1)(1 − p* z −1 ) ⎟ ⎜ (1 − p z −1)(1 − p* z −1) ⎟ ⎜ (1 − p −1 −1 ⎟
N / 2 z )(1 − pN / 2 z ) ⎠
*
⎝ 1 1 ⎠ ⎝ 2 2 ⎠ ⎝
Each bracketed term in Eq. (4.23) is the z-transfer function of a second order
IIR filter as shown in Figs. 4.7 and 4.8.a. Eq. (4.23) can be expressed in a
compact notation as
K
H ( z )=G ∏ H k ( z ) (4.24)
k =1
Sec. 4.4 Filter Structures 13
where for an IIR filter, assuming that N > M, the variable K is the integer part
of (N+1)/2 and for an FIR filter K is the integer part of (M+1)/2. Note that a
cascade filter may also have one or several first order sections with real-valued
zeros and/or real-valued poles and that when N or M are odd numbers there will
be at least one first order zero or first order pole in the cascade expression.
For an IIR filter each second order cascade section has the form
1 + b k z −1 + b k z −2
H k ( z )= (4.25)
1 + a k1 z −1 + a k 2 z − 2
For an FIR filter, as shown in Fig. 4.8.b, each second order cascade section has
the form
H k ( z )=1 + bk z −1 + bk z −2 (4.26)
b0 b0 b0
g + + +
Figure 4.7 Realization of an IIR cascade structure from second order sections.
b0
+
z-1 z-1
x(m) z-1
-b1 + a1
a1 a2
1
z-1
-b2 + a2 y(m)
(a) (b)
Figure 4.8 Realization of a second order section of: (a) an IIR Filter, (b) an FIR filter.
14 Chapter 5 Digital Filters
H 1(z)
x(m) + y(m)
H 2 (z)
..
.
H N (z)
∑1− a ∑
ek
H ( z) = K + −1 −2
+ −1
(4.27)
k =1 1k z − a2k z k =1 1 − a k z
or
N1 + N 2
H ( z) = K + ∑H
k =1
k ( z) (4.28)
Expanding Eq. (4.30) and using the assumed symmetry of the filters’ impulse
response ⎯ i.e. h(0)=h(M), h(1)=h(M−1) and so on ⎯ we have
H ( f )=h(0) + h(1) e − j2 πf + h(2)e − j4 πf + + h( M − 1)e − j2( M −1) πf + h( M )e − j2 Mπf
⎡ ⎤
− jMπf ⎢ jMπf − jMπf j( M − 2) πf − j( M − 2) πf ⎥
=e ⎢h( M / 2) + h(0)e + h( M )e + h(1)e + h( M − 1)e + ⎥
⎢⎣ 2 h ( 0) cos( Mπf ) 2 h (1) cos(( M − 2) πf ) ⎥⎦
(4.31)
where it is assumed that the filter length M+1 is an odd integer. Hence the
frequency response of the filter H(f) can be expressed as
⎡ ( M −1) / 2 ⎤
H ( f )=e − jMπf ⎢h( M / 2) + ∑ 2h(m) cos(( M − 2m)πf ) ⎥ (4.32)
⎢⎣ m =0 ⎥⎦
The term in the bracket is real-valued. The filter phase is the term e-jMπf, and the
filter phase response is given by
16 Chapter 5 Digital Filters
⎧− Mπf if H a ( f ) ≥ 0
φ ( f )= ⎨ (4.33)
⎩− Mπf + π if H a ( f ) < 0
where Ha(f) is the real-valued term within the bracket of Eq. (4.32). Thus the
phase response of an FIR filter with a symmetric impulse response is a linear
function of the frequency variable f. When the amplitude of the frequency
response Eq. (4.32) goes negative the phase undergoes a change of π radians.
= h( M ) + h( M − 1) z −1 + + h(0) z − M (4.34)
M
= z −M ∑ h ( m) z m = z − M H ( z −1 )
m =0
Form Eq. (4.34) we have the relationship H(z)= z-MH(z-1) which implies that if
H(z) has a zero at z=z1 then it must also have a zero at z=1/z1. Therefore, in
general the z-transfer function of a linear phase FIR filter can be factorized as
H ( z ) = G (1 − r1e − jϕ1 z −1 )(1 − r1e jϕ1 z −1 ) (1 − ( 1 / r1 )e − jϕ1 z −1 )(1 − (1 / r1 )e jϕ1 z −1 ) (4.35)
Complex conjugate zeor pair Resiprocal zero pair
where rk and ϕk are the radius and angular frequency of the kth complex pair of
zeros. Thus the zeros of a linear phase filter occur in reciprocal pairs mirrored
w.r.t. the unit circle, the exception being when the zeros are on the unit circle.
Example 4.1
The input-output relationship of a finite impulse response filter is given as
y (m)= x(m) −2.5 x(m − 1) + 5.25 x(m − 2) −2.5 x(m − 3) + x(m − 4) (4.36)
(i) Write the z-transfer function of this filter.
(ii) Show that the filter has a linear phase response.
Sec. 4.6 Design of Infinite Impulse Response (IIR) Filters 17
(iii) Find and plot the zeros of this filter and explain the constraints on the
position of the zeros of a linear phase filter.
Solution:
The z-transfer function of the finite impulse response filter H(z) is given by
H ( z )=1−2.5 z −1 + 5.25 z −2 −2.5 z −3 + z −4 (4.37)
where Ha(f) is the real-valued term within the bracket of Eq. (4.45). The
transfer function H(z) can be factorized as
Im
1/r
r
Re
Figure 4.10 Symmetric structure of the zeros of a linear phase FIR filter
18 Chapter 5 Digital Filters
(
H ( z ) = 1−0.5 z −1 + 0.25 z −2 1−2 z −1 + 4 z −2)( )
= (1−0.5e )(1 −0.5e π )(1−2e )(1−2e π )
(4.41)
− jπ / 3 −1 j / 3 −1 − jπ / 3 −1 j / 3 −1
z z z z
The zeros of the filter are positioned at a radii of 0.5 and 2 and angles of ±60
as shown in Fig. 4.10.
Example 4.2 Consider a unit delay filter with the following impulse response
h(m)
⎧1 m =1
x(m) z –1 y(m) h(m) = δ (m − 1) =⎨
⎩0 otherwise
0 1 m (4.42)
The frequency response of the filter is obtained as the Fourier transform of the
impulse response as
M
H( f ) = ∑ h(m) e − j2πmf = e − j2πf (4.43)
m =0
1.0
Magnitude(f)
Phase(f)
-3.5
0.0 0
Frequency Fs/2 Frequency Fs/2
Figure 4.11 Magnitude frequency and phase response of a unit delay filter.
Sec. 4.6 Design of Infinite Impulse Response (IIR) Filters 19
This filter has a unity magnitude response and a linear phase response shown in
Fig. 4.11. This is called a pure delay filter as its only effect is to delay the input.
The frequency response of the filter is obtained as the Fourier transform of the
impulse response as
M
H( f ) = ∑ h(m)e − j2πmf = e − j2 Kπf (4.47)
m =0
Phase(f)
-2
0 -4
1
Frequency 0 Frequency Fs/2
Fs/2
Figure 4.12 Magnitude and phase response of a delay filter with a delay of 10-units.
20 Chapter 5 Digital Filters
1 1
The frequency response of the filter is obtained as the Fourier transform of the
impulse response as
M
H( f ) = ∑ h(m)e − j2πmf = 1 +e − j2 Kπf
(4.51)
m =0
− j K πf
=e (e jKπf +e − jKπf ) = e − jKπf 2 cos( Kπf )
This filter’d magnitude frequency response is comb-shaped and given by
2
Magnitude(f)
Phase(f)
-2
0
Frequency Fs/2 Frequency Fs/2
⎧1 m = 0,1,...,10
h ( m) =⎨ (4.54)
⎩0 otherwise
m
The filter length is 11 samples long. The frequency response of this filter is
obtained from the Fourier transform of the impulse response and using the
convergence formula for a geometric series, as
10
1 − e − j22πf e − j11πf e j11πf − e − j11πf sin(11πf )
H( f ) = ∑ e− j2πfmT s =
1− e − j2πf
=
e − jπf
×
e jπf
−e − j πf
= e − j10πf
sin(πf )
(4.55)
m =0
12 1.5
10 1.0
|Magnitude(f)|
0.5
Phase(f)
8 0.0
6 -0.5
-1.0
4 -1.5
2 -2.0
-2.5
0 -3
0 0
Frequency Fs/2 Frequency Fs/2
Figure 4.14 Magnitude and phase response of filter with a rectangular impulse response.
22 Chapter 5 Digital Filters
where bks are the filter coefficients, M is the filter order, and x(m) and y(m) are
the filter’s input and output signals respectively. Now, when an FIR filter Eq.
(4.57) is excited with an impulse input then it is easy to see, as shown in Fig.
4.2, that the impulse response of the FIR filter is identical to the coefficients
sequence of the filter {bk} that is:
⎧b 0≤k≤ M
h(k ) = ⎨ k (4.58)
⎩0 Otherwise
Hence the filtering Eq. (4.58) can be expressed as the convolution of the
impulse response of the FIR filter h(m) with the input signal x(m) as
M
y ( m) = ∑ h ( k ) x ( m − k ) (4.59)
k =0
This observation forms the basis for the method of FIR filter design by
windowing. In the window design method we begin with the desired frequency
response Hd(f) and obtain the corresponding impulse response hd(m) which, for
an FIR filter, is the filter coefficients.
The frequency response Hd(f) and the impulse response hd(m) of a linear
filter are related by the Fourier transform pair as
M
H d ( f )=∑ hd (m)e − j2 mπf (4.60)
m=0
1/ 2
j2 mπf
hd (m)= ∫ H d ( f )e df (4.61)
−1 / 2
Thus given the desired filter frequency response Hd(f) we can determine the
impulse response hd(m) by evaluating the above Fourier integral. However,
Sec. 4.6 Design of Infinite Impulse Response (IIR) Filters 23
there are two problems here. First, the filter has infinite duration impulse
response. Second, the filter is non-causal, as it will have non-zero values for
coefficients with negative time index. Note a negative-indexed coefficient e.g.
h(-k) requires a future sample value x(m+k), this makes the filter non-causal for
real-time operations. These problems are solved by first multiplying hd(m) by a
truncation window of length (M+1) samples, and then shifting the truncated
impulse response by M/2 samples in the positive time direction.
The FIR filter window design technique involves the following steps:
(1) Start with the desired frequency response Hd(f).
(2) Choose a filter order M.
(3) Obtain hd(m) the inverse Fourier transform of Hd(f), From Eq. (4.61).
(4) Window hd(m) to obtain M+1 FIR filter coefficients centred at m=0.
(5) Shift the windowed impulse response by M/2 samples for causality.
The convolution of the rectangular window W(f) with the filter Hd(f) has
the effects of introducing ripples in the frequency spectrum of the filter and
extending the transition regions of the filter. As the filter order M increases the
main lobe width and the amplitude of the side lobes decrease.
The side lobes in the frequency domain are manifestation of the
discontinuities in time domain at the edges of a rectangular window and can be
alleviated by the use of windows that do not contain sharp discontinuities and
roll down rather gently to zero such as the raised-cosine windows of Hamming,
Hanning, and Blackman windows described in section 3.xx and reproduced here
for convenience. The general form of the raised cosine window equation is
given by
⎧ 2πm
⎪α − (1 − α ) cos 0≤m≤M
w(m) = ⎨ M +1 (4.65)
⎪⎩ 0 otherwise
% This function draws the shape of a window and its frequency response
Sec. 4.6 Design of Infinite Impulse Response (IIR) Filters 25
1
0 .9
0 .8
Amplitude
0 .7
0 .6
0 .5
0 .4
0 .3
0 .2 R e c ta n g le
H a m m in g
0 .1
B la c k m a n
0
0 20 40 60 80 100 120 128
T im e
Figure 4.15 Plot of: (a) rectangular window, (b) Hamming window, (c) Blackman
window for a window length of 32 samples (left) and 128 samples.
0 0
20 log10|W(f)| dB
20 log10|W(f)| dB
-10 -10
-20 -20
-30 -30
-40 -40
-50 -50
-60 -60
0 Fs/2 0 Fs/2
Frequency Hz Frequency Hz
(a)
0 0
20 log10|W(f)| dB
20 log10|W(f)| dB
-10 -10
-20 -20
-30 -30
-40 -40
-50 -50
-60 -60
0 Fs/2 0 Fs/2
Frequency Hz Frequency Hz
(b)
26 Chapter 5 Digital Filters
0 0
-10 -10
20 log10|W(f)| dB
20 log10|W(f)| dB
-20 -20
-30 -30
-40 -40
-50 -50
-60 -60
-70 -70
-80 -80
0 Fs/2 0 Fs/2
Frequency Hz Frequency Hz
(c)
Figure 4.16 The spectra of: (a) rectangular window (b) Hamming window, (c) Blackman
window for a window length of 32 samples (left) and 128 samples (right).
sin (2πFc m )
Fc
e j2 πfm
Fc
j2 πfm
hd (m)= ∫ 1.0 e df =
j2πm
=
πm
(4.70)
− Fc − Fc
0.5 1.2
0.4 1.0
0.3
0.8
h(m)
|H(f)|
0.2
0.6
0.1
0.4
0
-0.1 0.2
(a) -0.2
0 5 10 15 20 25 30 0
Time m Frequency fs/2
0.5 1.2
0.4 1.0
0.3
0.8
0.2
0.6
|H(f)|
h(m)
0.1 Time m
0.4
0.0
-0.1 0.2
(b) -0.2
0 20 40 60 80 100 0
Time m Frequency fs/2
0.5 1.2
0.4 1.0
0.3 0.8
h(m)
|H(f)|
0.2
0.6
0.1
0.4
0.0
0.2
-0.1
(c) -0.2
0 20 40 60 80 100 0
Frequency fs/2
Time m
Figure 4.17 The impulse response and the magnitude frequency response of an
FIR filter for the following cases: (a) filter order 30 with a rectangular window, (b)
filter order 100 with a rectangular window, (c) filter order 100 with a hamming
window.
28 Chapter 5 Digital Filters
orders of M=30 and M=100 are shown in Fig 4.17. Observe the relatively large
oscillations or the ripples in the pass-band and the stop-band. These ripples
increase in frequency as M the filter order is increased. These oscillations are a
direct result of the convolution with the side-lobes of the rectangular window.
To reduce the ripples in both the pass-band and the stop-band we can use a
window function that decays to zero gradually instead of the abrupt
discontinuous transition that happens at the edges of a rectangular window.
Fig 4.17.b illustrates how the use of a Hamming window reduces the ripples in
the pass-band and the stop-band. The ‘price’ paid is an increase in the
bandwidth of the transition band.
The impulse response of this filter is obtained via the inverse Fourier integral as
− Fc / Fs − Fc / Fs 0. 5
e j2 mπf e j2 mπf
0. 5
j2 mπf j2 mπf
hd (m) = ∫ 1.0e df + ∫ 1.0e df =
j2mπ
+
j2mπ
−0.5 Fc / Fs − 0. 5 Fc / Fs
sin (π m ) sin (2π m Fc / Fs )
= −
mπ mπ
(4.73)
The impulse response hd(m) is non-causal (it is nonzero for m < 0) and infinite
in duration. To obtain an FIR filter of order M we multiply hd(m) by a
rectangular window sequence of length M+1 samples. To introduce causality
(h(m) =0 for m < 0) shift truncated h(m) by M/2 samples
Sec. 4.6 Design of Infinite Impulse Response (IIR) Filters 29
– +
+
Delay of
M/2
H( f )
1 ⎧1 FL < | f | < FH
H d ( f )= ⎨ (4.75)
⎩0 otherwise
–FH –FL FL FH f
The impulse response of this filter is obtained via the inverse Fourier integral as
− FL / FS − FL / FS FH / FS
e j2 mπf e j2 mπf
FH / FS
j2 mπf j2 mπf
hd (m) = ∫ 1.0 e df + ∫ 1.0 e df =
j2mπ
+
j2mπ
− FH / FS FL /FS − FH / FS FL / FS
sin (2π m FH / FS ) sin (2π m FL / FS )
= −
mπ πm
(4.76)
30 Chapter 5 Digital Filters
The impulse response hd(m) is non-causal (it is nonzero for m < 0) and infinite
in duration. To obtain an FIR filter of order M multiply hd(m) by a rectangular
window sequence of length M+1 samples. To introduce causality (h(m) =0 for
m < 0) shift truncated h(m) by M/2 samples
sin (2π (m − M / 2) FH / Fs ) sin (2π (m − M / 2) FL / Fs )
h ( m) = − (4.77)
(m − M / 2)π (m − M / 2)π
Note that a high-pass FIR filter is equivalent to the configuration shown in the
Fig. 4.19.
+
+
–
Figure 4.19 Design of a band-pass FIR filter from a low-pass FIR filters
The impulse response of this filter is obtained via the inverse Fourier integral as
Sec. 4.6 Design of Infinite Impulse Response (IIR) Filters 31
− FH / Fs FL / Fs 0. 5
j2 mπf j2 mπf j2 mπf
hd (m) = ∫ 1.0 e df + ∫ 1.0 e df + ∫ 1.0 e df
−0.5 − FL / Fs FH / Fs (4.79)
sin π m sin 2π mFH / Fs sin 2π mFL / Fs
= − +
mπ πm πm
The impulse response hd(m) is non-causal (it is nonzero for m < 0) and infinite
in duration. To obtain an FIR filter of order M we multiply hd(m) by a
rectangular window sequence of length M+1 samples. To introduce causality
(h(m) =0 for m < 0) shift h(m) by M/2 samples
sin π (m − M / 2) sin 2π (m − M / 2) FH / Fs sin 2π (m − M / 2) FL / Fs
h ( m)= − +
(m − M / 2)π ( m − M / 2) π ( m − M / 2) π
(4.80)
Note that a band-pass FIR filter is also equivalent to the configuration shown in
the Figure 4.20.
+
+
−π π + –
− FL FL
− FH FH
Figure 4.20 Design of a band-stop FIR filter from low-pass FIR filters.
function DrawFIR_WindowsResponse()
% This function draws the impulse response and the frequency response of an FIR
% filter with a selection of different types of frequency response (lowpass, highpass,
% bandpass, bandstop)and windows. The filter design parameters are filtertype,
% window, filter cutoff frequencies and filter order.
32 Chapter 5 Digital Filters
Using the solution described in section 4.xx we obtain the windowed FIR filter
response as
h1 (m)= w(m) × 0.25 sinc(0.25π (m − M / 2)) 0≤m≤M (4.82)
To design the band-pass filters we can use the amplitude modulation (AM)
method to translate a low-pass filter to a band-pass filter. For a band-pass
width of 1 kHz the low-pass filter should have cutoff frequencies of ±500 Hz
(note that from –500 to +500 Hz we have a bandwidth of 1 kHz). Thus the
required low pass FIR filter equation is similar to Eq. (4.82), but with half the
bandwidth, and its impulse response is given by given by
h(m)= w(m) × 0.125 sinc (0.125π(m − M / 2) ) 0 ≤ m ≤ M (4.83)
To translate this low pass filter to the specified band pass filters we need AM
sinusoidal carriers with frequencies 1.5 kHz, 2.5 kHz and 3.5 kHz. The
modulated band pass filter equations are given by
h2 (m)= 2 × w(m) × 0.125 sinc(0.125π(m − M / 2) )sin (3πm / 8) 0≤ m ≤M (4.84)
h3 (m)= 2 × w(m) × 0.125 sinc(0.125π(m − M / 2) )sin(5πm / 8) 0≤ m ≤M (4.85)
0 .8
0 .6
0 .4
0 .2
0
0 F re q u e n c y F s/2
0 .2 0 .1 5
0 .1
0 .1 5
0 .0 5
0 .1
0
0 .0 5 -0 .0 5
-0 .1
0
-0 .1 5
- 0 .0 5
-0 .2
-0 .1 -0 .2 5
0 F re q u e n c y F s/2 0 F re q u e n c y F s/2
0 .2 5
0 .2 5
0 .2
0 .2
0 .1 5
0 .1 5
0 .1
0 .1
0 .0 5
0 .0 5
0
- 0 .0 5 0
- 0 .0 5
-0 .1
- 0 .1 5 -0 .1
-0 .2 - 0 .1 5
- 0 .2 5 0 -0 .2
F re q u e n c y F s/2 0 F re q u e n c y F s/2
Figure 4.23 The impulse response of the individual band-pass filters of a 4-band filter-
bank, plotted clockwise from the top left corner for bands 1 to 4.
a factor of 2. After downsampling, the upper band has inverted frequencies, i.e.
the low frequencies appear at the high frequencies and vice versa.
The filterbank of Figure 4.24 consists of a lowpass filter, H0(z), a
highpass filter H1(z), downsamplers, a DSP process (for such functions as
coding, noise reduction etc.), upsamplers and antialiasing filters G0(z) and
G1(z). The lowpass filter H0(z) and the highpass filter H1(z), split the input
signal into low frequency and high frequency bands. Both subband signals are
then downsampled by a factor of 2.
The z-transform of a signal down-sampled by a factor of 2 can be
expressed as
1
X d ( z ) = ⎡⎣ X ( z1/ 2 ) + X (− z1/ 2 ) ⎤⎦ ()
2
Note that the realtion is true because
⎧2 z k / 2 for k even
( z1/ 2 ) k + (− z1/ 2 ) k = ⎨ ()
⎩0 otherwise
After filtering and dowsampling, the z-transforms of the lowpass and highpass
subband signals, denoted as X0d(z) and X1d(z) respectively, can be expressed as
1
X 0 ( z ) = G0 ( z ) [ H 0 ( z ) X ( z ) + H 0 (− z ) X (− z ) ] (4.87 )
2
1
X 1 ( z ) = G0 ( z ) [ H1 ( z ) X ( z ) + H1 (− z ) X (− z ) ] (4.87 )
2
X ( z) = X 0 ( z) + X1 ( z)
1 1
= [G0 ( z ) H 0 ( z ) + G1 ( z ) H1 ( z )] X ( z ) + [G0 ( z ) H 0 (− z ) + G1 ( z ) H1 (− z )] X (− z )
2 2
Aliasing Term
(4.87 )
∞
X 0d ( f ) = ∑ X ( f + kFs / 2) H 0 ( f + kFs / 2) (4.87 )
k = −∞
∞
X 1d ( f ) = ∑ X ( f + kFs / 2) H1 ( f + kFs / 2) (4.88 )
k = −∞
Figure 14.24 illustrates the spectrum of a full band signal and also the spectra
of the lowpass and higpass sub-bands before and after downsampling by a
factor of 2 to 1. Note that whereas the spectrum of the fullband signal has a
bandwidth of Fs and a repeatition period of Fs, the spectra of the subband
signals after downsampling by a factor of 2 have a bandwidth of Fs/2 and a
repeatition period of Fs/2.
To reconstruct the signal, both sub-band signals are upsampled by a
factor of 2, and filtered with anti-aliasing filters G0(f) and G1(f). Thus, the
reconstructded output can be written as
X1(f),
Fs/4 <f < Fs/2
X(f)
H1( f ) 2:1 1:2 G1( f )
Digital ^
Signal + X(f)
Processor
H0( f ) 2:1 1:2 G0( f )
X0(f),
Fs/4 <f < Fs/2
Figure 4.24 - A QMF filter splitting a signal into two equal bandwidth sub-bands. For
reconstruction the individual subband signals are upsampled and filtered by anti-
aliasing filters.
Sec. 4.6 Design of Infinite Impulse Response (IIR) Filters 37
X( f )
(a)
-F 0 Fs
s f
X 0( f ) = H 0 ( f )X 0( f )
(b )
f
X 1( f ) = H 1 ( f )X ( f )
(c )
f
X 0d ( f )
(d )
f
X 1d ( f )
(e )
Figure 4.25 Illustration of dividing a signal into two subbands: (a) the original
signal, (b) the lower half-band, (c) the upper half-band, (d) the lower half-band
after down-sampling, and (e) the upper half-band after down-sampling.
Note that as a result of downsampling a signal by a factor Fs/2 and the
consequent aliasing X(f+Fs/2) becomes X(f). Hence after downsampling the
higher frequencies of the upperband signal (c) appear at the lower frequencies in
(d) and vice versa.???????
Xˆ ( f ) = [H 0 ( f )G0 ( f ) + H 1 ( f )G1 ( f )] X ( f ) +
1
2
1
[H 0 ( f + Fs / 2)G0 ( f ) + H 1 ( f + Fs / 2)G1 ( f )] X ( f + Fs / 2)
2
aliasing
(4.89)
where for notational convenience the sampling frequency Fs (e.g. 44100Hz for
music) is usually normalised to 1. Note that as a result of downsampling by a
factor of 2 and then later upsampling by a factor of 2, each frequency f will
have an aliasing term X(f+Fs/2). For cancellation of the aliasing term, we
require thefollowing relationships between the frequency response of the
subband filters H0(f) and H1(f) and the antialiasing filters G0(f) and G1(f):
38 Chapter 5 Digital Filters
Figure 4.26 A tree-based method for dividing a signal into three sub-bands.
G0 ( f ) = H1 ( f + Fs / 2) (4.90)
− G1 ( f ) = H 0 ( f + Fs / 2) (4.91)
we also require
1
[G0 ( f ) H 0 ( f ) + G1 ( f ) H 1 ( f )]=1 (4.92)
2
so that perfect reconstruction is achieved.
The aliaising cancellation may not work perfectly in the presence of
quantization noise. To get good reconstruction without relying on the aliasing
cancellation, the QMF filters need to have a steep pass-to-stop-band transition.
QMF filters can be constrcuted by designing a low pass filter with a cutoff
frequency of Fs/4 and then inverting the sign of the odd-indexed coefficients −
this has the effect of mirroring the poles and zeros − to produce a high pass
filter.
Splitting a signal into more than two subbands can be performed by using
a binary tree structure of QMF filters where a set of two QMF filters (a lowpass
and a highpass) combined with down sampler/s are used several times in a tree-
like structure to progressively divide the frequency spectrum and achieve finer
bandsplitting as illustrated in Figures (4.25 and 4.26).
function QMF( )
% Function QMF is a simple 2 band filter designed from a low pass FIR filter
Sec. 4.6 Design of Infinite Impulse Response (IIR) Filters 39
Figure 4.27 The configuration of a filter bank to split a total bandwidth of 22.05 kHz
into three bands of 0-4.5125 kHz, 4.5125-11.025 kHz and 11.025-22.05 kHz.
40 Chapter 5 Digital Filters
1
0.9
0.8
0.7
Magnitude(f)
0.6
0.5
0.4
0.3
0.2
0.1
0
Frequency fs/2
Figure 4.28 The pole-zero diagram and the magnitude spectrum of a second order
notch filter.
To control the bandwidth of the notch filter we place a pair of poles on the same
frequency as the notch frequency as shown in Figure 4.28. The resulting
transfer function is
1 + z −2
H ( z) = g (4.97)
1 + r 2 z −2
The radius of the pole controls the bandwidth of the notch filter, the nearer the
pole to the unit circle the smaller the bandwidth resulting in a sharper notch
filter. Fig. 4.28 shows the angular position and the frequency response of a
complex pair of poles and zeros at an angle of π/2.
The frequency response of the notch filter is obtained by substituting
jω
z =e as
1 + e − j 2ω
H ( e jω ) = g (4.98)
1 + r 2 e − j 2ω
Substituting the magnitude response specifications H(ω=0)=1 or H(ω=π)=1
yields
1 + e0
H (0) = g = 1 → g = 0.5(1 + r 2 ) (4.99)
1+ r e 2 0
42 Chapter 5 Digital Filters
Im
1.2
0.8
0.6
Re
0.4
0.2
0
0 Frequency Fs/2
(a) (b)
Figure 4.29 The pole-zero diagram (a), and the magnitude spectrum (b), of an 8th
order notch filter.
Exercises
1.
(a) Briefly list the signal processing steps required in the window design
technique, to obtain the coefficients of a causal finite impulse response
(FIR) discrete-time filter given the desired frequency response of the filter
H(f).
(b) Using the inverse Fourier transform method design two digital filters, a
low-pass filter and a high-pass filter, to divide the input signal into two
equal bandwidth signals.
(c) With the aid of a sketch show how the low pass and high pass filters in
(b) can be repeatedly used in a tree-like structure to divide a signal
bandwidth into 3 subband with the two lower bands having a width of
half those of the upper band.
2.
(a) State three different applications of filters.
(b) Explain why the impulse response function can completely describe the
characteristics of a linear time-invariant filter.
(c) Write the relationship between the impulse response and the frequency
response of a linear time-invariant filter.
Sec. 4.6 Design of Infinite Impulse Response (IIR) Filters 45
Obtain the z-transfer function of this filter and write the z transfer function of this
equation in polar form in terms of the radius and angular frequencies of its zeros.
Sketch the pole-zero diagram and the frequency response of the filter.
3.
(a) Explain the relationships between the Laplace transform, the z-transform
and the Fourier transform.
(b) Show how z-transform can be derived from Laplace transform and how
discrete Fourier transform (DFT) can be derived from z-transform of a
signal.
(c) The Figure below shows the discrete-time input signal and the impulse
response of a linear time invariant filter. Using the principles of linearity
and superposition, obtain the output of the filter in response to the input
discrete-time input signal shown in the Figure.
m m
x(1)
4 (a) State the reasons why it is preferable to design IIR filters as a cascade of
second order units?
46 Chapter 5 Digital Filters
(b) The difference equation relating the input and output of the infinite duration
impulse response (IIR) filter, shown in Figure below, is
Input Output
g -1 -1 -1 -1 -1
z z z z
(i) Taking the z-transform of the difference equation find, the transfer function
of the filter.
(ii) Describe the transfer function in polar form, and for a value of a=0.6561
obtain the pole and zeros of the filter and sketch its pole-zero diagram.
(iii) Sketch the frequency response of the filter, and suggest an application for
this filter. Discuss the effect of varying the value of a on the frequency
response of the filter.
(c) Calculate the value of the gain g such that the gain for the badnpass regions
is 1.0.
Using the transfer function equation obtain the values of the coefficients rz, ϕ z
and ϕ p of a second order notch filter for removing a sinusoidal interference with
a frequency of 100 Hz. Assume a sampling frequency of 10 kHz.
Sketch the pole-zero diagram and the frequency response of the notch filter.
Explain the effect of varying rp on the frequency response of notch filter.
Calculate the values of filter coefficients for which the second order system
acts as a digital oscillator operating at 10 kHz and with an oscillation
frequency of 1 kHz.
7 (a) Determine and sketch the impulse response h(n) of the low pass filter
described by the following equation
⎧⎪1 f < fc
H( f ) = ⎨
⎩⎪ 0 f ≥ fc
(b) Figure shows the bloack diagram of a high pass digital filter with frequency
response HHP(f), incorporating a low pass filter HLP(f).
HHP(f)
HLP(f)
-fc
-fc fc
(i) Obtain the frequency response and the impulse response of the filter HHP(f).
(ii) Assuming that the lowpass filter HLP(f) has N taps, for what value of the
delay variable D would the high filter HHP(f) perform correctly ?
8 Design a system for converting the sampling rate of a digital signal x(m), originally
sampled at a rate of 44 kHz, to a sampling rate of 16 kHz. Draw a block diagram of
this system and describe the operation of each subsystem.
H ( z ) = z −4 + z +4
What modification of the equation for h(n) is necessary before it can be used as
the impulse response of a causal filter.
10 (a) Describe in details the window design techniques for the design of a
finite impulse response (FIR) low pass filter with the frequency response
specification as shown in figure ().
Obtain and sketch the impulse response of this filter.
Explain the main effects of varying the filter order.
X (f)
-f c fc f
Using the window design technique and the filter impulse response from part
(a) above, design a bank of digital filters for a telephony speech application to
split a total bandwidth of 4 kHz to four equal width subbands.
(i) Write the cutoff frequencies and the equations for the response of the filter in
each band. Your equations should include the numerical parameters needed to
achieve the required cutoff frequencies.
(ii) Choose a value for the number of taps of the filter in each band and explain
how the number of filter coefficients affects the filter response.
(iii) Suggest an application for this filter bank.
11 Determine the values of a1 and a2 for which the second order system shown
in the figure and operating at a sampling rate of 40 kHz becomes a sinusoidal
oscillator with an oscillation frequency of 5 kHz. Plot a pole-zero diagram for
the oscillator.
Sec. 4.6 Design of Infinite Impulse Response (IIR) Filters 49
Input x(n)
Output y(n)
-1
z
-a 1
-1
z
-a 2
14 State the main effects of (i) a complex conjugate pair of poles, and (ii) a
complex conjugate pair of zeros, on the frequency response of a filter. Using the
window design method, derive an expression for the impulse response of a
50 Chapter 5 Digital Filters
causal lowpass digital finite impulse response (FIR) filter of length N operating
at a sampling rate of 20 kHz and with a cutoff frequency of 5 kHz.
State the effect of varying N on the frequency response of the filter. State what
values of N are typically used in the design of a lowpass FIR filter.
15 Consider a second order all zero infinite impulse response (IIR) system
operating at 20 KHz and with the z-transfer function given as
G
H ( z) =
1 + b1 z + b2 z − 2
−1
Assume that this system has a complex conjugate pair of poles. Rewrite the
transfer function in terms of pole radius and pole resonance frequency.
Find the values of the coefficients b1, b2 and the gain G for which this filter has
a resonance frequency of 5 kHz, a gain G of unity at this frequency, and a
bandwidth of 100 Hz.
Plot its pole-zero diagram, and write its frequency response equation. Write the
difference equation of this system.