S7 · Lesson 7 · Downsampling, upsampling and polyphase filters
Changing the sample rate inside a digital system, the spectra of decimation and interpolation, rational rate changes, the noble identities and polyphase implementation
Digital systems change sample rates constantly: an oversampled converter's output is brought down to the audio rate, a 44.1 kHz recording is resampled for a 48 kHz device, a software radio digitizes megahertz of spectrum and then zooms in on a 10 kHz channel. Two primitive operations do it all: keep every Mth sample, or insert L − 1 zeros between samples. Each one does something precise to the spectrum, stretching it and aliasing it or compressing it and imaging it, and both need a filter to clean up. Polyphase structures then let that filter run at the lower of the two rates, which is where most of the efficiency in real converters comes from.
- The spectrum of a signal with a triangular spectrum of half-width b (dashed), and after keeping every Mth sample (solid), from .
- Downsampling stretches the spectrum by M and adds M shifted copies. If b < π/M the copies don't touch.
- Widen the spectrum or raise M past that point and the copies overlap: aliasing, which only a lowpass filter before downsampling prevents.
Predict
A signal sampled at 48 kHz is to be decimated to 16 kHz by keeping every third sample. What must happen first?
A digital lowpass at π/3, which at 48 kHz is 8 kHz. The new Nyquist frequency is 8 kHz, and anything between 8 and 24 kHz in the original would fold into the new band. The original sampling being alias-free is irrelevant; decimation is a second sampling and needs its own anti-aliasing filter.
Name it
Downsampling (compression) by M
, with
Frequencies stretch by M; a component at moves to . To avoid aliasing, lowpass to first. The pair, filter then downsample, is a decimator.
Upsampling (expansion) by L
Insert L − 1 zeros: . The spectrum compresses by L and L − 1 images appear. A lowpass with cutoff π/L and gain L removes them: an interpolator.
Rational rate change and efficiency
- Change by L/M: upsample by L, one lowpass with cutoff and gain L, then downsample by M. 44.1 → 48 kHz is 160/147.
- Noble identities: a filter before a downsampler by M equals H(z) after it; after an upsampler equals H(z) before it.
- Polyphase: . By the noble identities each runs at the low rate, so an N-tap decimating FIR costs N multiplications per output sample (N/M per input) instead of N per input.
- Large factors are cheaper in stages, since early stages can use short filters with wide transition bands.
Worked example
A 120-tap FIR filter decimates by 4. Count multiplications per output sample, done naively and in polyphase form.
Show the solution
- Naive. The filter runs at the input rate, computing 120 products per input sample, and only every fourth output is kept:
- Polyphase. Four 30-tap subfilters each run once per output: That's 30 per input sample.
- Compare. Polyphase saves a factor of 4 and gives an identical result.
Answer 480 multiplications per output sample naively, and 120 in polyphase form.
Worked example
A 1 kHz tone sampled at 8 kHz is upsampled by 3. Where are its images, and what filter removes them?
Show the solution
- New rate. The new rate is 24 kHz, with its Nyquist frequency at 12 kHz.
- Images. Inserting zeros leaves the original spectrum's copies at 8 ± 1 and 16 ± 1 kHz visible, so images appear at 7 and 9 kHz, below the new 12 kHz Nyquist frequency.
- Interpolation filter. A lowpass at π/3 (4 kHz at 24 kHz) with gain 3 removes them and restores the amplitude.
Answer images at 7 and 9 kHz, removed by a lowpass filter at π/3 (4 kHz) with a gain of 3.
Worked example
Convert 44.1 kHz audio to 48 kHz with one polyphase filter of 3840 taps. What is the intermediate rate, the filter's cutoff, and the cost per output sample?
Show the solution
- Rate ratio. so L = 160 and M = 147.
- Intermediate rate. The conceptual intermediate rate is
- Cutoff. which is 22.05 kHz, the input's Nyquist frequency.
- Cost per output. In polyphase form each output uses only one of the 160 subfilters: That's 24 multiplications per output sample, against millions per second for the naive version.
Answer the intermediate rate is 7.056 MHz, the cutoff is π/160 (22.05 kHz), and each output sample costs 24 multiplications.
Check
A tone at ω = 0.1π is downsampled by 2. Where does it appear, in units of π?
Check
A signal at 96 kHz is decimated by 2. Above what frequency must the anti-aliasing filter remove content?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
A 1 kHz tone at 8 kHz is upsampled by 4. What's the lowest image frequency?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
An N = 120-tap decimating FIR (factor 2) is built in polyphase form. How many multiplications does it need per input sample?
Check
A rate converter upsamples by 160 and downsamples by 2. What's its single filter's cutoff, in units of π (at the upsampled rate)?
Check
A 44.1 kHz signal is upsampled by 160 inside a rational rate converter. At what rate does the conceptual interpolation filter run?
Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.
Check
A rate converter upsamples an 8 kHz signal by 5 and downsamples by 4.
(a)
What is the intermediate rate?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
(b)
What is the output rate?
Check
An N-tap FIR decimates by M.
Step 1
How many multiplications per input sample does the naive version need?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
And the polyphase version?
Step 3
How many multiplications does the polyphase version spend per output sample?
Explain why
Why does a decimator's filter only need to compute every Mth output?
A decimator filters and then throws away M − 1 of every M output samples, so computing those discarded outputs is wasted work. Because the filter is an FIR sum of past inputs, each kept output depends only on the inputs, not on any other output, and can be computed on its own. The polyphase form makes this systematic: splitting the filter's taps into M interleaved groups lets each group act on the inputs that belong to it at the low rate, and by the noble identity the result is exactly the same as filtering at the high rate and keeping every Mth sample. The arithmetic drops by a factor of M with no change in the output.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.