DSP 101
M9 · Lab
Hands-on lab
Read the time-frequency trade-off

Run the Short-Time Fourier Transform on a chirp in the sandbox, and predict — before you read it off the screen — the frequency resolution each window gives, the hop between frames, and how shrinking the window trades finer time for coarser frequency.

The Short-Time Fourier Transform
X_m[k] = \sum_{n=0}^{N-1} x[n + mR]\, w[n]\, e^{-j 2\pi k n / N}

A spectrogram is a stack of DFTs taken over short windows, so every setting is a compromise: a long window resolves close frequencies but smears events in time, and a short window pins events in time but blurs the frequency axis. The product Δt·Δf is fixed at 1 — you cannot sharpen both. Reading f_s/N, the hop and that trade-off off a real STFT is how you choose a window on purpose, not by default.

1 / 7
DSP 101
M9 · Lab
Set it up
One chirp

Open the sandbox. It opens on exactly this state — a chirp at f_s = 8000 Hz with an N = 256-sample Hann window at 50% overlap — so a Reset gets you here too. Each step names the one knob to change; leave everything else alone.

Set these values
Signal -> Chirp f_s -> 8000 Hz Window -> Hann Window length N -> 256 Overlap -> 50% (change only in Step 3)

Watch the frequency-resolution readout, the frame/hop readout and the comparison panel — every number you predict is printed there.

2 / 7
DSP 101
M9 · Lab
Step 1 of 3
The frequency resolution

Keep the defaults: an N = 256-sample window, f_s = 8000 Hz. Each DFT bin spans f_s/N hertz — that is the frequency resolution. Predict it, then read the resolution readout.

Expected

The frequency resolution is f_s/N = 8000 / 256 = 31.25 Hz per bin — two tones closer than that fall in the same bin and cannot be told apart.

3 / 7
DSP 101
M9 · Lab
Step 2 of 3
The hop between frames

Still N = 256, overlap 50%. The window advances by a hop of R = N·(1 - overlap) samples between frames. Predict the hop in samples, then read the frame/hop readout.

Expected

The hop is R = 256 · (1 - 0.50) = 128 samples — at f_s = 8000 Hz that is a new spectrum every 128 / 8000 = 16 ms.

4 / 7
DSP 101
M9 · Lab
Step 3 of 3
Shrink the window, watch the trade-off

Drag N down to 64 samples. The window now covers only 64 / 8000 = 8 ms instead of 32 ms — finer in time. Predict the new frequency resolution f_s/N, then read it.

Expected

The frequency resolution drops to f_s/N = 8000 / 64 = 125 Hz per bin — 4× coarser than the 256-sample window's 31.25 Hz, in exchange for a window 4× shorter in time (8 ms vs 32 ms). The product Δt·Δf = 1 — you cannot sharpen both.

5 / 7
DSP 101
M9 · Lab
Your turn
Open the sandbox

Everything above is waiting in the sandbox. Sweep the window length and watch the spectrogram trade time smear for frequency blur, change the window shape, raise the overlap, and switch between speech-like and music-like signals to see which window each one wants.

6 / 7
DSP 101
M9 · Lab
Wrap-up
What you did
  • Read the frequency resolution of a 256-sample window, f_s/N = 31.25 Hz
  • Found the hop between frames at 50% overlap, R = 128 samples (a spectrum every 16 ms)
  • Shrank the window to 64 samples and watched resolution coarsen to 125 Hz while the frame narrowed to 8 ms — the time-frequency trade-off
  • Every value you predicted is the demo's own STFT arithmetic, not a picture
7 / 7
1 / 8 muted