Skip to content

Filter Bank and Polyphase Explorer

Copy this iframe to your website:

1
<iframe src="https://dmccreary.github.io/signal-processing/sims/filter-bank-explorer/main.html" width="100%" height="664px" scrolling="no"></iframe>

Run MicroSim in Fullscreen

Description

This MicroSim builds an \(M\)-channel uniform filter bank from one low-pass prototype filter \(p[n]\) and shows both what the bank does and how it is implemented efficiently. With \(f_s = 8\) kHz, channel \(k\) covers \(k f_s/2M\) to \((k+1) f_s/2M\) and is centred on \((2k+1) f_s/4M\).

  • Upper left: the magnitude response \(|H_k(e^{j\omega})|\) of every analysis filter in its own colour, with the channel number above its centre and dashed lines at the test frequencies. The maroon strip underneath is the overall analysis-synthesis response \(|T(e^{j\omega})|\); a perfect bank would give a flat 0 dB line.
  • Upper right: the energy of the test signal in each subband, in dB of the input energy, and their sum.
  • Lower left: the prototype \(p[n]\) with every tap coloured by its phase \(m = n \bmod M\), and below it the \(M\) polyphase components \(E_m[q] = p[qM + m]\).
  • Lower right: 8 ms of the input \(x[n]\) and the output \(\hat{x}[n]\) shifted back by the bank delay \(N-1\), with the error on a magnified scale.
  • Read-outs: the prototype cutoff, the reconstruction error in dB, the range of \(|T|\), the worst alias term, and the multiplications per output sample for direct and polyphase decimation.

Channels M (2, 4, 8) sets the number of subbands. Prototype length N (16-128 taps) sets the length of \(p[n]\). Test signal chooses four tones (0.3, 1.0, 2.3 and 3.4 kHz with amplitudes 1.0, 0.7, 0.5 and 0.3), a linear chirp from 0 to 4 kHz, or a single tone whose frequency is set by the Tone slider. Tuned cutoff adjusts the prototype cutoff so that neighbouring channels cross at \(-3\) dB; unchecked, the cutoff is \(\pi/2M\) and they cross at \(-6\) dB. Hover over the response plot to read the two strongest channel gains.

This MicroSim supports Chapter 10: Advanced Filter Design and Implementation.

Mathematical Concepts

The prototype is a Hamming-windowed sinc of length \(N\) with cutoff \(\omega_c\), scaled so that \(\sum_n p[n] = 1\). Cosine modulation shifts it to each channel centre (a pseudo-QMF bank):

\[h_k[n] = 2\,p[n]\cos\!\left(\frac{\pi(2k+1)}{2M}\left(n - \frac{N-1}{2}\right) + \phi_k\right), \qquad \phi_k = (-1)^k \frac{\pi}{4}\]

Each channel output is kept at every \(M\)-th sample, \(v_k[m] = (h_k * x)[mM]\). The synthesis filters \(f_k[n]\) use the same cosine with phase \(-\phi_k\) and gain \(2M\) (which undoes the \(1/M\) of decimation), and the output is the sum of the channels:

\[\hat{x}[n] = \sum_{k=0}^{M-1} \sum_{m} v_k[m]\, f_k[n - mM], \qquad \hat{X}(z) = T(z)X(z) + \sum_{l=1}^{M-1} A_l(z)\,X(zW^l)\]

with \(T(z) = \frac{1}{M}\sum_k F_k(z)H_k(z)\), \(A_l(z) = \frac{1}{M}\sum_k F_k(z)H_k(zW^l)\) and \(W = e^{-j2\pi/M}\). The phases \(\pm\phi_k\) make the large alias terms between neighbouring channels cancel; what remains is set by the prototype's stop band. \(T\) is flat only if neighbouring channels are power complementary, \(|P(e^{j\omega})|^2 + |P(e^{j(\pi/M - \omega)})|^2 \approx 1\), which requires \(|P(e^{j\pi/2M})| = 1/\sqrt{2}\) (\(-3\) dB) at the band edge. With Tuned cutoff the sketch finds that \(\omega_c\) by bisection. The reconstruction error is

\[E = 10\log_{10}\frac{\sum_n \left(\hat{x}[n + N - 1] - x[n]\right)^2}{\sum_n x[n]^2}\ \text{dB}\]

over a 2048-sample record. The polyphase form writes \(P(z) = \sum_{m=0}^{M-1} z^{-m}E_m(z^M)\). Filtering at \(f_s\) and then discarding \(M-1\) of every \(M\) outputs costs \(N\) multiplications per input sample, which is \(N \cdot M\) per output sample. The polyphase decimator runs its \(M\) branches of \(N/M\) taps at \(f_s/M\) and computes only the samples that are kept: \(N\) multiplications per output sample, or \(N/M\) per input sample, a saving of a factor \(M\).

Lesson Plan

Learning Objectives

After using this MicroSim, students will be able to:

  1. Calculate the edges \(k f_s/2M\) and centre \((2k+1) f_s/4M\) of every channel and predict which channel or channels a tone falls into
  2. Explain why the subband energies add up to the input energy when neighbouring channels cross at \(-3\) dB, and to less when they cross at \(-6\) dB
  3. Analyze how the prototype length \(N\) and the cutoff tuning change the overall response \(|T|\), the worst alias term and the reconstruction error
  4. Decompose a prototype filter into its \(M\) polyphase components \(E_m[q] = p[qM + m]\) and state their length \(N/M\)
  5. Calculate the multiplications per output sample for direct and polyphase decimation and explain where the factor \(M\) comes from

Target Audience

Undergraduate students in a junior- or senior-level digital signal processing course. Plan about 40 minutes for the four activities.

Prerequisites

  • FIR filters, the windowed-sinc design method and magnitude responses in dB
  • Downsampling by \(M\) and aliasing (see the Multirate Sample Rate Converter)
  • Modulation: multiplying by a cosine shifts a spectrum up and down in frequency

Activities

All values are those the sim displays. Start from the defaults: M = 4, N = 64, multi-tone, Tuned cutoff checked.

Activity 1: Where does the energy go? (10 min). The channels are 1 kHz wide and centred on 0.5, 1.5, 2.5 and 3.5 kHz.

  • The bars read \(-1.7\), \(-8.7\), \(-8.6\) and \(-13.1\) dB and sum to 100.1 %. Predict them yourself: a tone of amplitude \(A\) has power \(A^2/2\), so the four tones carry 0.5, 0.245, 0.125 and 0.045 (total 0.915). The 1.0 kHz tone sits exactly on the edge between channels 0 and 1 and is split equally, so channel 0 holds \((0.5 + 0.1225)/0.915\), which is \(-1.7\) dB.
  • Set M = 8 (0.5 kHz channels). The bars read \(-2.6\), \(-8.7\), \(-8.7\), \(-57.4\), \(-8.6\), \(-35.9\), \(-13.5\) and \(-23.5\) dB. Channel 3 (1.5-2.0 kHz) contains no tone; its \(-57.4\) dB is leakage through the filters' stop bands.
  • Set M = 4 and choose the linear chirp. Every bar is close to \(10\log_{10}(1/4) = -6.0\) dB (\(-6.2\), \(-5.8\), \(-5.8\), \(-6.2\); the outer two are lower because the chirp fades in and out at 0 and 4 kHz).

Activity 2: The \(-3\) dB crossover (10 min). Choose single tone at 1.00 kHz with M = 4 and N = 64.

  • With the cutoff tuned (\(\omega_c = 0.138\pi\), \(|P| = -3.0\) dB at the band edge), channels 0 and 1 each read \(-3.0\) dB, the sum is 100.0 % and the reconstruction error is \(-68.8\) dB.
  • Uncheck Tuned cutoff (\(\omega_c = \pi/2M = 0.125\pi\), \(|P| = -6.0\) dB). The two bars drop to \(-6.0\) dB, the sum to 50.1 %, the maroon strip dips to \(-6.01\) dB at every band edge (0, 1, 2, 3 and 4 kHz), and the error is \(-6.0\) dB: half of the tone's amplitude is lost.
  • Still untuned, move the tone to 1.50 kHz, the centre of channel 1. The error improves to \(-64.2\) dB. Switch to the multi-tone signal: the error is \(-11.7\) dB untuned against \(-62.0\) dB tuned.

Activity 3: Prototype length, aliasing and the error floor (10 min). Choose the linear chirp, M = 8, tuned, and step N:

N Reconstruction error Worst alias term Overall response \(\lvert T \rvert\)
16 \(-3.1\) dB (cannot tune) \(-9.7\) dB \(+3.56\) dB everywhere
32 \(-25.0\) dB \(-29.2\) dB \(+0.00\) to \(+0.62\) dB
48 \(-44.2\) dB \(-46.5\) dB \(+0.00\) to \(+0.07\) dB
64 \(-51.2\) dB \(-63.8\) dB \(+0.00\) to \(+0.04\) dB
128 \(-45.6\) dB \(-69.5\) dB \(+0.00\) to \(+0.10\) dB

At N = 16 the prototype is too short to be narrower than one 0.5 kHz channel, so the channels overlap heavily (the bars sum to 150.7 %). Up to N = 48 the error tracks the worst alias term. Beyond that the alias term keeps falling but the error levels off between \(-45\) and \(-51\) dB: a windowed-sinc prototype is only approximately power complementary, so \(|T|\) keeps a ripple of a few hundredths to a tenth of a dB. Now set M = 2: the worst alias term reads below \(-120\) dB because the two-channel bank cancels aliasing exactly, and the error with the multi-tone signal and N = 64 is \(-55.4\) dB.

Activity 4: Polyphase bookkeeping (10 min). Return to M = 4, N = 64.

  • Each polyphase component \(E_0 \ldots E_3\) has \(64/4 = 16\) taps. Compare \(E_0\) with \(E_3\) and \(E_1\) with \(E_2\): each pair are mirror images, \(E_m[q] = E_{M-1-m}[N/M - 1 - q]\), because \(p[n]\) is symmetric.
  • The read-out gives \(N \cdot M = 256\) multiplications per output sample for the direct decimator and \(N = 64\) for the polyphase one (4 times fewer); per input sample that is 64 against 16.
  • Set M = 8, N = 128: 1024 against 128 per output sample, and 128 against 16 per input sample.

Assessment

  1. With \(f_s = 8\) kHz and M = 8, which frequencies does channel 5 cover, and where is its centre? Answer: the channels are \(f_s/2M = 0.5\) kHz wide, so channel 5 covers 2.5 to 3.0 kHz and is centred on \((2 \cdot 5 + 1) \cdot 8/32 = 2.75\) kHz.
  2. With M = 4 and the tuned cutoff, a single tone is set to 2.00 kHz. Which bars rise, and to what level? Answer: 2.0 kHz is the edge between channels 1 and 2. Each channel passes it at \(|H| = -3\) dB, so each holds half of the power: both bars read \(-3.0\) dB and the error is \(-68.8\) dB.
  3. Why does the untuned bank lose 6 dB at a band edge rather than 3 dB? Answer: at the edge each of the two channels has gain 0.5 in the analysis filter and 0.5 in the synthesis filter, so each path contributes 0.25 and the two paths sum to 0.5, which is \(-6\) dB. With the tuned cutoff each gain is \(1/\sqrt{2}\), each path contributes 0.5, and the sum is 1.
  4. A 128-tap filter decimates by M = 8. How many multiplications does each output sample cost in the direct and the polyphase form? Answer: direct \(128 \times 8 = 1024\) (seven of every eight filter outputs are thrown away); polyphase 128, from 8 branches of 16 taps running at \(f_s/8\). Per input sample that is 128 against 16.
  5. Doubling N from 64 to 128 with M = 8 makes the chirp's reconstruction error worse (\(-51.2\) to \(-45.6\) dB). Why does a longer prototype not guarantee a better bank? Answer: the longer prototype lowers the alias terms (\(-63.8\) to \(-69.5\) dB), but the error is then set by the ripple of \(|T|\) (+0.04 dB at N = 64, +0.10 dB at N = 128). That ripple depends on how closely the tuned windowed sinc approaches power complementarity, not on its length. A lower floor needs an optimized prototype or a perfect-reconstruction design.

Common Misconceptions

"Splitting a signal into M decimated subbands throws information away." The bank keeps \(M\) subbands at \(f_s/M\) each, exactly as many samples as the input. With the default settings the output matches the input to \(-62.0\) dB; the residual error comes from the prototype design, not from decimation.

"A polyphase filter is a different filter." \(E_0 \ldots E_{M-1}\) are the taps of \(p[n]\) dealt out like cards (the colours in the lower-left panel). The polyphase decimator performs the same multiplications as the direct filter for every output sample that is kept, and skips only the outputs that downsampling would discard.

References

  1. Filter bank - Wikipedia - analysis and synthesis banks, uniform DFT and cosine-modulated banks, and perfect reconstruction
  2. Polyphase quadrature filter - Wikipedia - the near-perfect-reconstruction pseudo-QMF bank built here, as used in MPEG audio coding
  3. Quadrature mirror filter - Wikipedia - the two-channel bank in which aliasing cancels exactly (compare M = 2)
  4. Downsampling (signal processing) - Wikipedia - decimation, aliasing and the polyphase implementation of a decimator
  5. Sub-band coding - Wikipedia - why audio and image coders split signals into subbands before quantizing them
  6. The Scientist and Engineer's Guide to Digital Signal Processing - Steven W. Smith - free online textbook with chapters on windowed-sinc filters