Nyquist-Shannon Theorem¶
According to the Nyquist-Shannon Theorem, the bandwith (the maximum frequency) of a signal must be lower than half of the sample rate $f_s$ of a digital system to avoid aliasing.
Aliasing¶
Aliasing is an (undesired) effect in digital systems, caused by frequencies that are higher than the Nyqist frequency. Since the spectrum of a sampled signal is periodic, it must be band-limited, in order to avoid misinterpretations, known as aliasing. Since the spectrum is periodic with $\omega_s$, the maximum frequency which can be represented - the Nyquist frequency - is:
$$f_N = \frac{f_s}{2}$$
As soon as components of a digitally sampled signal exceed this boundary, aliases occur.
The Wagon-Wheel Effect¶
One of the most popular examples for aliasing and mirror frequenies is the so-called wagon-wheel effect. Sine even analog film works with a frame-rate, it has a Nyquist frequency. When wheels are filmed at certain frequencies, they are too fast for the camera to capture the rotation. When the rotation frequency hits the Nyquist frequency, the wheel stands still. When it surpasses it, it starts turning backwards.
Aliasing Frequency for a Sinusoid¶
For a pure sinusoids with the frequency $f$, aliasing results in a sinusoid at the mirror frequency $f_m$:
$$f_m = \Big| f - f_s \Big\lfloor \frac{f}{f_s} \Big\rfloor \Big|$$
With $\lfloor x \rfloor$ as round to next integer.
At a sampling rate $f_s = 1000 \ \mathrm{Hz}$ and a Nyquist frequency $f_N = 500 \ \mathrm{Hz}$, a sinusoid with $f = 900 \ \mathrm{Hz}$ will be interpreted as one with $f = 100 \ \mathrm{Hz}$:
Aliasing for Signals with Overtones¶
For signals with overtones, undersampling leads to inharmonic alisases and happen before the fundamental itself exceeds the Nyquist frequency. For a harmonic signal with a fundamental frequeny $f_0$, the alias frequencies for all $N$ harmonics can be calculated:
$$f_m = \sum\limits_{n=1}^{N} \Big| n f_0 - f_s \Big\lfloor \frac{n f_0}{f_s} \Big\rfloor \Big|$$
For certain fundamental frequencies, all aliases will be located at actual multiples of the fundamental, resulting in a correct synthesis despite aliasing. This is a square wave spectrum with $f_0 = 200 \ \mathrm{Hz}$ at $f_s = 16000 \ \mathrm{Hz}$. All mirror frequencies fall into integer multiples of the fundamental frequency:
Changing the fundamental frequency of the square wave to $f_0 = 277 \ \mathrm{Hz}$, creates alising frequencies at non-integer multiples of $f_0$. The resulting spectrum shows the overlap of the original frequencies with the mirror frequencies in a pattern:
Anti-Aliasing Filter¶
In analog-to-digital conversion, anti-aliasing filters are used to band-limit the input and discard signal components above the Nyquist frequency.
The following example shows the magnitude of the frequency response for a 5th order Butterworth filter with a cutoff frequency of $f_c = 0.95 \frac{f_s}{2}$:
Band-Limited Synthesis¶
In case of digital synthesis, aliasing can occur easily. When generating a square wave signal with an infinite number of harmonics, aliasing happens instantaneoulsy and can not be removed, afterwards.
In order to avoid aliasing problems, most environments for audio signal processing and sound synthesis offer band-limited oscillators for specific waveforms. Users thus do not need to worry about this issue.