Description
Part I
In this homework, you will analyze a portion of Handel’s Messiah with time-frequency analysis.
To get started, you can use the following commands (note that Handel is so highly regarded, that
MATLAB has a portion of his music already in MATLAB! I’m sure they’ll add some Beyonce and
T-Swift at some point, but you’ll have to suffer Handel for now):
load handel
v = y’;
plot((1:length(v))/Fs,v);
xlabel(‘Time [sec]’);
ylabel(‘Amplitude’);
title(‘Signal of Interest, v(n)’);
This code plots the portion of music you will analyze. To play this back in MATLAB, you can use
the following commands:
p8 = audioplayer(v,Fs);
playblocking(p8);
This homework is rather open ended in the sense that I want you to explore the timefrequency signature of this 9 second piece of classic work.
Things you should think about
doing:
1. Through use of the G´abor filtering we used in class, produce spectrograms of the piece of work.
2. Explore the window width of the G´abor transform and how it effects the spectrogram.
3. Explore the spectrogram and the idea of oversampling (i.e. using very small translations of
the G´abor window) versus potential undersampling (i.e. using very course/large translations
of the G´abor window).
4. Use different G´abor windows. Perhaps you can start with the Gaussian window, and look to
see how the results are affected with the Mexican hat wavelet and a step-function (Shannon)
window.
Don’t be cheap on time here, i.e. don’t be lame. This is an opportunity for you to have a creative
and open ended experience with MATLAB and data analysis. Please do a nice job writing things up
and labeling your resulting plots. I believe this homework can be a really engaging and educational
experience if you devote some time to it.
Part II
Download the two files music1.wav and music2wav that were included with the homework.
These files play the song Mary had a little lamb on both the recorder and piano. These are .wav files
I generated using my iPhone. To import and convert them, use the following commands for both
pieces (NOTE: basically both pieces are converted to a vector representing the music, thus you can
easily edit the music by modifying the vector).
Figure 1: Music scale along with frequency of each note in Hz
[y,Fs] = audioread(‘music1.wav’);
tr_piano=length(y)/Fs; % record time in seconds
plot((1:length(y))/Fs,y);
xlabel(‘Time [sec]’); ylabel(‘Amplitude’);
title(‘Mary had a little lamb (piano)’);
p8 = audioplayer(y,Fs); playblocking(p8);
figure(2)
[y,Fs] = audioread(‘music2.wav’);
tr_rec=length(y)/Fs; % record time in seconds
plot((1:length(y))/Fs,y);
xlabel(‘Time [sec]’); ylabel(‘Amplitude’);
title(‘Mary had a little lamb (recorder)’);
p8 = audioplayer(y,Fs); playblocking(p8);
1. Through use of the G´abor filtering we used in class, reproduce the music score for this simple
piece. See Fig. 1 which has the music scale in Hertz. (note: to get a good clean score, you
may want to filter out overtones… see below).
2. What is the difference between a recorder and piano? Can you see the difference in the timefrequency analysis? Note that many people talk about the difference of instruments being
related to the timbre of an instrument. The timbre is related to the overtones generated by
the instrument for a center frequency. Thus if you are playing a note at frequency ω0, an
instrument will generate overtones at 2ω0, 3ω0, · · · and so forth.