Professional Documents
Culture Documents
7-1 (FIR Filter Design)
7-1 (FIR Filter Design)
3. Window Method
FIR Filter Format (1)
Input-output relationship
𝐾
𝑦 𝑛 = 𝑏𝑖 𝑥 𝑛 − 𝑖 = 𝑏0 𝑥 𝑛 + 𝑏1 𝑥 𝑛 − 1 + ⋯ + 𝑏𝐾 𝑥 𝑛 − 𝐾
𝑖=0
• 𝑏𝑖: FIR filter coefficients
• 𝐾: degree of FIR filter
• 𝐾 + 1: FIR filter length
Transfer Function
𝑌 𝑧 = 𝑏0 𝑋 𝑧 + 𝑏1 𝑧 −1 𝑋 𝑧 + ⋯ + 𝑏𝐾 𝑧 −𝐾 𝑋 𝑧
𝑌 𝑧
𝐻 𝑧 = = 𝑏0 + 𝑏1 𝑧 −1 + ⋯ + 𝑏𝐾 𝑧 −𝐾
𝑋 𝑧
Frequency response
1, Ω ≤ Ω𝑐
𝐻 𝑒 𝑗Ω =ቊ
0, Ω𝑐 ≤ Ω ≤ 𝜋
Ω𝑐
, 𝑛 = 0 sin Ω 𝑛
ℎ𝑛 = 𝜋 =
𝑐
sin Ω𝑐 𝑛 𝜋𝑛
, 𝑛≠0
𝜋𝑛
Sol)
a. Ω𝑐 = 0.2𝜋 radians
0.2, 𝑛=0
ℎ 𝑛 = ቐsin 0.2𝜋𝑛
, 𝑛≠0
𝜋𝑛
ℎ 0 = 0.2, ℎ 1 = ℎ −1 = 0.1871
𝑏0 = 𝑏2 = 0.1871, 𝑏1 = 0.2
b. 𝐻 𝑧 = 0.1871 + 0.2𝑧 −1 + 0.1871𝑧 −2
𝑦 𝑛 = 0.1871𝑥 𝑛 + 0.2𝑥 𝑛 − 1 + 0.1871𝑥 𝑛 − 2
c.
𝐻 𝑒 𝑗Ω = 𝑒 −𝑗Ω 0.2 + 0.3742 cos Ω
𝐻 𝑒 𝑗Ω = 0.2 + 0.3742 cos Ω
−Ω if 0.2 + 0.3742 cos Ω > 0
∠𝐻 𝑒 𝑗Ω = ቊ
−Ω + 𝜋 if 0.2 + 0.3742 cos Ω < 0
Gibbs effect
– The oscillations exhibited in the passband (main lobe)
and stop band (side lobes) of the magnitude frequency
response
– Originates from the abrupt truncation of the infinite
impulse response
– Window functions will be used to remedy the problem
Rectangular window
– 𝑤rec(𝑛) = 1, −𝑀 ≤ 𝑛 ≤ 𝑀
Triangular (Bartlett) window
𝑛
– 𝑤tri 𝑛 = 1 − , −𝑀 ≤ 𝑛 ≤ 𝑀
𝑀
Hanning window
𝜋𝑛
– 𝑤han 𝑛 = 0.5 + 0.5 cos , −𝑀 ≤𝑛 ≤𝑀
𝑀
Hamming window
𝜋𝑛
– 𝑤ham 𝑛 = 0.54 + 0.46 cos , −𝑀 ≤𝑛 ≤𝑀
𝑀
Blackman window
𝜋𝑛 2𝜋𝑛
– 𝑤black 𝑛 = 0.42 + 0.5 cos + 0.08 cos , −𝑀 ≤𝑛 ≤𝑀
𝑀 𝑀
b = fir1(N-1, Fc)
– Computes and returns N-point impulse response
coefficients of an FIR filter with a cutoff frequency Fc.
– Returns the N-point coefficients in the vector 𝒃,
arranged in ascending negative powers of 𝑧.
𝑏 𝑧 = 𝑏 0 + 𝑏 1 𝑧 −1 + ⋯ + 𝑏 𝑁 − 1 𝑧 − 𝑁−1
𝒃 = 𝑏 0 𝑏 1 𝑏 2 ⋯𝑏 𝑁 − 1
– The parameter, N-1, in the command specifies the order
of the filter (normally one less than the number of FIR
filter coefficients)
– The cutoff frequency, Fc, is normalized with respect to
the Nyquist frequency and lies between 0 and 1.
b = fir1(N-1,Fc,w)
– w = boxcar(N); w = blackman(N); w = hamming(N)
– w = hanning(N); w = kaiser(N,beta)
b = fir1(N-1,Fc,’filter-type’,w)
-40
-60
-80
-100
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)
0
Phase (degree)
-500
-1000
-1500
-2000
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)
0
-20
-40
-60
-80
-100
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)
200
Phase (degree)
100
-100
-200
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)
Specifications:
– Fig. 7.14
– Table 7.7 FIR filter length estimation
𝑓stop −𝑓pass
∆𝑓 = ; normalized transition width
𝑓𝑠
Filter length for Hamming window: 𝑁 = 3.3/Δ𝑓
Passband ripple
– 𝛿𝑝 dB = 20 log10 1 + 𝛿𝑝
Stopband attenuation
– 𝛿𝑠 dB = −20 log10 𝛿𝑠
Cut-off frequency
– 𝑓𝑐 = (𝑓pass + 𝑓stop)/2
0
Magnitude (dB)
-50
-100
500
Phase (degrees)
-500
-1000
-1500
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)
Frequency responses of the designed highpass filter using the Hanning window.
Speech 0.5
-0.5
-1
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Sample number
4
x 10
1
Highpassed speech
0.5
-0.5
-1
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Sample number
800
Amplitude |X(f)|
600
400
200
0
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)
30
Amplitude |Y(f)|
20
10
0
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)
Spectral comparison of the original speech and processed speech using the
highpass filter.