Project1

 

Project 1:Music Transcription System

Part I: Windows

There are many types of windows proposed for use in spectral analysis and
filter design. This project starts by looking at different types of windows and
evaluating their frequency response. The DTFT of a window is computed in
Matlab using a zero-padded FFT with a length of at least 4 to 5 times
longer than the window. The matlab code for this is:

>N=32; % this is your window length
>w=hamming(N); % this built-in function generates a Hamming 
window of length N
>W=fft(w,N*5); % Computes a zero padded FFT of length 5*N
>WdB=db(W,80);% scales the spectrum to a maximum amplitude of 1, then converts
              % to decibels with a minimum value of -80 dB
>plot((0:1:5*N-1)/(5*N-1),WdB); % plots the data
>xlabel('Normalized frequency, fs=1');ylabel('Magnitude');
      
Resolution (mainlobe width) -increasing the window length inproves
resolution by decreasing the mainlobe width
Verify this for the rectangular, Hamming and Kaiser windows
(use beta= 3) for L=16 and 32. Measure the mainlobe widths,
how do they compare with the rectangular window.
Verify your results for two signals with digital frequencies of 0.2
and 0.25 radians. How many samples do you need for each
window type to clearly show two peaks in the spectrum.
Sidelobe height - Low sidelobes help to minimize leakage.
Graphically determine the maximum sidelobe height for the
Hamming, Hann and Blackman window. Does the sidelobe height
depend on L, the window length?
In Kaiser windows the parameter, beta, can be used to change
the sidelobe height and the mainlobe width. Plot the Kaiser
window for several cases and verify the formula that says that
sidelobe height is proportional to beta/(sinh(beta))
Peak Finding: We will need an automatic method for finding peaks
in the data. The easiest way to do this to take the discrete derivative
and find zero crossings. You also need to search for harmonics of the
actual frequencies.  Here is one of my old routines,peakill, given here with
no warranty implied or otherwise.,
Part II: Music Analysis

FOR SGI USERS: The main software for playing music files is in the
locker: /lockers/EE524/HW3/musiclab. If you have downloaded
the GUI file on the SGIs please delete it since it takes up alot of space.
To access this directory, run the command:

>path(path,'/lockers/EE524/HW3/musiclab');

This adds this locker to the matlab path. All wave files are also in this
directory. These files allow you to listen to a music file and see the notes,
this should help you with your testing.

FOR PC USERS: download the zip archive music.zip

1. Input the sound file: You will use .wav files for testing. Most of the
files are sampled at fs=11025 Hz. You need to at least pull out the
notes and timing from the C scales. To read in a sound file in Matlab
use the command:

>[s,fs]=wavread('filename.wav');% reads in a wave file 
and its sampling rate
>sound(s,fs); % plays the sound, s
>musicgui % starts up the musical interface so that you can see
 the notes
      
2. Take some spectrograms of the signal, X[k,n] using equation 11.20 in 
the textbook. The spectrogram is the result of a sliding window dft. R is 
the length of the window, N is the number of samples in the DFT. Overlap 
is the number of samples overlap. Take both a narrowband and a wideband 
spectrogram.
>nfft=64;% fft length
>Fs=11025;
>window=hamming(nfft);% could be any window
>noverlap=32;% this is the amount of overlap between 
successive ffts
>y=specgram(s,nfft,fs,window,noverlap);% computes the 
spectrogram  

3. Plot the spectrogram. Its magnitude can be plotted as either a gray-scale
image or you can use a contour plot. The spectrogram is two dimensional
matrix of the DFT values.

contour(abs(y),[50,40,30,20,10,8,6,5,4,3,2,1,0.5]);
% the contour values are problem dependent
or 
imagesc(abs(y));colormap('gray');%displays as image  

4. Write a peak detection algorithm to find the peaks in frequency using
an appropriate spectrogram. Make a guess at the duration of the signal.
is an example peak detection routine that works fairly quickly.   You may want
to adjust the thresholds and the levels for the harmonics. It works by
keeping the stronger frequencies. It then approximates the derivatives by taking
the difference between successive values. Use it at your own risk, there is no
warranty or guarantee and I am not a help desk for Matlab related questions.

5. Use a narrowband spectrogram to find when a signal stopped and started.

Sound files for testing:
cscal_np.wav C scale with evenly spaced notes
cminor.wav C minor scale, notes vary in length
beet5_np.wav beginning of Beethoven's fifth symphony
furel_np.wav
gmin_np.wav
jesu_np.wav
twnkl_np.wav twinkle, twinkle, little star
What you should turn in:
Results and discussion for part 1
Results and discussion for part 2- you should be able to
demonstrate that your code works for two cases
when only one note at a time plays
when multiple notes play at the same time.
Instructions on how to run your code and a description for how it works.
Illustrated case for how it works, with spectrograms and other figures.
Discuss how good your resolution is both in time and in frequency.