D5 · Lesson 9 · Decimation and interpolation
Changing a digital signal's sampling rate, decimation by keeping every Mth sample and the filter that must come first, interpolation by inserting zeros and the images it creates, rational rate changes such as 44.1 to 48 kHz, and polyphase filters that skip the work that would be thrown away
A digital audio workstation mixes tracks recorded at 44.1 and 48 kHz, a software radio digitizes 20 MHz of spectrum and then needs only a 200 kHz slice of it, and a delta-sigma ADC samples at megahertz to deliver a few kilohertz of clean audio. All of them change sampling rates. Doing it is simple in principle: throw samples away, or insert new ones. Doing it right means respecting the sampling theorem at the new rate, which takes a low-pass filter, and doing it efficiently means never computing a sample you're about to discard.
- The spectrum of a signal occupying 0 to B kHz, sampled at 48 kHz, and the copies that land on top of it if it's decimated by M with no filter: decimating moves the sampling rate to 48/M kHz, so copies appear at every multiple of 48/M.
- If B is below the new Nyquist frequency, 24/M kHz, the copies don't overlap the original. Above it they fold onto it: aliasing.
- That's why decimation starts with a low-pass filter at the new Nyquist frequency.
Predict
A 48 kHz recording is decimated by 6 for an 8 kHz telephone link. What must the filter in front of the decimator do?
The new rate is 8 kHz, so its Nyquist frequency is 4 kHz. Anything left above 4 kHz in the 48 kHz signal folds back into the 0 to 4 kHz band after decimation, where nothing can remove it. A digital low-pass at about 3.4 kHz goes first, then every sixth sample is kept.
Name it
Decimation by M
Keep every Mth sample: the rate becomes , with Nyquist frequency . To avoid aliasing, first low-pass filter to below .
Interpolation by L
Insert L − 1 zeros between samples: the rate becomes , but the spectrum now contains images, copies of the original band around every multiple of the old rate (a tone at reappears at , , ...). A low-pass filter at the old Nyquist frequency, with gain L, removes them and fills in the zeros with smooth values.
Rational rates
Interpolating by L and then decimating by M changes the rate by L/M. From 44.1 kHz to 48 kHz is
with one filter, cutting off at the lower of the two Nyquist frequencies, between the steps.
Polyphase filters
Filtering at the high rate and then discarding M − 1 of every M outputs wastes most of the work. A polyphase decimator splits the N-tap filter into M branches and computes only the outputs that are kept, so the cost falls from to multiplications per second. Interpolators likewise skip the multiplications by the inserted zeros.
Worked example
A 20 MHz digitized band is decimated by 64 for a single channel. What's the new rate, and what can the channel's bandwidth be?
Show the solution
- New rate.
- Nyquist frequency.
- Channel bandwidth. After a sharp filter, a real signal up to about 150 kHz wide fits, or a complex baseband signal twice that.
Answer the new rate is 312.5 kHz, room for a real channel about 150 kHz wide or a complex one twice that.
Worked example
A 2000-tap decimation filter runs at 48 kHz with M = 6. What does polyphase save?
Show the solution
- Direct. multiplications per second.
- Polyphase. Only one output in six is ever computed:
Answer polyphase cuts the work from 96 million to 16 million multiplications per second.
Worked example
48 kHz audio is interpolated by 4 to 192 kHz. Where do the images of a 10 kHz tone land, and what must the filter do?
Show the solution
- Where images come from. Inserting zeros copies the spectrum around multiples of 48 kHz.
- Images in the new band. Within 0 to 96 kHz the tone appears on each side of 48 kHz and just below 96 kHz:
- The filter. A low-pass at the new rate with its cutoff near 24 kHz removes them, leaving only the 10 kHz tone at the higher rate.
Answer the images land at 38, 58 and 86 kHz, and a low-pass near 24 kHz at the new rate removes them.
Check
A 96 kHz signal is decimated by 2. Above what frequency must it be filtered out first?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
A 3 kHz tone sampled at 16 kHz is interpolated by 2 with zeros inserted. At what frequency is its first image?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
A 48 kHz signal is interpolated by 160 and decimated by 4. What's the new rate?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
A 1000-tap polyphase decimator runs at 48 kHz input with M = 16. How many million multiplications per second does it need?
Check
A 20 MHz signal is decimated by 16.
(a)
What is the new rate?
Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.
(b)
What bandwidth can survive without aliasing?
Check
A 500-tap decimation filter at 96 kHz decimates by 4.
(a)
How many million multiplies a second does it take, computed directly at the input rate?
(b)
And in polyphase form, in millions a second?
Explain why
Why must a decimator filter before it discards samples?
Keeping only every Mth sample lowers the sampling rate by M, and with it the highest frequency the samples can represent. Any content in the original signal between the new Nyquist frequency and the old one doesn't disappear when samples are dropped: it produces exactly the same sample values as some lower frequency, so it folds down on top of the wanted band. Once the samples are dropped, the folded content can't be separated from the real signal. Low-pass filtering first removes everything above the new Nyquist frequency while the higher rate can still represent it, so nothing is left to fold.
Practice
Keep practicing
8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.