Digital Sound & Music: Concepts, Applications, & Science, Chapter 2, last updated 6/25/2013

46

figure;

freqs = [0:(sr/2)-1];

plot(freqs, fftmag(1:sr/2));

axis([0 sr/2 0 4500]);

title('frequency response for HornsE04Mono.wav');

Let's zoom in on frequencies up to 5000 Hz.

axis([0 5000 0 4500]);

The graph below is generated.

Figure 2.48 Frequency response for HornsE04Mono.wav

The inverse Fourier transform gives us back our original sound data in the time domain.

ynew = ifft(fftdata);

If you compare y with ynew, you'll see that the inverse Fourier transform has recaptured the

original sound data.

2.3.10 Windowing the FFT

When we applied the Fourier transform in MATLAB in Section 2.3.9, we didn't specify a

window size. Thus, we were applying the FFT to the entire piece of audio. If you listen to the

WAV file HornsE04Mono.wav, a three second clip, you'll first hear some low tubas and them

some higher trumpets. Our graph of the FFT shows frequency components up to and beyond

5000 Hz, which reflects the sounds in the three seconds. What if we do the FFT on just the first

second (44100 samples) of this WAV file, as follows? The resulting frequency components are

shown in Figure 2.49.

y = wavread('HornsE04Mono.wav');

sr = 44100;

freqs = [0:(sr/2)-1];

ybegin = y(1:44100);