Engineering · Simulator 097
Digital systems store a signal as a list of numbers taken at regular moments. Change how fast the signal oscillates and how often it is sampled. See when the samples capture it faithfully, when a fast wave masquerades as a slow one, and how the number of bits per sample limits precision.
Sampling at rate f_s keeps only the values at times n/f_s. The Nyquist–Shannon sampling theorem says a signal containing only frequencies below f_s / 2 (the Nyquist frequency) can be rebuilt exactly from its samples by sinc interpolation:
x(t) = Σₙ x[n] · sinc(f_s t − n), sinc(u) = sin(πu) / (πu)
A frequency above f_s/2 is not lost but disguised: its samples are identical to those of a lower alias,
f_alias = | f − k f_s | for the whole number k that brings it into 0 … f_s/2
The spectrum chart shows why: sampling copies the signal's spectrum around every multiple of f_s, and only the copy inside the shaded band 0 … f_s/2 is reconstructed. Real converters therefore put an anti-aliasing filter before the sampler.
A zero-order hold (a staircase that holds each value until the next sample) is how simple converters output samples; it is not an exact reconstruction. Quantization rounds each sample to one of 2ⁿ levels; for a full-scale sine wave the signal-to-quantization-noise ratio is about 6.02 n + 1.76 dB.
Frequencies here are in hertz on a slow time scale so the waves are visible; the same rules apply to audio at kilohertz. Sinc reconstruction uses a finite stretch of samples, so it is very slightly imperfect near the edges.
CD audio samples at 44.1 kHz. What is the highest frequency it can represent? If a 30 kHz ultrasonic tone reached the converter without filtering, at what frequency would it be heard?
The Nyquist frequency is 22.05 kHz. A 30 kHz tone aliases to |30 − 44.1| = 14.1 kHz, well inside the audible range, which is why an anti-aliasing filter must remove everything above about 20 kHz before sampling. Scaled down: try 30 Hz sampled at 44.1 Hz.