# Signal Spectra

By Fourier theory, any waveform can be represented by a summation of a (possibly infinite) number of sinusoids, each with a particular amplitude and phase. Such a representation is referred to as the signal's spectrum (or it's frequency-domain representation). It is often easier to analyze signals and signal networks in terms of their spectral representations. As well, there are many instances where it is easier to synthesize a signal using a frequency-domain approach.

## Why is the spectral view useful?

• It is often the case that the spectrum of a signal can indicate aspects of the signal that would otherwise not be obvious by looking only at its time-domain representation.

• For example, from the time-domain plot below it is clear that the signal is periodic, with a period of about 0.02 seconds. However, few other features of the signal are immediately clear.

• The plot below shows the magnitude spectrum of the signal from Fig. 3. It is now obvious that the signal is comprised of only 5 frequency components, the magnitudes of which are inversely proportional to frequency. As implied by the time-domain periodicity, the spectral components are harmonically aligned. From further analysis, we see the 5 components fall only at odd integer multiples of the fundamental frequency.

• Frequency-domain representations are also very useful in evaluating digital filters.

• As an example, a simple digital filter has a time-domain representation of the form y[n] = x[n] + x[n-1]. It is certainly possible to gain intuition on the behavior of this filter by considering its output given various input signals in time. However, a relatively easy sequence of steps allows us to realize the filter response for all sinusoidal frequency inputs from 0 - fs / 2 as plotted below.

## How is a spectrum obtained?

• Given a discrete-time signal x[n], we can determine its frequency response using the Discrete Fourier Transform (DFT):

• The DFT determines sinusoidal weights'' via the inner product of sinusoids and the signal.

• The DFT can be interpreted as the sum of projections of x[n] onto a set of k sampled complex sinusoids or sinusoidal basis functions at (normalized) radian frequencies given by .

• In this way, the DFT and its inverse provide a recipe'' for reconstructing a given discrete-time signal in terms of sampled complex sinusoids.

• If the signal x[n] consists of N samples, X[k] will consist of k=N frequency weights (assuming no zero-padding). Based on the sampling theorem, however, only the first half of these frequency components are unique.

• The DFT coefficients are complex values. To plot the magnitude response of a signal's spectrum, we calculate the magnitude of each coefficient. For example, if a given coefficient is given by a + jb, its magnitude can be determined as . The Matlab function abs performs this calculation.

• The phase response of a signal is given by the angles'' of its complex DFT coefficients. For a coefficient given by a + jb, the phase angle is determined as . The Matlab function angle performs this calculation.

• In general, the spectra of real-world signals will not look as clean'' as the figures above. In fact, the spectrum of Fig. 4 was obtained by transforming an exact integer number of periods of the signal in Fig. 3. If we chose an arbitrary piece of the signal to transform, we would likely end up with a spectrum such as that shown below.

## The FFT

• A brute force calculation of a length N DFT requires a number of operations roughly proportional to N2. Thus, a 1024-point DFT would require about a million multiplications and about a million additions.

• Luckily, the DFT algorithm can be simplified to a form in which the required number of calculations is proportional to Now, our 1024-point DFT can be calculated with only about 10,000 operations!

• This simplified algorithm is referred to as the Fast Fourier Transform or FFT.

## Time / Frequency Resolution

• As mentioned above, a length N FFT (or DFT) computes sinusoidal weights'' for N evenly spaced frequencies between 0 and fs (N-1)/N. From the sampling theorem, only the first half of these frequency weights are unique.

• It follows that the larger the value of N, the more sinusoidal weights are computed and the smaller the spacing between frequency components. This spacing is given by fs/N.

• If analyzing a fairly static sound signal, you would thus be best off using a larger value of N to get a more precise estimate of the frequency content.

• On the other hand, if the timbre of a sound changes significantly over time, you will need to segment the sound and compute separate FFTs over each block, in order to estimate the change of the frequency content from one block to another. This may require smaller values of N, in order to isolate changes over time.

• When computing FFTs over time (blocks), the resulting data can be displayed in terms of a waterfall plot (separate spectra slightly offset from one another) or as a spectrogram (a 2D time vs. frequency plot where spectral magnitudes are displayed using color maps).