DSP 101
M6 · L4
Module 6 — The Fast Fourier Transform
Real-Time Spectrum Analysis

The Short-Time Fourier Transform, frame and hop sizing, the Hann window, waterfall displays, and how to build a live spectrum analyzer — making the FFT work in continuous time.

1 / 9
DSP 101
M6 · L4
The Core Idea
The Short-Time Fourier Transform

Slide a window of length N across the signal. Compute the FFT of each windowed frame. Stack results over time — you get a 2-D time-frequency map showing how spectral content evolves.

STFT
X[m,k] = \sum_{n=0}^{N-1} x[n+mR]\,w[n]\,e^{-j2\pi kn/N}
2 / 9
DSP 101
M6 · L4
Design Choices
Three Parameters That Control Everything
N
Frame size → freq. res.
R
Hop size → time res.
w[n]
Window → leakage
Uncertainty principle
Short frame → fine time, coarse frequency. Long frame → fine frequency, poor time. You can't have both.
3 / 9
DSP 101
M6 · L4
Standard Choice
Hann Window & 50% Overlap

The Hann (raised cosine) window tapers smoothly to zero — its peak side lobe sits at −31.5 dB, about 18 dB below rectangular's −13 dB. At 50% overlap, consecutive Hann windows sum to a constant (COLA condition) → perfect reconstruction.

Hann Window
w[n] = 0.5\!\left(1 - \cos\frac{2\pi n}{N-1}\right)
4 / 9
DSP 101
M6 · L4
The Pipeline
Building a Live Spectrum Analyzer
  • Capture: read samples into a ring buffer of size N
  • Window: every R new samples, extract N samples × Hann
  • FFT: N-point real FFT → N/2+1 magnitude-squared bins
  • dB: 10 log₁₀ |X[k]|² for display dynamic range
  • Display: bar graph or line; scroll waterfall by one row
  • Repeat at hop rate: f_s / R frames per second
5 / 9
DSP 101
M6 · L4
Display Techniques
Averaging & Peak Hold

Raw FFT output is noisy frame-to-frame. Two post-processing techniques:

Exponential smoothing
S[k] = α·|X[k]|² + (1−α)·S_prev[k] α ≈ 0.1–0.3 trades noise for responsiveness
Peak hold
P[k] = max(|X[k]|², P_prev[k]); hold then decay at δ dB/frame — reveals transients smoothing hides
6 / 9
DSP 101
M6 · L4
2-D Spectrum History
Waterfall Displays
  • Each STFT frame adds one row to the scrolling image
  • Colour encodes power (dB) — hot = strong, cool = weak
  • Chirps appear as diagonal lines; harmonics as horizontal bands
  • SDR: monitor MHz of RF for signals, interference, occupancy
  • Audio: room modes, reverb tails, harmonic structure
  • Vibration: track resonances as load or RPM changes
7 / 9
DSP 101
Knowledge Check

Check what stuck

Four questions from this lesson. Answer to see why — the explanation appears whether you were right or wrong. Nothing is scored or saved.

Question 1 of 0
Score 0/0

8 / 9
DSP 101
M6 · L4
Key Takeaways
What You Learned
  • STFT = repeated windowed FFTs across overlapping frames
  • N controls frequency res; R controls time res — trade-off is unavoidable
  • Hann window + 50% overlap = low leakage + COLA reconstruction
  • Live analyzer: ring buffer → window → rfft → dB → render
  • Smooth with exponential averaging; preserve peaks with peak hold
  • Waterfall reveals time-varying structure invisible in single-frame views
Read full article →
9 / 9
1 / 8 muted