Here are seventeen samples, 1 ms apart, of a smooth wave. A pulse goes at every sample, as tall as its sample, and the pulses are added one at a time. Decide first: where will the sum pass? Watch it at the dots, and between them.
A pulse at every sample, added
Seventeen samples, 1 ms apart, of a wave with nothing above 270 Hz.
Seventeen samples of a smooth wave, 1 ms apart. The dashed curve is the wave they came from.
Describe this picture
Seventeen samples, 1 ms apart, of a wave with nothing above 270 Hz, against time from −8 to 8 ms; there are no controls. The samples are dots with stems, labelled “samples x[n]”, and the original is a dashed curve labelled “the wave they came from”. The newest pulse is a faint curve labelled “newest pulse”, and the running sum is a solid accent curve labelled “sum of pulses”. Pulses join in the order 0, 1, −1, 2, −2, up to 8 and −8: the first at about 2 s, then one every 0.6 s. The readouts are “pulses added”, from 0 to 17, and “largest gap, −2 to 2 ms”, from 1.182 to 0.016. Reduced-motion steps stop at pulses 0, 1, 3, 5, 9, 13 and 17.
A pulse at every sample, added
The page The sampling theorem (10.2) ended with a promise. If a signal has nothing at or above half the sample rate, an ideal low-pass filter can cut the middle copy out of the sampled signal’s spectrum, and that copy is the original. Here I show what that filter does in time.
In this lesson ms, so kHz and the Nyquist frequency is Hz. The ideal low-pass from Frequency response and Bode plots (8.4) keeps . With time in milliseconds, its impulse response is , where . This sinc pulse is 1 at and 0 at every other whole number of milliseconds.
Now send the sampled signal’s spikes through that filter. By Continuous-time convolution (5.3), a spike leaves a copy of at its own position, scaled by the spike’s area. The area of the spike at is the sample . So the filter’s output is a sinc pulse at every sample, each as tall as its sample, added together. I call that output the reconstruction , and I write it as
The wave in this lesson is , with in seconds. It has nothing above 270 Hz, well under Hz. I sample it at kHz. Think of a flexible ruler bent through pins on a board: the pins are the samples, and the ruler is the sum.
The picture at the top of the page adds these sinc pulses one at a time. Its readout “largest gap, −2 to 2 ms” is the largest distance between the sum and on the stretch from −2 to 2 ms. With no pulses, the gap is the largest value of itself, 1.182.
One pulse at sample 0 is as tall as that sample, and 0 at every other sample instant. The gap is then 0.804. One pulse is wrong between the dots, but it is right at every dot, because it is 1 at its own sample and 0 at the others. The other pulses join from the middle outward, each as tall as its own sample and 0 at every other dot. With all seventeen added, the sum passes through every dot and, in the middle, lies on the original: the gap is 0.016. Near the ends it drifts, because pulses from samples further out are missing.
Notice the order of events. Every pulse keeps the sum on every dot, and each new pulse changes only what happens between the dots. The gap on the middle stretch falls from 1.182 to 0.804, and then to 0.226, 0.083, 0.048, 0.018 and 0.016 after 1, 3, 5, 9, 13 and 17 pulses.
Why the sum passes through every dot
At the instant , each sinc in the sum is . That is 1 when and 0 for every other whole number. So only one term survives, and
The sum passes through every sample, whatever the samples are. What happens between the dots is the tails of the pulses filling in. For a signal with nothing at or above , 10.2 says that they fill in the original, and the middle of the instrument shows it.
Near the ends the sum drifts, because the pulses from samples beyond the ends are missing. The sinc has tails that never end, and a pulse far away still contributes. This is also the filter’s problem. By 8.4, the ideal low-pass is not causal: its response starts before the spike that causes it. A real converter delays the pulse and uses a few dozen neighbours, with the sinc tapered toward its ends, a method from Window-method FIR design (19.1). Smooth interpolators such as cubic and Lagrange interpolation work the same way, with a short pulse in place of the sinc.
The same recipe with other pulses
Nothing in the recipe needs the sinc. Replace it by any pulse , and the sum is . Two cheap pulses are in everyday use. The hold is a rectangle one sample period long, starting at each sample. It makes the staircase that a digital-to-analog converter (DAC) makes, and the circuit is a zero-order hold. The straight lines pulse is a triangle two sample periods wide, which connects the dots.
Adding a pulse at every sample is convolution of the spikes with the pulse. So by Properties of the Fourier transform (8.2) the spectrum is 10.2’s copies, multiplied by the pulse’s spectrum. From series to transform (8.1) gives the rectangle’s spectrum as a sinc, and 8.2 gives the triangle’s, which is the rectangle’s squared. I measure each gain relative to 0 Hz, which means dividing the pulse’s spectrum by :
- hold: ;
- straight lines: ;
- sinc: 1 for and 0 above, the brick wall of 8.4.
A good pulse keeps the middle copy whole and removes every other copy. Which of the three does both? Watch how much is kept at 270 Hz, and how much of the 730 Hz copy is left, for each pulse.
Three pulses, three spectra
Same samples as above. Spectrum: positive frequencies; the negative side is its mirror image.
Hold each sample for one period: a staircase. Its spectrum droops (0.884 at 270 Hz) and lets 0.327 of the 730 Hz copy through.
Describe this picture
The same samples as above, in two panels, one above the other on a phone and beside each other on a wide page, and a switch labelled “pulse” with the options “hold”, “straight lines” and “sinc”. The time panel, from 0 to 8 ms, shows the samples, the dashed original and the rebuilt curve in the accent colour, labelled with the pulse’s name. The spectrum panel shows positive frequencies from 0 to 2500 Hz, the negative side being its mirror image, with size (arrow length) from 0 to 1. Faint lines stand at 110 and 270 Hz, with lengths 0.8 and 0.4, and copies of the same lengths at 730, 890, 1110, 1270, 1730, 1890, 2110 and 2270 Hz, each pair beyond 500 Hz labelled “copy”. The pulse’s gain curve is labelled “pulse gain” in a key above the panel, and each line, after the pulse has acted on it, is drawn solid. The readouts are “kept at 270 Hz” and “left of the 730 Hz copy”, to three decimals. The clip shows hold, straight lines and sinc for 4 seconds each, with half-second crossfades, and the switch follows it; choosing an option jumps to the end of the clip and shows that pulse.
Hold each sample for one period and you get a staircase. Its spectrum droops, keeping 0.884 at 270 Hz, and lets 0.327 of the 730 Hz copy through. Join the dots with straight lines and less of the copy gets through, 0.107, but the droop is worse, 0.782 at 270 Hz. Sinc pulses keep everything below 500 Hz whole and remove every copy, 1.000 and 0.000, so only the sinc rebuilds the original exactly.
Switch pulse to each option yourself, and compare the two readouts. Notice that the hold droops a little and leaks a lot, and the lines leak less and droop more. Each cheap pulse trades one error for the other. Only the sinc has no droop and no leak, and only for a signal with nothing at or above .
The hold’s droop and delay
The hold’s gain falls even inside the band you want to keep. At , where , the gain is , which is dB. For straight lines it is , which is dB, twice as far down in dB, as squaring doubles a dB value. This loss of the high end is called droop.
The hold also delays the signal. A staircase lags its curve by half a sample period, because each step starts at the sample and then holds it. At 44.1 kHz that is . In a CD player the audio band reaches 20 kHz, so . There the hold’s gain is , which is dB.
The fix is called compensation. Before the DAC, the player boosts the top of the band by , which at 20 kHz is , or dB. After the DAC an analog low-pass smooths the steps. That filter is the subject of Anti-aliasing and practical converters (10.4).
Two staircases
A hold staircase is easy to confuse with a second staircase, which comes from a different step. Rounding a value to the nearest of a few levels also makes steps, as I showed in Kinds of signals (1.2). They differ in what is kept and what is changed.
A hold changes the time axis, because the curve between ticks is replaced by one flat step, and keeps each value exact. Rounding does the opposite. It keeps the time and changes the value, and Quantization and noise (11.1) is about what that costs.
The maths behind it · an interpolating basis
The shifted sinc pulses are building blocks that are 1 at their own sample and 0 at every other one, so the weight of each block is simply its sample. Building blocks with that property form an interpolating basis, and the samples are the coordinates.
The maths behind it · linear interpolation
Drawing straight lines between measured points (linear interpolation) is the everyday way to fill gaps in a table. This page shows what it costs: a smoothed top of the band.
Worked example
- Gains. At the hold’s gain is ( dB) and the lines’ gain is ( dB). At they are ( dB) and ( dB). At they are ( dB) and ( dB).
- A CD player. At 20 kHz and kHz the hold’s gain is ( dB), the compensation boost is ( dB), and the hold’s delay is .
- The pulse sum. . The largest gap on ms after 1, 3, 5, 9, 13 and 17 pulses is , , , , and .
Where you’ll meet this
Every DAC, from a phone’s headphone output to a CD player, uses a hold followed by an analog filter, and the droop above is why the digital part boosts the top of the band first. Raising a sample rate by inserting samples is the same recipe done in the digital domain, in Upsampling and interpolation (22.2).
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Ideal reconstruction | exact when 10.2’s theorem holds | |
| One recipe | pulse : hold, triangle or sinc | |
| Passes through every dot | , and for nonzero whole | |
| Hold (zero-order hold) | gain | dB at ; delay |
| Straight lines | gain | dB at |
| Sinc | gain 1 below , 0 above | removes every copy; not causal |
| Compensation | boost by before the DAC | 1.440 at 20 kHz, kHz |