Generate a signal, see its frequency spectrum (DFT) and watch frequency
content evolve over time (STFT spectrogram)
Frequency f₀ (Hz)220 Hz
Amplitude1.00
Sample Rate (Hz)8000
DFT Window N512
Window FunctionHanning
STFT Hop (samples)128
220
Peak freq (Hz)
15.6
Freq resolution (Hz)
4000
Nyquist (Hz)
Hanning
Window
0.71
RMS amplitude
How it works:
The Discrete Fourier Transform (DFT) decomposes a
window of N samples into N/2+1 frequency bins spaced Δf = fₛ/N Hz apart.
X[k] = Σn x[n]·w[n]·e−j2πkn/N where w[n] is the
window function. A Rectangular window has sharp
side-lobes; Hanning/Hamming reduce leakage;
Blackman offers best leakage suppression at the cost of
wider main lobe.
The Short-Time Fourier Transform (STFT) applies the DFT
repeatedly on overlapping frames (hop size = N − overlap) and stacks the
magnitude spectra into a coloured spectrogram. Time runs
left-to-right, frequency bottom-to-top, and colour intensity encodes
log magnitude.
Top-left: Time-domain waveform (2 cycles shown).
Bottom-left: DFT magnitude spectrum.
Right: STFT spectrogram (scrolling in real time).
Yellow = loud, dark blue = silent.