Foundations to Frontier
Tests
A. Mathematical Foundations › A10 Signal Processing

Spectrograms and the Short-Time Fourier Transform

Real signals change over time: an engine spins up, a bird chirps, a bearing clicks. The short-time Fourier transform (STFT) slides a window along the signal and takes an FFT of each slice, giving a spectrogram, a picture of frequency content over time. This topic covers window length and the time–frequency trade-off, overlap and hop size, perfect reconstruction by overlap-add, ridge tracking of instantaneous frequency, and when long or short windows win. In the research exercise you track a reaction wheel's run-up from its vibration spectrogram to a twentieth of a frequency bin and pinpoint a 3 ms bearing click.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Sheet music for any sound

Sheet music shows which notes play when: time runs left to right, pitch goes up the page. A spectrogram draws the same picture for any signal: a jet engine spinning up, a bat’s call, a satellite’s vibration. It’s made by chopping the signal into short overlapping slices and finding the frequencies in each one. Short slices tell you exactly when; long slices tell you exactly which pitch. You can’t have both at once.

Spectrograms: frequency content over time
0500100015002000time 0 → 1 s
Each column is the FFT of one windowed slice. Short windows (N = 32) catch the clicks as sharp vertical lines but blur tones across wide bands; long windows (N = 2048) separate the 800/830 Hz tones (30 Hz apart needs Δf well under 30 Hz) but smear the clicks and the fast siren sweep. That is the uncertainty principle at work: Δt·Δf is bounded below. A linear chirp stays sharp longer because its smear is symmetric about the true frequency.
Why engineers care

Machinery health monitoring, radar micro-Doppler (spotting drone propellers), speech recognition front ends, seismic and structural monitoring and RF spectrum monitoring all start from a spectrogram. Many neural networks for audio and vibration take spectrograms as their input images.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A spectrogram shows…
  2. 2. Short analysis windows are good at locating…
  3. 3. Can a spectrogram be perfectly sharp in both time and frequency?

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

The STFT

X[m,k]=∑nx[n]w[n−mH]e−j2πkn/NX[m, k] = \sum_nx[n]w[n - mH]e^{-j2\pi kn/N}

Here w is a window of length N (Hann is the usual choice) and H is the hop. The spectrogram is ∣X[m,k]∣2\lvert X[m, k]\rvert^2, usually shown in dB.

Resolution

  • Frequency bin spacing: Δf=fs/N\Delta f = f_s/N.
  • Window duration: N/fsN/f_s.
  • So Δt⋅Δf≈1\Delta t\cdot\Delta f\approx1: halving one doubles the other.

Overlap is typically 50–75% (H = N/2 to N/4).

📝 Quick check (Level 1)
0/3 answered
  1. 1. Bin spacing for fs = 1000 Hz, N = 250:
  2. 2. Window duration for N = 256 at fs = 1024 Hz:
  3. 3. To separate tones 10 Hz apart you need Δf…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Perfect reconstruction: overlap-add

If the shifted analysis and synthesis windows satisfy ∑mw2[n−mH]>0\sum_mw^2[n - mH] > 0, inverse-FFT each frame, multiply by the window, overlap-add, and normalize by ∑w2\sum w^2. This recovers x exactly. A periodic Hann at 75% overlap works. This enables time–frequency editing: denoising, source separation and phase vocoders.

Ridges and instantaneous frequency

For a tone with slowly varying frequency, the spectrogram’s peak (ridge) follows fi(t)=12πdϕdtf_i(t) = \frac1{2\pi}\frac{d\phi}{dt}. Parabolic interpolation of the log-magnitude around the peak gives sub-bin accuracy. Choosing N depends on the signal:

  • a linear chirp smears symmetrically, so long windows still track its centre;
  • curved frequency laws (FM, vibrato, run-ups with acceleration) are biased by long windows;
  • transients need short windows.

Beyond the STFT

The STFT has fixed resolution at all frequencies. Wavelets (a10-7) and the constant-Q transform use long windows for low frequencies and short ones for high frequencies. Reassignment and synchrosqueezing sharpen ridges.

🐍 Exercise 1: STFT, inverse STFT and the window trade-off
Implement the STFT (periodic Hann) and overlap-add inverse, and check perfect reconstruction. Track the instantaneous frequency of a siren-like FM signal with three window lengths and show that a medium window wins.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Overlap-add reconstruction requires…
  2. 2. Parabolic peak interpolation gives…
  3. 3. Which representation adapts resolution to frequency?

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

The uncertainty trade-off

A window of duration T has a main-lobe width of about c/Tc/T in frequency (c ≈ 2 for Hann, between the first nulls). So events closer than about T in time, or frequencies closer than about c/T, merge. With Gaussian windows the bound σtσf≥1/(4π)\sigma_t\sigma_f\ge1/(4\pi) is reached (the Gabor transform). ∎

Bias for curved frequency laws

Over a window centred at t0t_0, f(t)≈f(t0)+f′(t0)(t−t0)+12f′′(t0)(t−t0)2f(t)\approx f(t_0) + f'(t_0)(t - t_0) + \frac12f''(t_0)(t - t_0)^2. The linear term spreads energy symmetrically, so the peak stays at f(t0)f(t_0). The quadratic term shifts the energy centroid by about 124f′′T2\frac1{24}f''T^2, which grows with window length. That’s why the FM signal favours medium windows. ∎

Overlap-add identity

∑mw[n−mH]⋅w[n−mH]x[n]/∑mw2[n−mH]=x[n]\sum_mw[n - mH]\cdot w[n - mH]x[n] / \sum_mw^2[n - mH] = x[n] wherever the denominator is positive. The inverse FFT of each unmodified frame returns w[n−mH]x[n]w[n - mH]x[n] exactly. ∎

Exercise 3.1: window needed to separate 800 and 830 Hz with Hann at fs = 4 kHz

The main-lobe half-width is 2fs/N2f_s/N. It needs to be about 30 Hz or less, so N≳2⋅4000/30≈267N\gtrsim2\cdot4000/30\approx267; use 512 for a clear dip. The duration is then 128 ms, so clicks smear over ~0.1 s.

📝 Quick check (Level 3)
0/3 answered
  1. 1. A linear chirp's ridge is unbiased because…
  2. 2. The ridge bias from frequency curvature grows like…
  3. 3. Hann main-lobe width (first null to first null) is about…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Reaction-wheel run-up and a bearing click

A reaction wheel accelerates from 10 to 90 Hz in 4 s, with harmonics and sensor noise. A spectrogram (N = 512 at 2 kHz, bins of 3.9 Hz) with parabolic peak interpolation tracks the fundamental with 0.07 Hz RMS error, about a fiftieth of a bin. A 3 ms bearing click at 2.5 s is located to within 1 ms with a 32-sample window. With 512 samples it smears over a quarter of a second. Ground vibration tests of spacecraft wheels use this run-up analysis (a waterfall plot) to find harmonics that excite structural modes.

🐍 Exercise 2 (research): run-up tracking and transient detection
Compute magnitude spectrograms of a reaction-wheel run-up signal with harmonics, noise and a short click. Track the fundamental with sub-bin ridge interpolation, and locate the click with short and long windows.

Time–frequency analysis in AI, robotics and aerospace

  • Machinery and wheel health: waterfall and run-up plots, order tracking, transient detection.
  • Radar micro-Doppler: classifying drones, walkers and rotors from spectrogram signatures (Chen, 2011).
  • Speech and audio ML: log-mel spectrograms feed networks for speech recognition and sound event detection.
  • Space operations: RF interference monitoring, and detecting meteoroid or debris impacts in accelerometer data.

References

  1. J. Allen (1977). “Short term spectral analysis, synthesis, and modification by discrete Fourier transform.” IEEE Trans. ASSP, 25(3).
  2. D. Griffin, J. Lim (1984). “Signal estimation from modified short-time Fourier transform.” IEEE Trans. ASSP, 32(2).
  3. L. Cohen (1995). Time-Frequency Analysis. Prentice Hall.
  4. V. Chen (2011). The Micro-Doppler Effect in Radar. Artech House.
  5. J. Smith (2011). Spectral Audio Signal Processing. W3K Publishing (ccrma.stanford.edu/~jos/sasp).
  6. F. Auger, P. Flandrin (1995). “Improving the readability of time-frequency and time-scale representations by the reassignment method.” IEEE Trans. Signal Processing, 43(5).
  7. S. Davis, P. Mermelstein (1980). “Comparison of parametric representations for monosyllabic word recognition.” IEEE Trans. ASSP, 28(4).