Aliasing demo

These pages aim at illustrating the aliasing phenomenon using audio signals.

1. Synthetic signal

The initial sound is a numerically synthetized piano La-tone at 440Hz. The sampling frequency is of 44.1kHz (CD-quality).

The spectrum of the first moment of this tone is presented below (in linear scales on the left, logarithmic scale on the right). The harmonic frequencies at multiple of the fundamental tone (440Hz) are clearly visible. The various music instruments are characterised by the relative amplitude of the harmonics.

The sound will be resampled at 2kHz, the new sampling frequency being represented by the black line. The green line represents the Nyquist frequency and the red curve represents the anti-aliasing filter that should be used.

Here is the 440Hz-La resampled at 2kHz without precautions against aliasing. The tone sounds "metallic" (and at least strange). This is due to the aliasing of the frequencies that were higher than the Nyquist frequency (half the sampling frequency). The aliasing is visible on the graphs as a "warping" of the frequenties against a "mirror" at the Nyquist frequency (1kHz).

In order to avoid aliasing, the spectrum of the signal to be resampled should be zero at frequencies higher than the Nyquist frequency. A low-pass filter is used to achieve this (see red curve in the two first graphs). The resulting downsampled signal sounds much more convincing, as it doesn't suffer of frequency aliasing as is obvious from the graphs.

2. Real-world music signal

The same treatment was performed on a real music signal originally having a sampling frequency of 44.1kHz (CD-quality). It spectrum is shown below

The at 4kHz downsampled version is awfully distorted by the aliasing.

If an anti-aliasing filter (in red in the graph above) is applied before the downsampling operation, the result altough what dimmed due to the loss of the high frequencies, is much more convincing.

3. One more remark

An attentive reader will have noticed that even the down-sampled sound files are provided at a 44.1kHz sampling rate, while the sampling rate should have been of 2kHz and 4kHz for respectively the La-tone and the real music piece.

In order to play sound sampled at low frequencies, the sound card has to perform some form of upsampling, involving most of the time a first-order interpolation. In order to avoid aliasing artefacts, a suitable low-pass filter as the one shown above should be used to only keep the blue part of the spectrum of the resampled signal (the red parts are meerly repetitions of the blue part).

It appears that the filter used in those DAC cards is not excellent and part of the remaining spectras is kept, leading to artificial sound degradations. Hence, to circumvent this problem, the upsampling at 44.1kHz was performed using a high-quality numerical filter (a 30-taps linear-phase FIR filter designed using least-squares minimization).

4. Goodies

The files used to produce these soundfiles and these graphs are made available below. and the sound-files
This page was last modified by xne.