ECE 437/436 DIGITAL SIGNAL PROCESSING
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
ECE 437/436 DIGITAL SIGNAL PROCESSING
Computer Project:
Ground Rules and Instructions for Submission
You must write your own programs, run your own simulations, and analyze and interpret your results. Submit the report electronically in PDF format. PLEASE DO NOT SUBMIT A ZIP FILE - submit each file individually to the blackboard. Document any theoretical/analytical preparation you did (or simply refer to specific material in the textbook/lecture) as part of your design of your computer programs.
Present your results, in a form of a project report with LESS THAN 10 PAGES, compactly, clearly, and selectively. A report “stuffed” with redundant material will not qualify for a high grade. In addition to your report, submit all the programs you have written for the project, in one, separate, plain-text file, to course web site on blackboard.iit.edu. Include your computer programs with your report at the end (as an appendix) (program pages are not counted towards the 10 page maximum).
You may discuss the project with your classmates, but your effort must be essentially independent. Verification of independent effort will be performed, and plagiarism will be treated as academic dishonesty.
Figures (preferred) and/or tables should be numbered consecutively (Figure 1, Figure 2, etc.). The text of your report should refer to figures and tables, before they appear in the document, by number. For example: “The frequency response of the filter is shown in Figure 3. One can see … .”.
Any figure or table without reference in the report text will be ignored, and the grade will be determined as if they were not there.
Each figure and table must have a caption. Each figure should include properly labeled axes (both).
Please use meaningful and illustrative plots. In some cases, you may want to zoom-in to a relevant detail. As necessary, consider also zooming-out, plotting multiple signals in one plot, plotting a difference between the 2 similar signals when comparing different cases etc.
Note that in some cases you may have to adjust the MATLAB axes to plot the entire signal (not just zoomed- in portion of it).
ANSWER ALL QUESTIONS I EXPLICITLY ASKED!
Objectives
The major goals of this computer project, using MATLAB (or GNU Octave), are:
Part I
1. Implementation of an FIR filter
2. Calculate response of the filter to a signal by calling the function fir()
Part II
1. Calculate system response to a signal (using impz)
2. Calculate system response by convolution via conv
3. Calculate system response using discrete Fourier transform (DFT) using fft and ifft.
4. Compare and discuss the differences/limitations of different MATLAB functions (impz, fft ,conv)
Problems:
Part I
Write a function that implements an FIR LTI system given by:
M
k=0
The code can be in Matlab/Octave. IMPORTANT: When using MATLAB/Octave, for this part - you may only use for/while loops and addition/multiplication on individual elements of the array. In Part I - using built-in MATLAB/Octave functions or syntax that operates on the entire array at once (such as using statements: w=w(2:N), or: y=x .* b ) is not allowed and will count as zero points! E.g. if you want to copy elements of
the array, you must use a “for-loop” or a “while-loop” and access individual elements of the array that you are trying to copy. While MATLAB is a good simulation tool, in most cases, MATLAB is not used in practice in real-time applications or devices. This exercise is meant to get your code as close to a practical real-time implementation of an fir filter as possible.
While MATLAB is a good simulation tool, in most cases, MATLAB is not used in practice in real-time applications or devices. This exercise is meant to code-up a filter close to a practical real-time implementation of an FIR filter.
A MATLAB program “Project_Part1_2022.m”is provided to you. This program reads a set of FIR coefficients stored in array called “b” and saved in a “filterCoefficients.mat” file. The program then loads an audio-signal “HarvardSentences_RoomNoise.wav” sampled at rate Fs=48000Hz and calls the function “firFilt” (that you will write) one sample-at-a-time. Each time the function is called, one SINGLE input-data sample x(n) of the audio-file is provided to the function representing the fir-filter. You must not modify “Project_Part1_2022.m” and your function must work with Project_Part1_2022.m as is.
The function “firFilt” takes ONE input sample x(n) as its sole input and returns ONE output sample y(n) as its sole output, i.e. and has the following MATLAB definition:
function y_n = firFilt(x_n)
global b M filter_state ;
% CONTINUE IMPLEMENTING THE FIR FILTER ...
Array b = [b0, b1, b2, b3, ..bM] contains the coefficients of the filter.
Array “filter_state” is the array that stores the “internal state” of the filter i.e. it is used to store the previous values of the input signal.
Assume zero-initial conditions.
Although M=289 in this particular case, you should write your function so that it works for arbitrary filter order M. I might apply different filter coefficients to test your code.
For debugging purposes, you can verify the correct operation of the function by comparing your output to the output of the MATLAB built-in “filter(b,a,..)” function. NOTE: Style of your Matlab programming is irrelevant as long as the solution is correct.
In your report, submit the printout of the function. Also, submit the “FilteredSignal_Part1.wav” i.e. the audio file that is the result of filtering.
Useful MATLAB functions (use MATLAB help for detailed descriptions):
freqz, impz, zplane, fft, ifft, conv, filter … Explore different versions of “freqz”, “impz” to improve your plots.
Answer the following questions (provide plots if necessary):
1) Use statement “load(‘filterCoefficients.mat’); “ and then analyze the filter represented by array “b” . Use freqz MATLAB commands to display the frequency response (vs. frequency) of the FIR filter whose coefficients are given by array “b” . Zoom-in the figures to get better details …
2) What kind of filter is this? (bandpass/lowpass/highpass?)
3) What analog frequency/frequencies will this filter amplify/attenuate/pass thru? Explain / How/Why ?
4) What is the cutoff frequency of the filter (approximately corresponds to the -3dB attenuation). Use freqz matlab-plot to find out – you may need to zoom-in)
5) What kind of attenuation/gain does the filter apply to a discretized sinusoid with analog frequency 10kHz sampled at 48Khz?
6) Comment on the phase-response of the filter? Is it linear? Why do you think that is?
NOTE: Use (good-quality) headphones (you won’t notice the difference otherwise) to carefully listen to “HarvardSentences_RoomNoise.wav” and the filtered “FilteredSignal_Part1.wav” . This is an example of using an EQ filter to improve the quality of audio and suppress “room” ambient noise (boomy “rumble” sound in the background of the first audio file). The difference is subtle.
Part II)
From class, we know that the output of an LTI can be obtained as:
y(n) = Z- 1 {H(z) ×X(z)} , z ÎROC ,
Also, using the convolution sum:
y(n) = å x(k)h(n - k) ,
=-¥
(1)
(2)
Or, y(n) can be calculated using (Inverse) Discrete Fourier transform:
yp (n) = IDFT {DFT (x(n)) ×DFT (h(n))} = å(¥) y(n - l ×K) , (3)
=-¥
where DFT is K-point discrete Fourier transform (DFT) (and with the assumption of periodicity of the sequences with period K).
For the following input signal (given by its Z-transform):
X(z) = 1一 a(1)z 一1 , ROC: |z|>|a|
Where a= - 0.95
The system is given by its’ system function:
,
1 − r coS (业0)z一1
H(z) = R0C: |z| > r
The methods may, therefore, not be producing the same/correct result or may be producing the same/correct result for only some samples. E.g. in the case of convolution we can only do the finite summation of truncated signals and in the case of DFT we are not only truncating, but implicitly assuming periodic signals. In this computer exercise observe and comment how changes in the truncation length of calculated x(n)and h(n) (e.g. experiment with truncating to N=32, 64, 128 samples) changes the calculated output.
Also, explore how zero-padding in the case of fft/ifft computation of convolution changes the result! First truncate the signal(s) h(n) and x(n) to N samples, and then zero-pad to create K-sample long signal (part of which is zeros). Use the K-point convolution/ DFT where K≥N (Use K=N, 1.5N and 2N). Is there a K where both conv and fft/ifft provide the same result? Why?
Questions:
- Which of the 3 Matlab method(s) produce the result closest to the actual y(n)?
- What kind of filter does H(z) represent (low-pass, high-pass or band-pass). What is the filter cutoff frequency (if low/high-pass) or center frequency (if band-pass)? If necessary, use the MATLAB “freqz” function to estimate.
- If you truncate both h(n) and x(n) to length of N samples (call them hN (n), XN(n) respectively), what part of convolution of truncated signals hN (n) ∗ XN(n) matches the actual y(n)?
- If you truncate h(n) to length N, and truncate x(n) to length M (call them hN (n), XM(n) respectively) what part of convolution of truncated signals hN (n) ∗ XM(n) matches the actual y(n)?
- If you truncate h(n) to length N and truncate x(n) to length M (call them hN (n), XM(n) respectively) and use fft/ifft of length K, what is the minimum length K to produce the same result as time-domain convolution hN (n) ∗ XM(n)
2022-12-11