next up previous
Next: A Crash Course in Up: notes Previous: Comparing Sounds

MATLAB and Fourier Transform

Last semester we used the fast Fourier Transform algorithm in MATLAB to investigate data sets. We want to do this now as well. We will compare the power spectra of our sound files and investigate, whether or not this leads to a better method of recognizing sounds. To start we compute the Fourier transforms of the two vectors y1 and y2 we already looked at.

z1=fft(y1);
N1=length(y1);
p1=abs(y1).^2;
plot(p1(1:N1/2);
This sequence should provide you with the graph of the power spectrum of the sound y1. Recall, that the vector p1 is symmetric about N1/2 (why?), and that is why we only plot the first half of this vector. Answer the following questions about this graph:
  1. Qualitatively describe the graph of p1.
  2. Will truncating the length of this graph qualitatively change it?
  3. Compare your graph with the graph of your team partner. Describe the similarities and the differences.
  4. Now repeat this process and answer the above questions for your vector y2.
  5. The power spectra p1 and p2 are of different length, which make a direct comparison impossible. Recall, that we can only compare two vectors, if they have the same length. Is there a simple way two remedy this problem?
  6. Based on your experience with the graphs of y1, y2, p1 and p2, does comparison of the spectra seem more or less promising that comparison of the actual graphs.

Finally, we will directly compare the two spectra. To do this let N be the smaller of the length of y1 and y2, and type

plot(p1(1:N/2)-p2(1:N/2));
  1. N/2 is always an integer, why?
  2. Is the last graph ``small'' compared with the graphs of p1 and p2?
  3. ``Small'' is a rather objective term. How would you make that term more precise, i.e. how can you measure p1-p2.

One way of measuring the distance between the spectra is to use the norm. Consider the following three procedures:

  1. N1=max(abs(p1(1:N/2)-p2(1:N/2)));
    
  2. N2=max(abs(y1(1:N/2)-y2(1:N/2)));
    
  3. N3=sqrt(sum(abs(y1-y2).^2));
    
Which of these procedures give a norm of the difference of the spectra? Which one don't give a norm? Compare these with the theoretical norms we computed above. Compute N1, N2, and N3. Which of the numbers is the smallest which is the biggest. Is any of these numbers small?


next up previous
Next: A Crash Course in Up: notes Previous: Comparing Sounds
Werner Horn 2006-06-06