0% found this document useful (0 votes)
33 views22 pages

Fir Window Method

The document discusses the Gibbs oscillatory behavior in the frequency response of FIR filters and introduces the window method to mitigate these oscillations. Various window functions, such as rectangular, triangular, Hanning, Hamming, and Blackman, are presented, along with their mathematical formulations. The design procedure for FIR filters using the window method is outlined, including examples that demonstrate the application of the Hamming window and the calculation of filter coefficients.

Uploaded by

tanzimahmed024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views22 pages

Fir Window Method

The document discusses the Gibbs oscillatory behavior in the frequency response of FIR filters and introduces the window method to mitigate these oscillations. Various window functions, such as rectangular, triangular, Hanning, Hamming, and Blackman, are presented, along with their mathematical formulations. The design procedure for FIR filters using the window method is outlined, including examples that demonstrate the application of the Hamming window and the calculation of filter coefficients.

Uploaded by

tanzimahmed024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

242 CHAPTER 7 FINITE IMPULSE RESPONSE FILTER DESIGN

To summarize Example 7.3, the magnitude frequency response demonstrates the Gibbs oscillatory
behavior existing in the passband and stopband. The peak of the main lobe in the passband is dropped
from 0 dB to approximately 10 dB, while for the stopband, the lower side lobe in the magnitude re-
sponse plot swings approximately between 18 and 70 dB, and the upper side lobe swings between
25 and 68 dB. As we have pointed out, this is due to the abrupt truncation of the infinite impulse
sequence h(n). The oscillations can be reduced by increasing the number of coefficient and using a
window function, which will be studied next.

7.3 WINDOW METHOD


In this section, the window method (Fourier transform design with window functions) is developed to
remedy the undesirable Gibbs oscillations in the passband and stopband of the designed FIR filter. Re-
call that the Gibbs oscillations originate from the abrupt truncation of the infinite-length coefficient
sequence. Then it is natural to seek a window function, which is symmetrical and can gradually weight
the designed FIR coefficients down to zeros at both ends for the range of  M  n  M. Applying the
window sequence to the filter coefficients gives
hw ðnÞ ¼ hðnÞ  wðnÞ,

where w(n) designates the window function. Common window functions used in the FIR filter design
are as follows:
1. Rectangular window:
wrec ðnÞ ¼ 1,  M  n  M: (7.23)

2. Triangular(Bartlett) window:
jnj
wtri ðnÞ ¼ 1  ,  M  n  M: (7.24)
M
3. Hanning window:
nπ 
whan ðnÞ ¼ 0:5 + 0:5 cos ,  M  n  M: (7.25)
M
4. Hamming window:
nπ 
wham ðnÞ ¼ 0:54 + 0:46 cos ,  M  n  M: (7.26)
M
5. Blackman window:
nπ  2nπ
wblack ðnÞ ¼ 0:42 + 0:5 cos + 0:08 cos ,  M  n  M: (7.27)
M M

In addition, there is another popular window function, called the Kaiser window [its detailed informa-
tion can be found in Oppenheim et al. (1998)]. As we expected, the rectangular window function has a
constant value of 1 within the window, hence does only truncation. As a comparison, shapes of the other
window functions from Eqs. (7.23) to (7.27) are plotted in Fig. 7.9 for the case of 2M + 1 ¼ 81.
We apply the Hamming window function in Example 7.4.
7.3 WINDOW METHOD 243

FIG. 7.9
Shapes of window functions for the case of 2M + 1 ¼ 81. “o” line, triangular window; “+” line, Hanning window;
Solid line, Hamming window; Dashed line, Blackman window.

EXAMPLE 7.4
Given the calculated filter coefficients
hð0Þ ¼ 0:25, hð1Þ ¼ hð1Þ ¼ 0:22508,hð2Þ ¼ hð2Þ ¼ 0:15915, hð3Þ ¼ hð3Þ ¼ 0:07503,

a. Apply the Hamming window function to obtain windowed coefficients hw(n).


b. Plot the impulse response h(n) and windowed impulse response hw(n).

Solution:
(a) Since M ¼ 3, applying Eq. (7.18) leads to the window sequence
3  π
wham ð3Þ ¼ 0:54 + 0:46 cos ¼ 0:08
3
2  π
wham ð2Þ ¼ 0:54 + 0:46 cos ¼ 0:31
3
1  π
wham ð1Þ ¼ 0:54 + 0:46 cos ¼ 0:77
3
0π
wham ð0Þ ¼ 0:54 + 0:46 cos ¼ 1,
3

Continued
244 CHAPTER 7 FINITE IMPULSE RESPONSE FILTER DESIGN

EXAMPLE 7.4—CONT’D
1π
wham ð1Þ ¼ 0:54 + 0:46 cos ¼ 0:77
3
2π
wham ð2Þ ¼ 0:54 + 0:46 cos ¼ 0:31
3
3π
wham ð3Þ ¼ 0:54 + 0:46 cos ¼ 0:08:
3
Applying the Hamming window function and its symmetric property to the filter
coefficients, we get
hw ð0Þ ¼ hð0Þ  wham ð0Þ ¼ 0:25  1 ¼ 0:25
hw ð1Þ ¼ hð1Þ  wham ð1Þ ¼ 0:22508  0:77 ¼ 0:17331 ¼ hw ð1Þ
hw ð2Þ ¼ hð2Þ  wham ð2Þ ¼ 0:15915  0:31 ¼ 0:04934 ¼ hw ð2Þ
hw ð3Þ ¼ hð3Þ  wham ð3Þ ¼ 0:07503  0:08 ¼ 0:00600 ¼ hw ð3Þ:
(b) Noncausal impulse responses h(n) and hw(n) are plotted in Fig. 7.10.

0.2
h(n)

0.1

0
−4 −3 −2 −1 0 1 2 3 4
Sample number n

0.2
hw(n)

0.1

0
−4 −3 −2 −1 0 1 2 3 4
Sample number n
FIG. 7.10
Plots of FIR noncausal coefficients and windowed FIR coefficients in Example 7.4.
7.3 WINDOW METHOD 245

We observe that the Hamming window does its job to weight the FIR filter coefficients to zero
gradually at both ends. Hence, we can expect a reduced Gibbs effect in the magnitude frequency
response.
Now the lowpass FIR filter design via the window design method can be achieved. The design
procedure includes three steps. The first step is to obtain the truncated impulse response h(n),
where  M  n  M; then we multiply the obtained sequence h(n) by the selected window data seq-
uence to yield the windowed noncausal FIR filter coefficients hw(n); and the final step is to delay
the windowed noncausal sequence hw(n) by M samples to achieve the causal FIR filter coefficients,
bn ¼ hw(n  M). The design procedure of the FIR filter via windowing is summarized as follows:
1. Obtain the FIR filter coefficients h(n) via the Fourier transform method (Table 7.1).
2. Multiply the generated FIR filter coefficients by the selected window sequence

hw ðnÞ ¼ hðnÞwðnÞ, n ¼ M, …0,1, …,M, (7.28)


where w(n) is chosen to be one of the window functions listed in Eqs. (7.23)–(7.27).
3. Delay the windowed impulse sequence hw(n) by M samples to get the windowed FIR filter
coefficients:

bn ¼ hw ðn  MÞ, for n ¼ 0,1,⋯, 2M: (7.29)


Let us study the following design examples.

EXAMPLE 7.5
(a) Design a three-tap FIR lowpass filter with a cutoff frequency of 800 Hz and a sampling rate of
8000 Hz using the Hamming window function.
(b) Determine the transfer function and difference equation of the designed FIR system.
(c) Compute and plot the magnitude frequency response for Ω ¼ 0, π/4, π/2, 3π/4, and π (rad).

Solution:
(a) The normalized cutoff frequency is calculated as
800
Ωc ¼ 2πfc Ts ¼ 2π  ¼ 0:2π ðradÞ:
8000

Since 2M + 1 ¼ 3 in this case, FIR coefficients obtained by using the equation in Table 7.1 are
listed as
hð0Þ ¼ 0:2 and hð1Þ ¼ hð1Þ ¼ 0:1871
(see Example 7.2). Applying Hamming window function defined in Eq. (7.26), we have

wham ð0Þ ¼ 0:54 + 0:46 cos ¼1
1
1π
wham ð1Þ ¼ 0:54 + 0:46 cos ¼ 0:08:
1

Continued
7.3 WINDOW METHOD 253

20

−20
Magnitude frequency responses

−40
Hanning window
−60 Peak of 1st side lobe

−80 Hamming window


Peak of 1st side lobe

−100
Blackman window
Peak of 1st side lobe
−120

−140
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)
FIG. 7.13
Comparisons of magnitude frequency responses for the Hanning, Hamming, and Blackman windows.

Passband Transition Stopband

pass

FIG. 7.14
Lowpass filter frequency domain specifications.

where fpass and fstop are the passband frequency edge and stop frequency edge. The filter length using
the Hamming window can be determined by
3:3
N¼ : (7.31)
Δf
Note that the passband ripple is defined as
 
δp dB ¼ 20  log 10 1 + δp , (7.32)
254 CHAPTER 7 FINITE IMPULSE RESPONSE FILTER DESIGN

Table 7.7 FIR Filter Length Estimation Using Window Functions (Normalized Transition
Width Δf ¼ jfstop fpass j)
fs

Stopband
Window Window Function Window Length Passband Ripple Attenuation
Type w(n), 2M ≤ n ≤ M (N) (dB) (dB)

Rectangular 1 N ¼ 0.9/Δf 0.7416 21


πn
Hanning 0:5 + 0:5cos N ¼ 3.1/Δf 0.0546 44
Mπn
Hamming 0:54 + 0:46 cos N ¼ 3.3/Δf 0.0194 53
M
nπ
Blackman 0:42 + 0:5 cos N ¼ 5.5/Δf 0.0017 74
M
2nπ
+0:08cos
M

while the stopband attenuation is defined as

δs dB ¼ 20  log 10 ðδs Þ: (7.33)

The cutoff frequency used for design will be chosen at the middle of the transition band, as illustrated
for the lowpass filter case shown in Fig. 7.14.
As a rule of thumb, the cutoff frequency used for design is determined by

fpass + fstop
fc ¼ : (7.34)
2

Note that Eq. (7.31) and formulas for other window lengths in Table 7.7 are empirically derived
based on the normalized spectral transition width of each window function. The spectrum of each
window function appears to be shaped like the lowpass filter magnitude frequency response with
ripples in the passband and side lobes in the stopband. The passband frequency edge of the spec-
trum is the frequency where the magnitude just begins to drop below the passband ripple and where
the stop frequency edge is at the peak of the first side lobe in spectrum. With the passband ripple
and stopband attenuation specified for a particular window, the normalized transition width of
the window is in inverse proportion to the window length N multiplied by a constant. For example,
the normalized spectral transition Δf for the Hamming window is 3.3/N. Hence, matching the
FIR filter transition width with the transition width of the window spectrum gives the filter length
estimation listed in Table 7.7.
The following examples illustrate the determination of each filter length and cutoff frequency/fre-
quencies for the design of lowpass, highpass, bandpass, and bandstop filters. Application of each
7.3 WINDOW METHOD 255

designed filter to the processing of speech data is included, along with an illustration of filtering effects
in both time domain and frequency domain.

EXAMPLE 7.8
A lowpass FIR filter has the following specifications:

Passband 0–1850 Hz
Stopband 2150–4000 Hz
Stopband attenuation 20 dB
Passband ripple 1 dB
Sampling rate 8000 Hz

Determine the FIR filter length and the cutoff frequency to be used in the design equation.

Solution:
The normalized transition band as defined in Eq. (7.30) and Table 7.7 is given by
j2150  1850j
Δf ¼ ¼ 0:0375:
8000
Again, based on Table 7.7, selecting the rectangular window will result in a passband ripple of
0.74 dB and stopband attenuation of 21 dB. Thus, this window selection would satisfy the design
requirement for the passband ripple of 1 dB and stopband attenuation of 20 dB (Although all the
other windows satisfy the requirement as well but this one results in a small number of coeffi-
cients). Next, we determine the length of the filter as
0:9 0:9
N¼ ¼ ¼ 24:
Δf 0:0375
We choose the odd number N ¼ 25 [requirement in Eq. (7.18)]. The cutoff frequency is determined
by (1850 +2150)/2¼ 2000 Hz. Such a filter has been designed in Example 7.7, its filter coefficients
is listed in Table 7.6, and its frequency responses can be found in Fig. 7.12 (dashed lines).

Now we look at the time domain and frequency domain results from filtering a speech signal
by using the lowpass filter we have just designed. Fig. 7.15A shows the original speech and
lowpass filtered speech. The spectral comparison is given in Fig. 7.15B, where, as we can see, the fre-
quency components beyond 2 kHz are filtered. The lowpass filtered speech would sound muffled.
We will continue to illustrate the determination of the filter length and cutoff frequency for other
types of filters via the following examples.
256 CHAPTER 7 FINITE IMPULSE RESPONSE FILTER DESIGN

× 104
1

0.5
Speech

−0.5

−1
0 200 400 600 800 1000 1200 1400 1600 1800 2000

× 104
1
Lowpassed speech

0.5

−0.5

−1
0 200 400 600 800 1000 1200 1400 1600 1800 2000
(A) Sample number

800

600
Amplitude X(f )|

400

200

0
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)

800

600
Amplitude |Y(f )|

400

200

0
0 500 1000 1500 2000 2500 3000 3500 4000
(B) Frequency (Hz)
FIG. 7.15
(A) Original speech and processed speech using the lowpass filter. (B) Spectral plots of the original speech and
processed speech by the lowpass filter.
7.3 WINDOW METHOD 257

EXAMPLE 7.9
Design a highpass FIR filter with the following specifications:

Stopband 0–1500 Hz
Passband 2500–4000 Hz
Stopband attenuation 40 dB
Passband ripple 0.1 dB
Sampling rate 8000 Hz

Solution:
Based on the specification, the Hanning window will do the job since it has passband ripple
of 0.0546 dB and stopband attenuation of 44 dB.
Then
j1500  2500j
Δf ¼ ¼ 0:125
8000
3:1
N¼ ¼ 24:2 Choose N ¼ 25:
Δf
Hence, we choose 25 filter coefficients using the Hanning window method. The cutoff frequency
is (1500 + 2500)/2 ¼ 2000 Hz. The normalized cutoff frequency can be easily found as
2000  2π
Ωc ¼ ¼ 0:5π ðradÞ:
8000
and note that 2M + 1 ¼ 25. The application program and design results are listed in Program 7.4
and Table 7.8.

Table 7.8 FIR Filter Coefficients in Example 7.9 (Hanning Window)


Bhan: FIR Filter Coefficients (Hanning Window)

b0 ¼ b24 ¼ 0.000000 b1 ¼ b23 ¼ 0.000493


b2 ¼ b22 ¼ 0.000000 b3 ¼ b21 ¼  0.005179
b4 ¼ b20 ¼ 0.000000 b5 ¼ b19 ¼ 0.016852
b6 ¼ b18 ¼ 0.000000 b7 ¼ b17 ¼  0.040069
b8 ¼ b16 ¼ 0.0000000 b9 ¼ b15 ¼ 0.090565
b10 ¼ b14 ¼ 0.000000 b11 ¼ b13 ¼  0.312887
b12 ¼ 0.500000

Program 7.4. MATLAB program for Example 7.9.


% Fig. 7.16 (Example 7.9)
% MATLAB program to create Fig. 7.16
%
N = 25; Ftype=2; WnL= 0; WnH= 0.5*pi; Wtype=3;fs=8000;
Bhan= firwd(N,Ftype,WnL,WnH,Wtype);
freqz(Bhan,1,512,fs);
axis([0 fs/2 -120 10]);
7.3 WINDOW METHOD 259

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
(B) Frequency (Hz)

FIG. 7.17, CONT’D


(B) Spectral comparison of the original speech and processed speech using the highpass filter.

EXAMPLE 7.10
Design a bandpass FIR filter with the following specifications:

Lower stopband 0–500 Hz


Passband 1600–2300 Hz
Upper stopband 3500–4000 Hz
Stopband attenuation 50 dB
Passband ripple 0.05 dB
Sampling rate 8000 Hz

Solution:
j1600  500j j3500  2300j
Δf1 ¼ ¼ 0:1375 and Δf2 ¼ ¼ 0:15
8000 8000
3:3 3:3
N1 ¼ ¼ 24 and N2 ¼ ¼ 22
0:1375 0:15
Choosing N ¼ 25 filter coefficients using the Hamming window method:
1600 + 500 3500 + 2300
f1 ¼ ¼ 1050 Hz and f2 ¼ ¼ 2900 Hz:
2 2
The normalized lower and upper cutoff frequencies are calculated as

1050  2π
ΩL ¼ ¼ 0:2625π ðradÞ and
8000

Continued
260 CHAPTER 7 FINITE IMPULSE RESPONSE FILTER DESIGN

EXAMPLE 7.10—CONT’D
2900  2π
ΩH ¼ ¼ 0:725π ðradÞ,
8000
and N ¼ 2M + 1 ¼ 25. Using the MATLAB program, design results are achieved as shown in
Program 7.5.

Program 7.5. MATLAB program for Example 7.10


% Fig. 7.18 (Example 7.10)
% MATLAB program to create Fig. 7.18
%
N = 25; Ftype= 3; WnL=0.2625*pi; WnH=0.725*pi; Wtype=4;fs=8000;
Bham= firwd(N,Ftype,WnL,WnH,Wtype);
freqz(Bham,1,512,fs);
axis([0 fs/2 -130 10]);

Fig. 7.18 depicts the frequency responses of the designed bandpass FIR filter. Table 7.9 lists the
designed FIR filter coefficients.
For comparison, the original speech and bandpass filtered speech are plotted in Fig. 7.19A,
where the bandpass frequency components contains a small portion of speech energy. Fig. 7.19B
shows a comparison indicating that the low-frequency and high-frequency components are removed
by the bandpass filter.
Magnitude response (dB)

−50

−100

0 500 1000 1500 2000 2500 3000 3500 4000


Frequency (Hertz)

500

0
Phase (degrees)

−500

−1000

−1500

−2000
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hertz)
FIG. 7.18
Frequency responses of the designed bandpass filter using the Hamming window.
Table 7.9 FIR Filter Coefficients in Example 7.10 (Hamming Window)
Bham: FIR Filter Coefficients (Hamming Window)

b0 ¼ b24 ¼ 0.002680 b1 ¼ b23 ¼  0.001175


b2 ¼ b22 ¼  0.007353 b3 ¼ b21 ¼ 0.000674
b4 ¼ b20 ¼  0.011063 b5 ¼ b19 ¼ 0.004884
b6 ¼ b18 ¼ 0.053382 b7 ¼ b17 ¼  0.003877
b8 ¼ b16 ¼ 0.028520 b9 ¼ b15 ¼  0.008868
b10 ¼ b14 ¼  0.296394 b11 ¼ b13 ¼ 0.008172
b12 ¼ 0.462500

× 104
1

0.5
Speech

−0.5

−1
0 200 400 600 800 1000 1200 1400 1600 1800 2000

× 104
1
Bandpassed speech

0.5

−0.5

−1
0 200 400 600 800 1000 1200 1400 1600 1800 2000
(A) Sample number
800
Amplitude X(f )|

600

400

200

0
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)

50

40
Amplitude |Y(f )|

30

20

10

0
0 500 1000 1500 2000 2500 3000 3500 4000
(B) Frequency (Hz)

FIG. 7.19
(A) Original speech and processed speech using the bandpass filter. (B) Spectral comparison of the original
speech and processed speech using the bandpass filter.
7.4 NOISE REDUCTION AND TWO-BAND DIGITAL CROSSOVER 267

Program 7.7. MATLAB program for the application of noise filtering.


close all; clear all
fs =8000; % Sampling rate
T = 1/fs; % Sampling period
v = sqrt(0.1)*randn(1,250); % Generate Gaussian random noise
n = 0:1:249; % Indexes
x = sqrt(2)*sin(2*pi*500*n*T)+v; % Generate 500-Hz sinusoid plus noise
subplot(2,1,1);plot(n,x);
xlabel('Number of samples');ylabel('Sample value');grid;
N = length(x);
f =[0:N/2]*fs/N;
Axk= 2*abs(fft(x))/N;Axk(1)=Axk(1)/2; % calculate single side spectrum
for x(n)
subplot(2,1,2); plot(f,Axk(1:N/2+1));
xlabel('Frequency (Hz)'); ylabel('Amplitude j X(f )j ');grid;
figure
Wnc= 2*pi*900/fs; % determine the normalized digital cutoff frequency
B = firwd(133,1,Wnc,0,4); % design FIR filter
y = filter(B,1,x); % perform digital filtering
Ayk= 2*abs(fft(y))/N;Ayk(1)=Ayk(1)/2; % single-side spectrum of the filtered data
subplot(2,1,1); plot(n,y);
xlabel('Number of samples');ylabel('Sample value');grid;
subplot(2,1,2);plot(f,Ayk(1:N/2 +1)); axis([0 fs/2 0 1.5]);
xlabel('Frequency (Hz)'); ylabel('Amplitude j Y(f )j ');grid;

7.4.2 SPEECH NOISE REDUCTION


In a speech recording system, we digitally record speech in a noisy environment at a sampling rate of
8000 Hz. Assuming that the recorded speech contains information within 1800 Hz, we can design a
lowpass filter to remove the noise between 1800 Hz and the Nyquist limit (the folding frequency of
4000 Hz). Therefore, we have the filter specifications listed below:
Filter type: lowpass FIR filter
Passband frequency range: 0–1800 Hz
Passband ripple: 0.02 dB
Stopband frequency range: 2000–4000 Hz
Stopband attenuation: 50 dB
According to these specifications, we can determine the following parameters for filter design:
Window type ¼ Hamming window
Number of filter tap ¼ 133
Lowpass cutoff frequency ¼ 1900 Hz.
Fig. 7.24A shows the plots of the recorded noisy speech and its spectrum. As we can see in the noisy
spectrum, the noise level is high and broadband. After applying the designed lowpass filter, we plot the
filtered speech and its spectrum shown in Fig. 7.24B, where the clean speech is clearly identified, while
the spectrum shows that the noise components above 2 kHz have been completely removed.
268 CHAPTER 7 FINITE IMPULSE RESPONSE FILTER DESIGN

× 104
1

0.5
Sample value

−0.5

−1
0 0.05 0.1 0.15 0.2 0.25
Number of samples

800

600
Amplitude |X(f )|

400

200

0
0 500 1000 1500 2000 2500 3000 3500 4000
(A) Frequency (Hz)
× 104
1

0.5
Sample value

−0.5

−1
0 0.05 0.1 0.15 0.2 0.25
Number of samples

800
Amplitude |Y(f )|

600

400

200

0
0 500 1000 1500 2000 2500 3000 3500 4000
(B) Frequency (Hz)
FIG. 7.24
(A) Noisy speech and its spectrum. (B) Enhanced speech and its spectrum.
270 CHAPTER 7 FINITE IMPULSE RESPONSE FILTER DESIGN

0.5
Sample value

−0.5
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Number of samples

0.04

0.03
Amplitude |Y(f )|

0.02

0.01

0
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hz)
FIG. 7.26
Retrieved vibration signal and its spectrum.

7.4.4 TWO-BAND DIGITAL CROSSOVER


In audio systems, there is often a situation where the application requires the entire audible range of
frequencies, but this is beyond the capability of any single speaker driver. So, we combine several
drivers, such as the speaker cone and horns, each covering different frequency range, to reproduce
the full audio frequency range.
A typical two-band digital crossover can be designed as shown in Fig. 7.27. There are two speaker
drivers. The woofer responds to low frequencies, and the tweeter responds to high frequencies.

Highpass filter Gain_H Tweeter:


yH(n)
The crossover passes
Digital high frequencies
audio x(n)

Lowpass filter Gain_L Woofer:


yL(n)
The crossover passes
low frequencies

FIG. 7.27
Two-band digital crossover.
7.4 NOISE REDUCTION AND TWO-BAND DIGITAL CROSSOVER 271

The incoming digital audio signal is split into two bands by using a lowpass filter and a highpass filter in
parallel. We then amplify the separated audio signals and send them to their respective corresponding
speaker drivers. Hence, the objective is to design the lowpass filter and the highpass filter so that their
combined frequency response is flat, while keeping transition as sharp as possible to prevent audio
signal distortion in the transition frequency range. Although traditional crossover systems are designed
using active circuits (analog systems) or passive circuits, the digital crossover system provides a cost-
effective solution with programmable ability, flexibility, and high quality.
A crossover system has the following specifications:
Sampling rate ¼ 44,100 Hz
Crossover frequency ¼ 1000 Hz (cutoff frequency)
Transition band ¼ 600 Hz to1400 Hz
Lowpass filter ¼ passband frequency range from 0 to 600 Hz with a ripple of 0.02 dB and stopband
edge at 1400 Hz with the attenuation of 50 dB.
Highpass filter ¼ passband frequency range from 1.4 to 44.1 kHz with ripple of 0.02 dB and stop-
band edge at 600 Hz with the attenuation of 50 dB.
In the design of this crossover system, one possibility is to use an FIR filter, since it provides a linear
phase for the audio system. However, an IIR filter (which will be discussed in Chapter 8) can be an
alternative. Based on the transition band of 800 Hz and the passband ripple and stopband attenuation
requirements, the Hamming window is chosen for both lowpass and highpass filters, we can determine
the number of filter taps as 183, each with a cutoff frequency of 1000 Hz.
The frequency responses for the designed lowpass filter and highpass filter are shown in Fig. 7.28A,
and for the lowpass filter, highpass filter, and combined responses appear in Fig. 7.28B. As we can
see, the crossover frequency for both filters is at 1000 Hz, and the combined frequency response is
perfectly flat. The impulse responses (filter coefficients) for lowpass and highpass filters are plotted
in Fig. 7.28C.
Magnitude response (dB)

−50

−100

−150

−200
100 101 102 103 104
Frequency (Hz)
Magnitude response (dB)

−50

−100

−150

−200
100 101 102 103 104
(A) Frequency (Hz)

FIG. 7.28
(A) Magnitude frequency responses for the lowpass filter and highpass filter.
(Continued)
272 CHAPTER 7 FINITE IMPULSE RESPONSE FILTER DESIGN

20
Combined
0

−20 LPF HPF

−40
Magnitude response (dB)

−60

−80

−100

−120

−140

−160

−180

−200
100 101 102 103 104
(B) Frequency (Hz)

0.06
Impulse response of LPF

0.04

0.02

−0.02
0 20 40 60 80 100 120 140 160 180 200
n
1
Impulse response of HPF

0.5

−0.5
0 20 40 60 80 100 120 140 160 180 200
(C) n

FIG. 7.28, CONT’D


(B) Magnitude frequency responses for both the lowpass filter and highpass filter, and the combined magnitude
frequency response for the digital audio crossover system. (C) Impulse responses of both the FIR lowpass filter
and the FIR highpass filter for the digital audio crossover system.

7.5 FREQUENCY SAMPLING DESIGN METHOD


In addition to methods of Fourier transform design and Fourier transform with windowing discussed in
the previous section, frequency sampling is another alternative. The key feature of frequency sampling
is that the filter coefficients can be calculated based on the specified magnitudes of the desired filter
frequency response uniformly sampled in the frequency domain. Hence, it has design flexibility.
To begin with development, we let h(n), for n ¼ 0, 1, ⋯, N  1, be the causal impulse response (FIR
filter coefficients) that approximates the FIR filter, and we let H(k), for k ¼ 0, 1, ⋯, N  1, represent the
corresponding discrete Fourier transform (DFT) coefficients. We obtain H(k) by sampling the desired
7.5 FREQUENCY SAMPLING DESIGN METHOD 273

Desired filter frequency response

Desired filter frequency response

FIG. 7.29
Desired filter frequency response and sampled frequency response.

frequency filter response H(k) ¼ H(ejΩk) at equally spaced instants in frequency domain, as shown in
Fig. 7.29.
Consider the FIR filter transfer function:
HðzÞ ¼ hð0Þ + hð1Þz1 + ⋯ + hðN  1ÞzðN1Þ : (7.35)
Its frequency response is then given by
 
H ejΩ ¼ hð0Þ + hð1Þej1Ω + ⋯ + hðN  1ÞejðN1ÞΩ : (7.36)

Sampling H(e ) at equally spaced instants Ωk ¼ 2πk/N for k ¼ 0, 1, ⋯, N  1, as shown in Fig. 7.29,

we have
 
H ejΩk ¼ hð0Þ + hð1Þej12πk=N + ⋯ + hðN  1ÞejðN1Þ2πk=N : (7.37)

Using the definition of DFT, it is easy to verify the expansion of Eq. (7.37) as follows:
for k ¼ 0:
  X
N 1
H ejΩ0 ¼ hð0Þ + hð1Þej12π0=N + ⋯ + hðN  1ÞejðN1Þ2π0=N ¼ hðnÞWN0n ¼ H ð0Þ,
n¼0

for k ¼ 1:
  X
N1
H ejΩ1 ¼ hð0Þ + hð1Þej12π1=N + ⋯ + hðN  1ÞejðN1Þ2π1=N ¼ hðnÞWN1n ¼ H ð1Þ,
n¼0


for k ¼ N  1:
  X
N1
kðN1Þ
H ejΩN1 ¼ hð0Þ + hð1Þej12πðN1Þ=N + ⋯ + hðN  1ÞejðN1Þ2πðN1Þ=N ¼ hðnÞWN ¼ HðN  1Þ:
n¼0
274 CHAPTER 7 FINITE IMPULSE RESPONSE FILTER DESIGN

It is observed that
 
H ejΩk ¼ H ðkÞ ¼ DFTfhðnÞg: (7.38)

Thus, the general equation to obtain h(n) is


 
hðnÞ ¼ IDFT H ejΩk : (7.39)

Note that the obtained formula (see Eq. 7.39) does not impose the linear phase, thus it can be used for
nonlinear phase FIR filter design. Second, the sequence h(n) is guaranteed to be real valued.
To simplify the design algorithm in Eq. (7.39), we begin with
X
N1
H ðk Þ ¼ hðnÞWNnk :
n¼0

Note that !∗
X
N 1
nðNkÞ
X
N 1 X
N 1
H ðN  k Þ ¼ hðnÞWN ¼ hðnÞWNnk ¼ hðnÞWNnk ¼ H ðkÞ:
n¼0 n¼0 n¼0

Then
1XN 1
hðnÞ ¼ HðkÞWNkn
N k¼0
!
1 XM X2M
kn kn
¼ Hð0Þ + HðkÞWN + HðkÞWN :
N k¼1 k¼M + 1

For the second summation, let j ¼ N  k ¼ 2M + 1  k. We yield


!
1 XM X 1
ðNjÞn
hðnÞ ¼ Hð0Þ + H ðkÞWNkn + HðN  jÞWN
N k¼1 j¼M
!
1 XM X M
ðNkÞn
kn
¼ Hð0Þ + HðkÞWN + HðkÞWN :
N k¼1 k¼1

Furthermore,
!∗ !
1 XM XM
hðnÞ ¼ Hð0Þ + H ðkÞWNkn + HðkÞWNkn : (7.40)
N k¼1 k¼1

Combining two summations in Eq. (7.40) yields the design equation as


( )!
1 X M
kn
hðnÞ ¼ Hð0Þ + 2 Re HðkÞWN : (7.41)
N k¼1

Now, let us consider the linear phase FIR filter design in Eq. (7.41) with N ¼ 2M + 1 and symmetric
coefficients
 
H ejΩ ¼ hð0Þ + hð1Þej1Ω + ⋯ + hðMÞejMΩ + hðM  1ÞejðM + 1ÞΩ + ⋯ + hð0Þej2MΩ : (7.42a)

We can express Eq. (7.42a) as


" #
  X
M1
jΩ jMΩ
H e ¼e hðMÞ + 2hðnÞcos ½2π ðM  nÞΩ (7.42b)
n¼1
7.5 FREQUENCY SAMPLING DESIGN METHOD 275

Since the term in the bracket in Eq. (7.42b) is real valued (magnitude frequency response), we can
specify the frequency response as
  2πk
H ejΩk ¼ Hk ejM N ¼ HðkÞ (7.43)

Clearly, H ðejΩk Þ ¼ Hk ejk N M
¼ H ðkÞ for k ¼ 0, 1, 2, ⋯, M holds linear phase.
Now, on substituting the magnitude and its corresponding linear phase in Eq. (7.43), Eq. (7.41)
leads to
( )!
1 XM 2π
j N kM kn
hðnÞ ¼ H0 + 2 Re Hk e WN
N k¼1
( )!
1 XM 2π 2π
j N kM j N kn
¼ H0 + 2 Re Hk e e (7.44)
N k¼1
( )!
1 XM 2π
j N kðnMÞ
¼ H0 + 2 Re Hk e :
N k¼1

Finally, we obtain the design formula for FIR filter with linear phase (only magnitudes specification are
required) as
!
1 XM
2πkðn  MÞ
hðnÞ ¼ H0 + 2 Hk cos for 0  n  M: (7.45)
N k¼1
2M + 1

The rigor derivation can be found in Appendix E. The design procedure is therefore simply summarized
as follows:
1. Given the filter length of 2M + 1, specify the magnitude frequency response for the normalized fre-
quency range from 0 to π:

2πk
Hk at Ωk ¼ for k ¼ 0,1, ⋯,M: (7.46)
ð2M + 1Þ

2. Calculate FIR filter coefficients:


( )
1 XM
2πkðn  MÞ
bn ¼ hðnÞ ¼ H0 + 2 Hk cos (7.47)
2M + 1 k¼1
2M + 1

for n ¼ 0, 1, ⋯, M.

3. Using the symmetry (linear phase requirement) to determine the rest of coefficients:

hðnÞ ¼ hð2M  nÞ for n ¼ M + 1,⋯, 2M: (7.48)

Example 7.12 illustrates the design procedure.


280 CHAPTER 7 FINITE IMPULSE RESPONSE FILTER DESIGN

EXAMPLE 7.14
(a) Design a linear phase bandpass FIR filter with 25 coefficients using the frequency sampling
method. Let the lower and upper cutoff frequencies be 1000 and 3000 Hz, respectively, and
assume a sampling frequency of 8000 Hz.
(b) List the FIR filter coefficients.
(c) Plot the frequency responses.

Solution:
(a) First we calculate the normalized lower and upper cutoff frequencies for the bandpass filter;
that is, ΩL ¼ 2π  1000/8000 ¼ 0.25π (rad) and ΩH ¼ 2π  3000/8000 ¼ 0.75π (rad),
respectively. The sampled values of the bandpass frequency response are specified by the
following vector:
Hk ¼ ½0 0 0 0 1 1 1 1 1 0 0 0 0:

As a comparison, the second specification of Hk with smooth transition bands is used; that is,
Hk ¼ ½0 0 0 0:5 1 1 1 1 1 0:5 0 0 0:

(b) The MATLAB list is shown in Program 7.9. The generated FIR coefficients are listed in
Table 7.13.

Table 7.13 FIR Filter Coefficients in Example 7.14 (Frequency Sampling Method)
B1: FIR Filter Coefficients B2: FIR Filter Coefficients

b0 ¼ b24 ¼ 0.055573 b0 ¼ b24 ¼ 0.001351


b1 ¼ b23 ¼  0.030514 b1 ¼ b23 ¼  0.008802
b2 ¼ b22 ¼ 0.000000 b2 ¼ b22 ¼  0.020000
b3 ¼ b21 ¼  0.027846 b3 ¼ b21 ¼ 0.009718
b4 ¼ b20 ¼  0.078966 b4 ¼ b20 ¼  0.011064
b5 ¼ b19 ¼ 0.042044 b5 ¼ b19 ¼ 0.023792
b6 ¼ b18 ¼ 0.063868 b6 ¼ b18 ¼ 0.077806
b7 ¼ b17 ¼ 0.000000 b7 ¼ b17 ¼  0.020000
b8 ¼ b16 ¼ 0.094541 b8 ¼ b16 ¼ 0.017665
b9 ¼ b15 ¼  0.038728 b9 ¼ b15 ¼  0.029173
b10 ¼ b14 ¼  0.303529 b10 ¼ b14 ¼  0.308513
b11 ¼ b13 ¼ 0.023558 b11 ¼ b13 ¼ 0.027220
b12 ¼ 0.400000 b12 ¼ 0.480000
7.5 FREQUENCY SAMPLING DESIGN METHOD 281

Program 7.9 MATLAB program for Example 7.14.


% Fig. 7.32 (Example 7.14)
% MATLAB program to create Fig. 7.32
%
fs= 8000;
H1=[0 0 0 0 1 1 1 1 1 0 0 0 0]; % magnitude specifications
B1= firfs(25,H1); % design filter
[h1,w]=freqz(B1,1,512); % calculate magnitude frequency response
H2=[0 0 0 0.5 1 1 1 1 1 0.5 0 0 0]; % magnitude specification
B2= firfs(25,H2); % design filter
[h2,w]=freqz(B2,1,512); % calculate magnitude frequency response
p1= 180*unwrap(angle(h1)')/pi;
p2= 180*unwrap(angle(h2)')/pi
subplot(2,1,1); plot(f,20*log10(abs(h1)),'-.',f,20*log10(abs(h2)));grid
axis([0 fs/2 -100 10]);
xlabel('Frequency (Hz)'); ylabel('Magnitude Response (dB)');
subplot(2,1,2); plot(f,p1,'-.',f,p2);grid
xlabel('Frequency (Hz)'); ylabel('Phase (degrees)');

(c) Similar to the preceding example, Fig. 7.32 shows the frequency responses. Focusing on the
magnitude frequency responses depicted in Fig. 7.32, the dash-dotted line indicates the magni-
tude frequency response obtained without specifying the smooth transition band, while the solid
line indicates the magnitude frequency response achieved with the specification of the smooth
transition band, hence resulting in the reduced ripple effect.
Magnitude response (dB)

−50

−100
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)

500
Phase (degrees)

−500

−1000

−1500
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)
FIG. 7.32
Frequency responses using the frequency sampling method in Example 7.14.

You might also like