$35
In this assignment, you will recover harmonics from data and apply DFT to audio ?les. This is the last assignment for
this semester. I initially thought of splitting it into two weekly assignments but then decided against it and combined
them into one assignment due in two weeks. I hope this works out better for all of us.
Figure 1: Sample coe?cient vs. frequency plots; sine coe?cients vs. frequecy (left); cosine coe?cients vs. frequency
(right)
Problem 1
The zip archive for this assignment contains data.txt with 6,284 real numbers generate by some function unknown to
you. Apply the harmonic recovery analysis to it to recover the harmonics in the frequency range from 0 to 150 and plot
1
their coe?cients. The plots in Figure 1 show two sample plots. Note that the plots are not the plots for this problem.
They are just examples. Your plots will have a similar appearance but di?erent values. For example, suppose that you
have recovered the values of a0, a10, b10, a40, and b40, i.e., the 0-th, 10-th, and 40-th harmonics are present. Here is a
sample output that your code may produce.
a0 = 1.784
a10 = 0.56996
b10 = 1.898
a40 = 29.18
b40 = 7.9209
To do harmonic recovery, you will need a threshold to determine if the sine or cosine coe?cient of a harmonic is
present. I implemented my solution in Octave and used a threshold of 0.03.
Problem 2
In this problem, you will perform the DFT analysis of musical audio ?les. The zip archive contains three audio ?les:
ODE_TO_JOY_RIGHT_HAND.wav, ODE_TO_JOY_BOTH_HANDS.wav, and ODE_TO_JOY_ORCHESTRA.wav. All three ?les record
the famous segment from Beethoven's Ode to Joy. The ?le ODE_TO_JOY_RIGHT_HAND.wav records me playing the notes
on my piano with my right hand. The ?le ODE_TO_JOY_BOTH_HANDS.wav records me playing the same segment with both
hands. Finally, the ?le ODE_TO_JOY_ORCHESTRA.wav is a recording of the segment by an Austrian choir and orchestra. I
recorded these wav ?les with a ?ve-dollar microphone so there is some background noise in all three recordings. But it
is manageable. So, do the DFT analysis of the three ?les the way we did in Lecture 12. Speci?cally,
1. Plot the spectrum analysis of each audio ?le;
2. Identify the top ?ve frequencies in each audio ?le;
3. Use https://en.wikipedia.org/wiki/Piano_key_frequencies to identify the corresponding musical notes.
What To Submit
You can do this assignment in Octave, Python, or Java. If you do it in Octave, save your solution in HW08.m. If you do
it in Python, save it in HW08.py. If you do it in Java, save it in HW08.java. If you do it in Java and use third-party jars,
please submit them along with your HW08.java. In your source ?le, de?ne the function/method problem_01() with your
source code for Problem 1 and the function/method problem_02() with your source code for Problem 2.
Enjoy!
2