D5 · Lesson 7 · Fast convolution and filter banks
Filtering by multiplying spectra, why the FFT computes circular convolution and how zero padding makes it linear, overlap-add processing in blocks, when the FFT beats a direct FIR filter, the latency it costs, and splitting a signal into many channels with a DFT filter bank
Convolving a signal with a 10,000-tap impulse response, the reverberation of a concert hall, say, takes 10,000 multiplications for every output sample: almost half a billion a second for CD audio. But convolution in time is multiplication in frequency, and the FFT gets to frequency cheaply. Transform a block, multiply by the filter's spectrum, transform back, and the cost per sample grows only with the logarithm of the filter's length. Long filters, room simulators and the channelizers that split a wideband radio into hundreds of channels all work this way.
- Real multiplications per output sample for an N-tap FIR filter, computed directly (N) and by FFT overlap-add with a transform of the next power of two at least 2N (counting 4 real multiplications per complex one).
- For short filters, direct wins; past about 64 taps the FFT method wins, and by thousands of taps it's tens of times cheaper.
- The cost is latency: the FFT method has to collect a whole block before producing any output.
Predict
A 1024-tap filter runs by overlap-add with 2048-point FFTs. About how many complex multiplications does each output sample cost?
Each block takes a 2048-point FFT and inverse FFT (1024 × 11 multiplications each) plus 2048 spectral products: 2048 × 11 + 2048 = 24,576. It yields 2048 − 1024 + 1 = 1025 new outputs, so 24.0 complex multiplications, about 96 real ones, per sample against 1024 directly: ten times cheaper.
Name it
Convolution by FFT
Convolution in time is multiplication in frequency, but the DFT's version is circular: the end of the output wraps around onto the start. Convolving a B-sample block with an N-tap filter makes outputs, so the transform length must be
with the block and the filter zero-padded to L. Then the circular result equals the linear one.
Overlap-add
Cut the input into blocks of B samples, convolve each by FFT, and add each result's sample tail onto the start of the next. (Overlap-save instead overlaps the input blocks and discards the wrapped samples.) Per block the work is two L-point FFTs plus L products, about complex multiplications, for B outputs.
Latency
Nothing comes out until a block has been collected: at least B samples of delay, which matters for live audio. Real-time convolvers split the filter into short and long partitions to keep the delay small.
Filter banks
A bank of M bandpass filters spaced apart can share one prototype low-pass and one M-point FFT: the input passes through the prototype's M polyphase branches, and the FFT turns their outputs into M channels at once. Radio channelizers, audio codecs (MP3, AAC) and the OFDM receivers of D4 are built on this.
Worked example
What transform length handles 3000-sample blocks with a 1000-tap filter, and what's the first block's latency at 48 kHz with B = 1025?
Show the solution
- Transform length. so a 4096-point FFT.
- Block size. With 2048-point FFTs and a 1024-tap filter, B = 1025 samples.
- Latency. before the first output.
Answer a 4096-point FFT, and with B = 1025 the first output comes 21.4 ms after the start.
Worked example
A 48 kHz signal is split into 64 channels by a DFT filter bank. How far apart are they?
Show the solution
- Channel spacing.
- Rate after the bank. Each channel can be decimated by up to 64 (lesson 9), so the total sample rate stays 48 kHz.
Answer the channels are 750 Hz apart.
Worked example
How much does FFT convolution save over direct convolution for a 1000-tap filter with 4096-point transforms?
Show the solution
- Outputs per block.
- Cost per block. Two FFTs and a spectrum product take about
- Cost per output. complex multiplies, or about 69 real multiplies.
- Compare. Direct convolution takes 1000 multiplies per output, about 15 times as many.
Answer FFT convolution does about 15 times less work: about 69 real multiplies per output against 1000.
Check
Blocks of 1000 samples are convolved with a 64-tap filter by FFT. What's the shortest transform that avoids wraparound?
Check
A -tap filter runs by overlap-add with FFTs twice that long. About how many complex multiplications does each output cost?
Check
An overlap-add convolver collects 1025-sample blocks at 44.1 kHz. What's its minimum latency?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
A DFT filter bank splits a 1000 kHz signal into 16 channels. How far apart are the channels?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
An overlap-add filter has 500 taps and uses 2048-point FFTs.
(a)
How many new outputs does each block give?
(b)
How many times less work than direct convolution is it, counting 4 real multiplies per complex one?
Check
Overlap-add processes 256-sample blocks at 16 kHz.
(a)
What latency does collecting a block add?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
How many blocks a second?
Explain why
Why does the FFT method of convolution need zero padding?
Multiplying two DFTs and transforming back gives circular convolution, as if both signals repeated forever with the DFT's length as their period. The true, linear convolution of a block with a filter is longer than either: it lasts the block's length plus the filter's length minus one. If the transform is shorter than that, the part of the output that runs past the end wraps around and adds onto the beginning, corrupting it. Padding both the block and the filter with zeros to at least the full output length gives the wrapped tail room to land on zeros, so the circular result equals the linear one.
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.