Fewer samples
Audio arrives as samples x[n], 48 000 a second, one every 20.8 µs. It holds a 1 kHz tone we want and a 10 kHz whistle we do not, 0.5 each. A speech system needs only 16 000 samples a second.
With the switch closed the filter is skipped. The ↓3 block keeps x[0], x[3], x[6] ... and drops the rest: y[m] = x[3m]. This is downsampling by M = 3. Out come 16 000 samples a second.
Aliasing again
At 16 000 samples a second, only frequencies below half of that can be told apart: 8 kHz, the new Nyquist frequency fs/(2M). The 1 kHz tone fits. The 10 kHz whistle was fine at 48 kHz but is now too high.
Dropping samples cannot remove the whistle. It folds across 8 kHz to 16 − 10 = 6 kHz. The kept samples trace a 1 kHz tone plus a 6 kHz tone, both 0.5. A DFT of y[m] finds 0.50 at 6 kHz.
Filter first
Open the switch: samples now pass a low-pass filter before ↓3. It is a FIR filter (finite impulse response): each output is a weighted sum of the last 61 inputs, v[n] = Σ h[k]·x[n−k]. Its cutoff sits at 8 kHz.
At 1 kHz the filter's gain is 1.002: the tone passes. At 10 kHz it is 0.0008, 62 dB down. Everything above the new Nyquist frequency must be removed before a single sample is dropped.
Now ↓3 drops two samples in three of the filtered stream. The whistle still folds to 6 kHz, but at 0.0004 instead of 0.5. Low-pass plus downsampling is decimation. The filter also delays everything by 30 samples (0.625 ms).
In practice
Two of every three filter outputs are thrown away, so never compute them. Work out v[n] only for n = 0, 3, 6 ...: 976 000 multiply-adds a second instead of 2 928 000. Polyphase decimators are built on this idea.
With scipy, firwin designs the 61-tap low-pass (cutoff 1/3 of the old Nyquist frequency), lfilter runs it and v[::3] keeps every third sample. signal.decimate(x, 3, ftype="fir") does the job in one call and also removes the delay.
The working
# step 1/9 · rate
fs = 48 000 samples per second
Ts = 1 / fs = 20.8 µs
x[n] = 0.5·sin(2π·1000·n/fs)
+ 0.5·sin(2π·10000·n/fs)
goal: fs' = 16 000 per second
48 000 / 16 000 = 3 = M
plots: x[n] over 1 ms (48 samples),
and its spectrum (DFT of 96 samples:
1000 Hz 0.50, 10000 Hz 0.50)
48 000 samples a second is the standard rate of professional video and audio; 16 000 is the wideband speech rate of ITU-T G.722 (audio up to 7 kHz). The two tones of 0.5 each are a chosen example. The filter is scipy.signal.firwin(61, 1/3), the same filter scipy.signal.decimate(x, 3, ftype="fir") uses. Filtered values are the steady state, after the first 60 samples. Every number is computed from this model. The motion is slowed down a great deal: real samples arrive every 20.8 µs.