Signal Sampling & Nyquist Theorem

Set a signal frequency and sampling rate to see whether the signal is faithfully captured or aliased.

Loading interactive simulation...

Two different frequencies can leave identical samples behind 🖖

Sampling works only when the sample rate captures the fastest oscillation content. If fs < 2 fsignal, different continuous frequencies produce identical samples, so reconstruction locks onto a false lower alias frequency.

At least two dots per wave 🖖

To pin down a wave you have to catch it both rising and falling — at least two samples in every cycle. With fewer, those same dots could belong to many different waves, and the digital copy guesses wrong. CD audio uses 44,100 samples per second because human hearing tops out near 20 kHz, and 2 × 20 kHz leaves comfortable margin.

Why wheels spin backward on film 🖖

The wagon-wheel effect is Nyquist in the visible world. A movie camera samples motion at 24 frames per second; if a spoked wheel turns slightly less than one spoke-gap between frames, each shot lands just short of the last, so the eye reads the wheel as rotating slowly backward. Same maths as audio aliasing — the frame rate is the sample rate, and fast rotation folds into a false slow one.

Problems solved in full

  1. The 6 dB-per-bit rule and stray 1.76 for an 8-bit converter 5 steps

    Derive the 6 dB-per-bit rule from scratch for an 8-bit converter — where does the stray 1.76 come from? — then say what it does not promise.

    1. Rounding to the nearest level leaves an error no bigger than half a step, and over a busy signal that error is spread evenly across the interval. Its variance is the integral of e² over a uniform distribution.

    2. The reference signal is a sine filling the full input range, so its power is half the square of its amplitude.

    3. Divide the two. The full-scale range cancels, which is the reason the result is a pure function of bit count and not of voltage.

    4. Take logarithms. The 6.02 is 20 log₁₀2 — one bit doubles the number of levels — and the 1.76 is the leftover 3/2 from the previous line.

    5. Evaluate at 8 bits, then at 16. Every extra bit is worth just over 6 dB, so CD audio's eight extra bits buy 48 dB.

    Answer

    49.92 dB, and the 1.76 is 10 log₁₀(3/2). It is the ratio between a sine's mean-square value and the variance of a uniform signal filling the same range, and it is the only part of the formula that is not just counting bits. Notice what never appears: the sample rate. A 24-bit converter running at 8 kHz has 146 dB of amplitude resolution and still cannot represent a 5 kHz tone — bits buy vertical precision, sample rate buys bandwidth, and no amount of one substitutes for the other. That is why the two sliders on this page are genuinely independent axes rather than two ways of saying "quality".

  2. A 30 kHz tone on a CD, and where it comes back 7 steps

    A microphone picks up a 30 kHz component, well above anything anyone can hear, and it reaches a 44.1 kHz converter with nothing filtering it first. What ends up in the recording, and which other tones can it no longer be told apart from?

    Open this problem in the tool

    1. Start with the ceiling. A converter running at 44,100 samples per second can honestly represent anything below half that rate. Our tone is above the limit, so whatever the samples look like afterwards, they cannot mean what they appear to mean.

    2. Write down what the converter actually stores. It never sees the wave. It sees the wave’s value once every 1/44,100 of a second, and nothing else.

    3. Now add a whole number of cycles between one sample and the next. Every sample gains an extra 2πk of phase, and a sine is unchanged by whole turns. The stored numbers come out identical, digit for digit.

    4. So the samples do not identify a frequency. They identify a family, and playback has to choose a member of it. It takes the one nearest zero, which is the distance from 30,000 Hz to the closest multiple of the sampling rate.

    5. That is the figure the tool prints. 14,100 Hz is a thin high whistle, audible to most young listeners and among the first things to go with age, and it was not in the room: an inaudible component has been turned into an audible one by the act of recording it.

    6. Which other tones land in the same place? Every member of the family, and there are infinitely many. The ones a whole sampling rate above come back digit for digit; the mirrored ones come back with every sample negated, which is the same tone with its phase turned over. Either way the recording holds one number per sample and keeps no record of which tone produced it.

    7. That is why the filter has to be analogue and has to sit in front of the converter, and it fixes how sharp it must be: pass 20 kHz, stop by 22,050 Hz, a gap of about a seventh of an octave. Building that in analogue electronics is hard, which is the practical reason oversampling converters exist. Sample faster, the guard band widens, the analogue filter can be gentle, and the steep part of the job moves into arithmetic where it is cheap.

    Answer

    14,100 Hz, at full strength. A 30 kHz tone sampled at 44.1 kHz is indistinguishable from a 14,100 Hz tone, and so are 58,200 Hz, 74,100 Hz and every other member of |k·fs ± 14,100|. Aliasing destroys information at the moment of sampling, so no amount of processing afterwards can separate the folded tones again. The only place to prevent it is in front of the converter.

References (2)