Sei sulla pagina 1di 4

Chapter 2 MATLAB EXERCISE

Windowing Functions for the FFT


Fourier theory tells us that any periodic waveform can be formulated as an infinite sum of its
frequency components. This theory is put into practice with the Fourier transform, a mathematical
operation that transforms audio data from the time to the frequency domain. For discrete data like
a digitized audio signal, the discrete Fourier transform is applied. Once in data are in the frequency
domain, a frequency spectrum can be generated which shows the magnitude of each of the
frequency components. Figure 1 shows a single-frequency sound in Adobe Audition. The
frequency spectrum is on the left, and the time domain audio signal is on the right. The spike in the
frequency spectrum corresponds to a dominant presence of a frequency of 880 Hz in this waveform.

The Fast Fourier Transform (FFT) is an efficient implementation of the discrete Fourier transform
that is basic operation in audio processing systems. The FFT is applied on relatively small windows
of contiguous audio samples. For the FFT, the size of the window is a power of 2, typically on the
order of 2048 or 4096 audio samples. The relatively small window size focuses the transform on a
short segment of time in order to determine what the frequency components are in that period.
Figure 2 shows the choices of FFT window size in Adobe Audition, ranging from 32 to 65536.

Digital Sound & Music MATLAB EXERCISE


Windowing Functions for the FFT Page 1
This material is based on work supported by the National Science Foundation under CCLI Grant DUE 0717743, Jennifer Burg PI, Jason Romney, Co-PI.
Figure 1

Digital Sound & Music MATLAB EXERCISE


Windowing Functions for the FFT Page 2
This material is based on work supported by the National Science Foundation under CCLI Grant DUE 0717743, Jennifer Burg PI, Jason Romney, Co-PI.
Figure 2

When the FFT is applied, it is implicitly being assumed that the windowed audio segment is
periodic – that is, that the window contains an integral number of cycles of a repeating pattern. If
this were actually the case, then the amplitude of the audio sample at the end of each window
would match up with the one at the beginning. But this rarely is this true. If you were to attach the
end of the window to the beginning, there would likely be sudden a jump from one level to another,
as shown in the figure below. This manifests itself in the output of the Fourier transform as the
detection of a frequency components that aren't really there – called spurious frequencies. You
can see the presence of spurious frequencies, called spectral leakage, in Figure 1. Although there
really is just one frequency in the time domain audio signal, the FFT indicates a small amount of
other frequencies all across the audible spectrum.

Digital Sound & Music MATLAB EXERCISE


Windowing Functions for the FFT Page 3
This material is based on work supported by the National Science Foundation under CCLI Grant DUE 0717743, Jennifer Burg PI, Jason Romney, Co-PI.
Windowing functions are used to mitigate this effect. Windowing functions effectively taper the
amplitudes of the audio segments at the ends of the FFT windows, helping to eliminate the spurious
frequencies from the results of the FFT.

Four commonly-used windowing functions are given in the table below. Windowing functions are
easy to apply. The segment of audio data being transformed is simply multiplied by the windowing
function before the transform is applied.

( ) [ ( )]
( ) { }

triangular windowing function Hanning windowing function

( ) ( ) ( ) ( ) ( )

Hamming windowing function Blackman windowing function

t is time.

T is length of period. If w is window size and sr is sampling rate, then

Figure 3 Four commonly used windowing functions

Application of Windowing functions with the FFT is illustrated in the Chapter 2 of the book
associated with this exercise. Using that example, your assignment is to compare the results of the
four window functions of a windowed segment of music that you read in from a WAV file. You can
use the WAV file stored with this exercise if you like.

Digital Sound & Music MATLAB EXERCISE


Windowing Functions for the FFT Page 4
This material is based on work supported by the National Science Foundation under CCLI Grant DUE 0717743, Jennifer Burg PI, Jason Romney, Co-PI.

Potrebbero piacerti anche