You are on page 1of 5

1 Project Definition:

In this project, yon will design a set of FIR bandpass filters that will allow you to implement an arbitrary
frequency response of your choosing. We will connect these bandpass filters in a parallel structure that is more
generally called a filter bank, as shown below.

x[n] -+~-----.I y[n]

Figure 1.

Assuming that each individual filter bank system impulse response hk [n] in an LTI system , notice that an
equivalent impulse response for the entire filter bank system can be obtained by summing the individual impulse
responses, each multiplied by their respective gaiu , i.e. ,
N
h[n] = L a1.:h.1:[11].
,.,
An input signal can then be processed by convolving it with the equivalent system impulse response, i.e.,
y[n] = x[n] * h[n].
We will be implementing such a filter bank us iug bandpass FIR filters created IL<iing the windowing method. To
begin, we start with an ideal frequency response for n bandpass filter with lower and upper cutoff frequencies,
W/ and w,. , respectively. Thus , for a n ideal bandpass filter , the magnitude response is

IHA:(e-''"') l = { l , if W/ _lwl Wu
0, otherwise

To obtain the impulse response, we apply the inverse DTFT:

li ;[n] = _!_
211"
I'" Hi.: (e-'"')e - i"'dw
- ,r

= _!_ 1-w, C- jwndw + _.!._ /"'" e. - jwn dw


211" -w. 211" ..,,
= ,rljn [eiw. n _ eJw, n + e -jw,n _ C- ;w. n]
2

= ;;; [sin(w., n) - sin(w1n)]

= ~sinc(wun) - ~siuc(w,n).
Such an impubc response exists from 11 E ( - 00,00) and is symmetric ahont 11 = 0, making it 11011-eausal. We
mrnit truncate and shift h;{n] to make it a causal FIR filter for implementation. For each fi lter stage we t hm,
have
h1,[11] = h;[11 + (M - 1)/2]w1, [11 + (M - 1)/ 2],
where k E ( I. N) specifics t he N bandpass filters and w1,[11] is a windowing fun ctiou of (odd ) length M.

You will apply the created filter bauk to a provided aud io signa l to adjust its frC(111cncy content . Such a filter
bank configuration is call()(! an audio equalizer. The audible range of t he human ear i-; approximately within
t he rnnge of22.5 Hz to 22000 Hz. However , humam, perceive sound 011 a logarithmic scale, meaning that we arc
able to distinguish lower fn.'qnencics better thau higher frcc111c11cics. To create an audio C(1ualizcr we tluL-. need
to creat e our bandpass filt ers to occupy equal frequency ba11<L-; on n logarithmic scale, ns showu in the figure
below.

lot(/)

,...
,•••
24Q

••
Q.,r~

Figure 2.
The mnin parameters of interest in this project will be the uumber of bandpass filters N , the length (or order)
of ench FIR filter A{, and the minimum and maximum analog frC(JUencics, /,,.;,, aud /,,.,11 •

2 Design Tasks:
In thi'! section we will make t he analytic computatiorn, UCCCS'!ary to design the filters. In t he document yon
submi t ouliue, create a Design section and provide the information rC(111estC(I below in each task.

=
We will ass ume the input audio files arc sampled at a rate of J~ 44.lkHz, which bi the rate typically \L,;ccl on
audio CDs for .wa v files (note that the sampling rate i-. 2 x 22050Hz, which is 110 coincidence). We will select
N = 8 for the munhcr of bandpass filters aud choose M = 751 for the length of each FIR filter . The goal will
be to IL'!C the log plot above to determine the cutoff frequencies Ji , h , ... , h snch t hat the effective continuous
frequency responses of the eight filters should ha\'C a co111b[uC(I bandwidth ranging from (0, 22050)Hz.

I have providC(l a MATLAB fuuct ion, bpw, that implements a causal FIR bandpass fi lter using t he windowing
method (provided with thi'! assignment) . To use it , all you need to specify arc the lower and upper digital cutoff
frc<111eucics (iu radiatL'! per sample), t he length of the filter M , and t he type of windowiug function to npply
(i.e. , I've done t he hard part ). For additionaJ help with the fnuct ion open the .m file aud read the help section
at the hegiuuiug of t he fi le.

Your task is to design and create the 8 bandpass fi lters, which simply involves determining the cutoff frC(jllCIIC)'
for each filter aud choosiug a window type. Note that h t[n] a nd hg[n] will be lowpass and highpas.-. fi lters,
rcspccth·ely. This is easily accounted for by sett ing W/ =
0 for li i[nj and w., =
11" for hi, [n]. Once you have
crcatC(I each filter in ?\'IATLAD, you simply need to multiply each filter by its rcspcclh·'C gain factor (which arc
tuniug parameters) a nd sum the scaled impulse respo nses together. Then, apply the filter via convolution, i.e.,
using the ~-IATLAB comnmud conv(x,b). Once processed , the rcconstmctiou proccsi-; is to be done using t he
sound() C..'O lllllland in MATLAB so that you can listen to t he results of applyiug your filter.
To design your equalizer perform the fo\lowiug design tasks:

1. Determine the upper and lower analog cutoff frequencies for each bandpass filter iu radiaus per second
using Figure 2 as a guide. Use J..,;,. = 22.5Hz aud f,,uu = 22050Hz. Create and fill out the fo\lowiug
table in your project submission:

nd) n,. (radians/sccoud)


/1111

Ilg n

2. ~lnp each upper and lower analog cutoff frequency to a digital frequency using a sampling rate of
J. = 44 IOOHz. Create and fill out the followiug table in your project submission:
I Filter I W/ (racliruL<i/sample) I w1, (radim1s/ s11.mple) j
"•"

3. Later in t he project you will choose a gain 111, for each filt er and corrcspouding windowing function
that I\C.lj1L<itl-i the aud io signal to your liking. Create a table iu yonr document sitnilar to that below that
specifics the filt er gain factor and windowing fuuction you selected for each filter in your equalizer. Also,
provide the mlucs in dB (i.e., ii.1, = 20logrn(t1 1,) dB).

I Filter II Gain (V / V) I Gain (dB) I Windowing Function I


'1 1 n

" tj11
3 Implementation and Analysis:
In this sect ion y:c will implement , apply, and tune our filter bank using digital audio data. Download the
audio files Undone-Clip.wav included with the project (you arc welcome to 1L-;c your own a udio file so long as it
ha.-c I\ sampling rate of 44. lkHz) . In yonr submitted document create au Implementation and Aualysis scctiou
and include all requested figures thnt you generate along with your ti.'IATLAB cod e pasted nt the end of your
document.
I. Use the digital cutoff frequencies calcnlatcd above to create each impulse rcspousc using the bpv function ,
sck ctiug a windowing fnnctiou of yo ur choosing for each filter. Select a gaiu rnluc of yo nr choa;ing for
each filter. Now, multiply each impulse rcspousc by its rcspccth'C filter gaiu and sum t hem together to
obtain the total impulse rt'!,JlOIISC h[11].
2. Rend iu the provided nndio file using the audioread command. Convolve the audio file with t he totnl
impuL'lC response computed in 3.1. Listen to t he reimlt using the sound command. Now, tune the gain
parameters uuti l you find a set of values that you like best.
3. Rccrente li 4 [n] using both a rectangular nnd Dlnckmau window by making use of the digital cutoff fre-
quencies you calculated nbove for /14 [11]. Plot the impulse response for 1!4 [11] for both windowing fuu d iOIL"·
Use the stem commnnd and plot them on two separate subplots. Include this plot as Figure L
4. Next , plot the mag11it ude of t he frequency rC!-iponsc IH4 (ci"')I using the rectangular and Blackman windows
on the same plot. Use 4000 points iu the fft. I would nlso suggest yon zoom your plot to best sec t he
details of the filters using the axis command, e.g. , axis([ - .5 .5 0 1.21) or whatever range best displnys
your filters. Use digital frequency (radians/ sample) for t he frequency scale, i.e., {- 1r, 1r]. Include this plot
as Figure 2.
5. Using the gain values you selected above, plot the magnitude frequeucy response for ench individual filter ,
i.e., 1Hdc1 "') 1fork = 1, 2.... ,8 (agaiu use N = 4096 points iu each fft). You should plot nit eight filter
magnitude rcspouscs 011 the same plot. Plot these RS a funct ion of Hertz rather than digitnl frequency
(/ = /. (:f,.)) nm! tL'iC a logarithmic scale for the x-axis. To do this, instead of IL'>ing the plot command.
use the semilogx conunand. Note t hat when IL'iing n log scale you should ouly plot the po-;itive half of
the frequency response, i.e., / E (o,!,: ). lnclnde this plot as Figure 3.
6. Now, repeat the previous step for the total system magnitude frcc1ueucy respmLw IH (e'"')I a nd include
this tC!-iult as Figure 4.
7. Plot 21XXl samples of the input and output nudio scc1ueuce, x[n] and y[n], ou the same plot. I suggest
you use the plot oomm11.nd rather thau the stem commaud in t his case. I also suggestion you offset
by HXX.l samples into the signal to avoid the border effects at the beginning of the output signal (e.g.,
x(1001: 3000)). Include this plot as Figure 5.
8. Plot the frequency spectrum of the input and output audio signal'>, IX(ci'"')I llll{I IY(ci'"') I, on two separate
subplots 1\gaiu IL'ii ng a logarithmic frequency scale (Hertz) for the x-axis. l11 this case, do not specify N
for the fft so t hat it will set N equal to the lengt h of the sequence (note that yon will have t o recreate
the frequency vector based upon t he 1111111bc r of samples iu the FFT of each signal). Include these plots
a.,; Figure 6.

9. Now, recreate t he equalizer 11 [11] by sek-cting a Dlnc kmnu wiudow for nil 8 filten; IL'i iug gain values
[4 3 2 I I 2 3 4] for h i[n] through h~[n), respectively. Now, recreate /1 [11] by selecting n Kaiser wiu-
dow for all 8 fil tel'8 using gain values of [3 I 3 I 3 131]. For each filter, plot the total magnitude response
H(c 1"'), similar Step 6 above. lnclude these plots as Figure 7.

4 Questions:
Create a section entitled RC!-iults and DL-.c1L<ssion and m1swcr the followiug questions , making use of the design
results from Section 2 aud the implementation experience and figures generated in Section 3.
l. Explain your decision for choosing the gain values and windowing fuu ctiow; that yo u felt were most
interesting.

2. Regarding Figure l , discuss the similarities and differences you o~rvc wheu eompariug the impulse
responses for 11 4[11] 1L-.ing the rectangular and Blackman windows.

3. CompMe the filter magnitude responses in Figure 2. Discuss the differences you observe between the two
filters and explain how they each compare to an ideal bandpass filter.

4. Regarding Figure 3 , explain the characteristics you o~rve with each individual filter's magnitude re--
spomie. DOC!! each filter passband appear to be nearly the same width on a logarithmic scale per our
design guidelines? Explain.

5. Compare the total system magnitude response of Figure 4 to the individual filt er magnitude responses of
Figure 3, uotiug anythi ng interesting.

6. While I did not ask you to generaW phru;c rci;pousc plots for each filter , what would you expect of the
phase response based upon each filter 's characteristics'! \Vhat docs this mean"!

7. Regarding Figure 5, explain any differences that you ohierve between the input and output audio signals,
and particularly relate it to the shape of the total frequency response and the gains you selected .

8. In regards to Figure 6, based upon your chosen hand gains , doClS the output signal indicate that these
gains have been properly applied within their respective frequency bands? Explain.

9. In regards to the total system magnitude responses generatcd for Figure 7, do they appear to have the
expected shape based upon the specificd gains? \\That effect do the different windowing functions have on
their shape"! \Vhile our application was tailorcd to an audio equalizer , how might such au approach be
useful in general?

IO. Since you worked to adjm;t your equalizer to your own listening preferences, spend some time reflecting
more deeply upon how differences in cultural and globaJ backgrow1d may influence this process for our
audio equalizer application. In what ways do you think tw1iug will vary across classmates within the same
aud acra&'i different cultural backgrounds"!

You might also like