S77 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

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 Xd(ejω)=1M∑k=0M−1X(ej(ω−2πk)/M).
  • 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?

Name it

Downsampling (compression) by M

xd[n]=x[nM], with

Xd(ejω)=1M∑k=0M−1X(ej(ω−2πk)/M)

Frequencies stretch by M; a component at ω0 moves to Mω0. To avoid aliasing, lowpass to π/M first. The pair, filter then downsample, is a decimator.

Upsampling (expansion) by L

Insert L − 1 zeros: Xe(ejω)=X(ejωL). 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 min⁡(π/L,π/M) and gain L, then downsample by M. 44.1 → 48 kHz is 160/147.
  • Noble identities: a filter H(zM) before a downsampler by M equals H(z) after it; H(zL) after an upsampler equals H(z) before it.
  • Polyphase: H(z)=∑k=0M−1z−kEk(zM). By the noble identities each Ek 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
  1. Naive. The filter runs at the input rate, computing 120 products per input sample, and only every fourth output is kept: 120×4=480per output
  2. Polyphase. Four 30-tap subfilters each run once per output: 4×30=120per output That's 30 per input sample.
  3. 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
  1. New rate. The new rate is 24 kHz, with its Nyquist frequency at 12 kHz.
  2. 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.
  3. 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
  1. Rate ratio. 4844.1=160147 so L = 160 and M = 147.
  2. Intermediate rate. The conceptual intermediate rate is f=160×44.1kHz=7.056MHz
  3. Cutoff. ωc=min⁡(π/160,π/147)=π/160 which is 22.05 kHz, the input's Nyquist frequency.
  4. Cost per output. In polyphase form each output uses only one of the 160 subfilters: 3840160=24taps 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°.

Explain why

Why does a decimator's filter only need to compute every Mth 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.