Skip to content

Discrete-time Fourier analysis

Spectral analysis in practice

A record is finite, so a tone between FFT bins leaks into every bin. This topic covers windowing and spectral leakage, compares window functions, shows what zero-padding does and does not do for resolution, reads a spectrum in volts or power per hertz, and builds and inverts spectrograms with the short-time Fourier transform (STFT).

Lessons on this topic

Top: 32 samples of a cosine at k₁ = 8.50 bins, as stems from sample 0 to 31. Bottom: the DFT as bars at bins 0 to 16, sizes ÷ (N/2), on the dashed spectrum of the cut tone; a triangle marks the tone at 8.50 bins. Tallest bar 8 at 0.6407; bar 7 0.2183, bar 9 0.6346; bar 16 0.0625. 59.0 % of the energy is outside the peak bar and its mirror.Top: 32 samples of a cosine at k₁ = 8.50 bins, as stems from sample 0 to 31. Bottom: the DFT as bars at bins 0 to 16, sizes ÷ (N/2), on the dashed spectrum of the cut tone; a triangle marks the tone at 8.50 bins. Tallest bar 8 at 0.6407; bar 7 0.2183, bar 9 0.6346; bar 16 0.0625. 59.0 % of the energy is outside the peak bar and its mirror.

Intermediate · 20 minYou are hereRead

Windowing and spectral leakage

See why a tone between bins spreads into every bin, then taper the record’s ends so a weak tone beside a strong one stands out.

The flat-top window. Shape panel: w[n] against n/N from 0 to 1. Spectrum panel: |W| in dB relative to its peak, against the offset from the tone, 0 to 16 bins. Main lobe 10.0 bins; the bracket marks half of it, from 0 to the first zero at 5.0 bins. A dotted level marks the highest side lobe, −93.0 dB.The flat-top window. Shape panel: w[n] against n/N from 0 to 1. Spectrum panel: |W| in dB relative to its peak, against the offset from the tone, 0 to 16 bins. Main lobe 10.0 bins; the bracket marks half of it, from 0 to the first zero at 5.0 bins. A dotted level marks the highest side lobe, −93.0 dB.

Intermediate · 22 minYou are hereRead

Window functions compared

Compare five classic windows and the Kaiser family by main lobe, side lobes, scalloping loss, coherent gain and noise bandwidth, then pick one for a measurement.

Top: the 32 samples of the tone as stems, then 480 zeros added, to n = 511. Bottom: size ÷ (N/2) against frequency from 0 to 2000 Hz. The DTFT of the 32 samples as a dashed curve, peaking at 1100.4 Hz with size 0.998; a triangle marks the tone at 1100 Hz. 512 FFT points, every 15.625 Hz, 129 of them from 0 to 2000 Hz, all on the curve; the highest, ringed, at 1093.75 Hz with size 0.997.Top: the 32 samples of the tone as stems, then 480 zeros added, to n = 511. Bottom: size ÷ (N/2) against frequency from 0 to 2000 Hz. The DTFT of the 32 samples as a dashed curve, peaking at 1100.4 Hz with size 0.998; a triangle marks the tone at 1100 Hz. 512 FFT points, every 15.625 Hz, 129 of them from 0 to 2000 Hz, all on the curve; the highest, ringed, at 1093.75 Hz with size 0.997.

Intermediate · 20 minYou are hereRead

Zero-padding and resolution

Append zeros to a record and the FFT points come closer on the same curve. See why padding cannot split two tones, and how a parabola finds a peak between bins.

Spectrum of a 1 V, 1000 Hz tone plus noise, N = 1024, Hann window, against frequency from 0 to 4000 Hz, scaled as a² ÷ 2: power; vertical axis dB re 1 V² from −70 to 60. The tone's bin at 1000 Hz is ringed and reads −3.0 dB re 1 V². A dashed truth line at −3.0 dB is labelled 0.5 V² (−3.0 dB).Spectrum of a 1 V, 1000 Hz tone plus noise, N = 1024, Hann window, against frequency from 0 to 4000 Hz, scaled as a² ÷ 2: power; vertical axis dB re 1 V² from −70 to 60. The tone's bin at 1000 Hz is ringed and reads −3.0 dB re 1 V². A dashed truth line at −3.0 dB is labelled 0.5 V² (−3.0 dB).

Intermediate · 22 minYou are hereRead

Reading a spectrum: scaling and units

Turn raw FFT numbers into volts, volts squared or volts squared per hertz, and learn which one reads a tone true and which reads noise true.

Signal sampled at 8 kHz: 1000 Hz for 0.25 s, then 2000 Hz, with its spectrogram below, frames of 256 samples every 16 ms. The spectrogram is complete: 33 columns, full ink at 1000 Hz up to 250 ms and at 2000 Hz after it.Signal sampled at 8 kHz: 1000 Hz for 0.25 s, then 2000 Hz, with its spectrogram below, frames of 256 samples every 16 ms. The spectrogram is complete: 33 columns, full ink at 1000 Hz up to 250 ms and at 2000 Hz after it.

Intermediate · 19 minYou are hereRead

Spectrograms and the STFT

Cut a recording into windowed frames, take an FFT of each, and read the picture: tones as lines, clicks as stripes, glides as slopes.

Hann windows of 64 samples, one every 16 samples (75 % overlap), drawn as thin lines on sample n from 0 to 320, neighbours alternating solid and dotted. Their sum, a thick dashed line, is flat at 2.000.Hann windows of 64 samples, one every 16 samples (75 % overlap), drawn as thin lines on sample n from 0 to 320, neighbours alternating solid and dotted. Their sum, a thick dashed line, is flat at 2.000.

Advanced · 25 minYou are hereRead

Inverting the STFT

Add the frames of a spectrogram back to recover the sound, edit cells to erase or denoise it, and stretch time without changing pitch.

Phasorium

Account

Sign inWith Google, GitHub or your email

Subjects

Site

Look