PlaygroundSignals · 04
Aliasing
Samples per second
Hear
What's going on
A computer records sound by measuring it many thousands of times a second, much like a film records motion as a series of photos. If the sound changes too fast between two measurements, the computer is fooled into seeing something slower.
You know the effect from films, where fast wagon wheels seem to spin slowly backwards. In sound, a tone higher than half the measuring rate comes back as a different, lower tone. To capture a vibration you need at least two measurements per cycle. People hear up to about 20,000 vibrations a second, so recording everything we can hear takes more than 40,000 measurements a second; a CD uses 44,100, leaving a little room for the filter that removes anything higher. A phone call uses only 8,000, which is why voices sound thin on the phone. The first setting here is an unrealistically slow 2,000 a second, so the effect happens at comfortable pitches; it works the same way at any rate.
Why it matters: every digital audio device has to deal with this, usually with a filter that removes too-high sounds before recording. Any model that works on recorded audio inherits the same limits.
The maths behind itFor the curious · formulas and details
Sampling at a rate fs keeps the values x(n / fs). A sine at f and a sine at f − k·fs take exactly the same values at those instants, so after playback you hear the one closest to zero:
f_heard = | f − k · f_s | k = the nearest whole number to f / f_s
The Nyquist–Shannon sampling theorem states that a signal with no frequencies at or above fs/2 (the Nyquist frequency) is determined exactly by its samples, and can be rebuilt with sinc interpolation. Anything above folds back into [0, fs/2].
The 44.1 kHz of the CD puts the Nyquist frequency at 22.05 kHz, leaving room above 20 kHz for the anti-aliasing filter to fall off before the folding point.