ELEC 484 Assignment 2
Design and implementation of wah-wah filter.
A wah-way effect is created by a bandpass filter with variable center
frequency and small bandwidth. The center frequency is controlled by a
low frequency oscillator (LFO) with frequency around 1-2 Hz, or can be
controlled by an external control input device such as a mouse or
slider. The center frequency varies from near 0 to a frequency less
than half the sampling rate. The output of the bandpass filter is
added to the direct (input) signal.
In this assignment you will study a 2-pole 2-zero bandpass filter in
detail, and then use it to add a wah-wah effect to an audio file.
Phase 1
You are asked to design a bandpass filter, test the filter
characteristics, and document your results.
Realistic specifications for the bandpass filter
to be used to create a wah-wah effect are
- sampling rate f_s = 44,100 Hz
- center frequency f_1 = 44,100/64 = 689 Hz.
- 3dB bandwidth B = 100 Hz
- using 2 poles and 2 zeros.
Alternate specifications which result in much simpler
algebra are
- sampling rate f_s = 8,000 Hz
- center frequency f_1 = 2,000 Hz.
- 3dB bandwidth B = 100 Hz
- using 2 poles and 2 zeros.
It is recommended to use the alternate specifications for this
assignment in order to learn about the filter with minimal algebra, and
recognize how the realistic filter results in much more messy algebra.
You can use any general purpose software that you like, such as C,
Fortran, Matlab, Maple, and spreadsheets or anything else you have.
1. Design the filter and specify the transfer function H(z).
Scale the filter for unity gain at f_1 (bandpass).
2. An approximate formula for the 3 dB bandwidth B
of the filter as a function of the magnitude |a| of the poles
(distance of pole from origin) is deltaomega = 2*|1-a|/sqrt(a),
where deltaomega is the normalized bandwidth B in radians. This
shows that the distance of the pole from the unit circle |1-a|
controls the bandwidth. Find a numerical value for |a| such that B
= 100 Hz.
3. Plot the frequency response (both amplitude and phase) of H(z).
Check that the power response is down 3 dB at f_1 + B/2, as it
should be with the correct value of |a|. What is the phase shift at
f_1 and at f_1 + B/2? Write your own program to make this plot, and
compare the results with POI.
4. Take the IDFT (Inverse Discrete Fourier Transform) of the sampled
frequency response to obtain the impulse response h(n). Do this
manually with your own program, and with a Matlab, spreadsheet or
other standard FFT routine. Use N = 1024. What is the frequency
resolution ?
5. Find the difference equations by analysis and compare with POI.
6. Find the impulse response h(n) using the difference equations.
Obtain numerical results for h(n) for 0 < n < 25. Spreadsheets are
recommended for programming the difference equations, but other
types of computer simulation (e.g. C, Fortran) are acceptable.
Repeat using MATLAB. For what value of n is h(n) less than one
percent of it's maximum value?
7. Find the impulse response h(n) by analysis.
Take the inverse z-transform using 2 out of 3 different methods:
long division, partial fractions with first order factors, partial
fractions with quadratic factors.
8. Prepare a table with 5 columns, listing n and h(n) for the
computer simulation of part 6, the 2 analytical methods in part 7,
and the IDFT calculation of part 4, for 0 < n < 3.
9. Take the DFT of h(n) by computer (with your own program)
and show that H(r) corresponds to the frequency response obtained
in part 3. Select an appropriate FFT size to obtain a frequency
resolution of 10 Hz or less. Use zero-padding if needed.
10. Demonstrate that the filter works correctly by computer simulation
as follows: Evaluate the filter output y(n) with sinusoidal input
x(n) by using the difference equations. Use sampled cosine waves at
the center frequency f_1, repeat again at the 3 dB down frequency
f_1 + B/2. Plot the input and output on the same graph. Verify
from the graph that both the amplitude and phase of the y(n) cosine
wave output relative to the input x(n) are as predicted by H(f) in
part 3.
11. Repeat item 10 by computing the convolution of the input x(n) with
h(n), and compare the results with the difference equation method.
How many terms of h(n) are needed to get reasonable agreement?
Phase 2 (not required, for interest only)
16. Find the impulse response h(n) by taking
the inverse z-transform of H(z) using the inversion integral. Do
the integral by two different methods, contour integration along a
path, and residues. Obtain results for 0 < n < 3.
17. Find the impulse response h(n) using a Laurent series expansion
of H(z). Find the radius of convergence of the Laurent series
using both the ratio test and the root test.
18. Expand the table in part 7. above by adding 3 new columns, and
show that the answers of parts 16 and 17 are equivalent to those
obtained in Phase 1 for 0 < n < 3.
Phase 3
Use your bandpass filter to add a wah-wah effect to an
audio file consisting of white noise, and compare to the result
using the wah-wah effect built into Audacity.
Note
POI may contain a bug, showing index n instead of n-1 etc
General
Title all graphs, label the axes, and include a scale with proper
units. It is suggested (but not mandatory) that the final report is in
pdf format.