Signal analysis – Fourier, sampling and the FFT

All modern measurement rests on signal analysis: a signal is recorded as a sequence of numbers, and the computer finds its frequency content, correlations and transfer functions. In the 1980s it was still new that an analyser could do an FFT in real time. The course “Signal analysis” gave the theory behind it – and the pitfalls. The page has two interactive figures: on aliasing and on windows and leakage.

DTH, course 5161 (1988), 6 points: Signal analysis (course 51), Acoustics Laboratory. The dual-channel FFT analyser from Brüel & Kjær was then the workhorse of the laboratory, also for measurements of sound in ducts as in the thesis.

Fourier

In 1807 Joseph Fourier claimed that any periodic function can be written as a sum of sine and cosine oscillations. Lagrange did not believe it, but Fourier was right – with certain mathematical reservations that took a century to sort out. For a non-periodic signal the sum becomes an integral, the Fourier transform:

$$X(f) = \int_{-\infty}^{\infty} x(t)\,e^{-j2\pi f t}\,dt,\qquad x(t) = \int_{-\infty}^{\infty} X(f)\,e^{j2\pi f t}\,df$$

The most important property for an engineer is the convolution theorem: a linear, time-invariant system acts on a signal by convolution with its impulse response $h(t)$, and in the frequency domain the convolution becomes a simple product, $Y(f) = H(f)X(f)$. That is why frequency analysis is so useful: each frequency can be treated on its own.

Sampling and aliasing

A computer can only store values of the signal at discrete times $t_n = n/f_s$. The sampling theorem – Whittaker (1915), Kotelnikov (1933), Nyquist and Shannon (1949) – says that a signal with no frequencies above $f_s/2$ can be fully reconstructed from its samples. $f_s/2$ is called the Nyquist frequency.

If the signal contains frequencies above $f_s/2$, they cannot be distinguished from lower frequencies: a frequency $f$ looks like $|f - k f_s|$ for the integer $k$ that brings it below $f_s/2$. This is aliasing, and it is the same thing that makes wagon wheels in a western seem to turn backwards. Aliasing cannot be removed once it has happened – which is why there is always an analogue low-pass filter in front of an A/D converter.

Try it: The thin blue curve is the continuous signal, the dots are samples, and the gold curve is the lowest frequency passing through the same points – what the computer “sees”. Keep $f_s = 100$ Hz and turn the signal up past 50 Hz. At 100 Hz all samples fall on the same value: the signal appears constant. At 95 Hz it looks like 5 Hz.

DFT and FFT

With $N$ samples one computes the discrete Fourier transform

$$X_k = \sum_{n=0}^{N-1} x_n\,e^{-j2\pi kn/N},\qquad k = 0,1,\dots,N-1$$

The frequency resolution is $\Delta f = f_s/N = 1/T$, the reciprocal of the measurement time. To distinguish frequencies 1 Hz apart one must measure for at least 1 s. That is the classical uncertainty relation $\Delta t\,\Delta f \geq$ constant – the same mathematics as Heisenberg’s (see From Bell’s inequality to sound intensity).

Computed directly, the DFT needs $N^2$ multiplications. In 1965 James Cooley and John Tukey published an algorithm that needs only $N\log_2 N$: the Fast Fourier Transform. For $N = 1024$ it is 100 times faster. It later turned out that Gauss had found the idea in 1805 to compute the orbits of asteroids – before Fourier. The FFT is counted among the most important algorithms of the 20th century; without it there would be no mobile phones, MRI scanners or digital audio.

Windows and leakage

The DFT assumes that the $N$ samples are one period of a periodic signal. If a whole number of periods of a tone does not fit into the measurement time, there is a jump where the signal repeats, and the tone’s energy leaks into many frequency lines. The leakage can hide weak tones next to a strong one. The remedy is to multiply the signal by a window that goes smoothly to zero at both ends. The Hanning window $w_n = \sin^2(\pi n/N)$ is standard for noise and mixed signals; the flat-top window is used when the amplitude of a tone must be read accurately; the rectangular one (no window) for transients entirely inside the measurement time.

Try it: $N = 256$ samples; frequencies are given in DFT lines (a tone at 12.5 lines does not fit the measurement time). With the rectangular window and tone 1 on a whole number of lines – say 12.0 – the spectrum is perfect. Move it to 12.5: the leakage hides tone 2, which is 50 dB weaker. Switch to Hanning. How weak can tone 2 be and still be seen?

Correlation and spectra

The cross-correlation $R_{xy}(\tau) = E[x(t)\,y(t+\tau)]$ measures how much two signals resemble each other with a time shift. It is used to find delays: how long sound takes to travel from a leak in a water pipe to two microphones, or which direction noise comes from. The Wiener–Khinchin theorem says that the Fourier transform of the autocorrelation is the power spectrum $G_{xx}(f)$, and that of the cross-correlation is the cross-spectrum $G_{xy}(f)$.

For noise signals a single spectrum is very uncertain – the standard deviation of each line is as large as the value itself. One therefore averages over many spectra; with $n$ averages the relative uncertainty falls as $1/\sqrt n$. With 50 % overlap between Hanning-windowed blocks the data are used almost fully (Welch’s method, 1967).

Frequency responses and coherence

A dual-channel analyser measures a system’s input $x$ and output $y$ simultaneously and estimates the frequency response

$$H_1(f) = \frac{G_{xy}(f)}{G_{xx}(f)},\qquad \gamma^2(f) = \frac{|G_{xy}(f)|^2}{G_{xx}(f)\,G_{yy}(f)}$$

The coherence $\gamma^2$ lies between 0 and 1 and tells how much of the output is linearly due to the input. Low coherence means noise, non-linearity or leakage – or other sources. It is one of the most useful diagnostic tools in all experimental acoustics and vibration engineering. Sound-intensity measurement with two microphones is based on the imaginary part of the cross-spectrum between them.

Try it: At the top is a dual-channel measurement: a noise generator drives a loudspeaker, and the analyser measures both the signal into the system (channel 1) and the microphone signal (channel 2). Both pass through an anti-aliasing filter and an A/D converter before the FFT. Below are the estimated frequency response $|H_1|$ and the coherence $\gamma^2$ for a system with two resonances. Turn up the background noise: the coherence drops first at the anti-resonance between the peaks, where least signal gets through – and that is exactly where $H_1$ becomes unreliable.

Time and frequency

A spectrum does not show when the frequencies occur. In 1946 Dennis Gabor proposed dividing the time–frequency plane into cells, each represented by a Gaussian-windowed oscillation – the one that minimises $\Delta t\,\Delta f$. The short-time Fourier spectrogram is the everyday tool of speech research and birdsong. Wavelets (Morlet, Grossmann and Daubechies in the 1980s) use short windows at high frequencies and long ones at low, as the ear itself does.

Since 1989

Further reading