C9 · Lesson 21 · Sampling and reconstruction
When samples capture a signal exactly, and when they lie
Every digital audio file, oscilloscope trace and phone call depends on a claim that sounds too good to be true: a continuous signal can be recovered exactly from its samples, as long as it's sampled more than twice as fast as its highest frequency. Break that rule and the samples don't just lose detail, they lie: a high frequency masquerades as a low one, and nothing done afterward can tell the difference. That's aliasing, the wagon wheels that turn backward in films. This lesson covers the sampling theorem, what aliasing does, and how a converter turns samples back into a smooth signal.
- The dashed curve is a cosine at frequency f, and the dots are its samples at rate . The solid curve is the lowest-frequency cosine through the same dots: what the samples look like they came from.
- Below the two curves agree. Above it they part: at 0.9 the samples trace a slow cosine at 0.1 of the sample rate.
- Press Listen while moving the slider (at = 1 kHz): the pitch you hear is the alias, rising to 500 Hz and then falling again as the true frequency keeps rising.
Predict
A 900 Hz tone is sampled at 1 kHz without an anti-aliasing filter. What frequency do the samples show?
100 Hz. Sampling can't distinguish frequencies that differ by a multiple of , and 900 = 1000 − 100, so the samples of a 900 Hz cosine are exactly those of a 100 Hz one. Once sampled, the error can't be undone.
Name it
The sampling theorem
Sampling at makes copies of the signal's spectrum at every multiple of . A signal with no energy above B hertz is captured exactly if
(2B is the Nyquist rate, and the Nyquist frequency), because then the copies don't overlap.
Aliasing
A sinusoid at f is indistinguishable after sampling from one at for any whole k. Folded into the range 0 to , it appears at
Above , frequencies fold back down. An anti-aliasing filter before the converter removes them while they can still be told apart (C4 designed one); it needs a guard band between B and to roll off in.
Reconstruction
Ideally, each sample is replaced by a sinc, , and the sincs added: that rebuilds the band-limited signal exactly. A real DAC holds each sample for one period, a zero-order hold, which multiplies the spectrum by
drooping to 0.637 (−3.9 dB) at , and leaves images of each tone at , , …, which a reconstruction filter removes.
Worked example
Sampled at 1 kHz, where do 900 Hz, 1.1 kHz, 600 Hz and 1.6 kHz tones appear?
Show the solution
- Fold each tone.
- Compare. Four different tones, two apparent frequencies: once sampled, each pair is identical.
Answer 900 Hz and 1.1 kHz both appear at 100 Hz, and 600 Hz and 1.6 kHz both appear at 400 Hz.
Worked example
CD audio is sampled at 44.1 kHz to carry 20 kHz. What guard band does that leave, and how much does a zero-order hold droop at 20 kHz?
Show the solution
- Where the first copy starts.
- Guard band. The anti-aliasing filter has from 20 to 24.1 kHz, a 4.1 kHz guard band, to fall.
- Hold droop. or −3.2 dB, which players correct with a gentle boost.
Answer a 4.1 kHz guard band, from 20 to 24.1 kHz, and a droop to 0.694 (−3.2 dB) at 20 kHz.
Worked example
A telephone channel carries 0 to 4 kHz. What sample rate gives the anti-aliasing filter a 1 kHz guard band to fall in?
Show the solution
- Where the first copy starts. The first copy of the spectrum after sampling starts at kHz.
- Leave room to fall. For the filter to have from 4 kHz to that point to fall:
- What telephony chose. Telephony settled on 8 kHz with a filter that starts rolling off at 3.4 kHz, which gives a guard band of about the same size, 1.2 kHz.
Answer a sample rate of at least 9 kHz.
Check
A 1300 Hz tone is sampled at 1000 Hz with no anti-aliasing filter. At what frequency do the samples show it (between 0 and 1000/2)?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
A signal has no content above 20 kHz. What is its Nyquist rate?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
A DAC with a zero-order hold runs at 22.05 kHz. How much does it droop at 5 kHz, in dB?
Check
A DAC at 8 kHz plays a 1 kHz tone through a zero-order hold.
(a)
Where is the lowest image?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
(b)
Where is the next one up?
Check
A 20 kHz signal is sampled at 44.1 kHz. How wide is the guard band between the signal's edge and the first spectral copy's edge?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
A signal has components up to 20 kHz. Which sample rate captures it without aliasing (with a suitable anti-aliasing filter)?
Check
What is the zero-order hold's gain at 0.45 times the sample rate?
Check
A 1300 Hz tone is sampled at 1000 Hz.
(a)
At what frequency does it appear?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
(b)
What is the highest frequency that can appear?
Check
A zero-order hold reconstructs a signal at 0.25 of the sample rate.
(a)
What is its gain there?
(b)
And in decibels?
Explain why
Why can't aliasing be fixed after the signal has been sampled?
After sampling, all that remains is the list of numbers. A tone at f and one at produce exactly the same list, sample for sample, so no processing of the samples can tell which one was there, or separate them if both were. The information that distinguished them was in the values between the samples, which were never recorded. The only fix is to remove the frequencies above before sampling, with an analog anti-aliasing filter, while they're still different signals.
Practice
Keep practicing
11 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.