home/ modules/ spectral-analysis-and-processing

Spectral analysis and processing: FFT, STFT, and the phase vocoder

  • learner can perform windowed spectral analysis (DFT/FFT/STFT), read spectrograms, and reason about the time-frequency resolution tradeoff
  • learner can process audio in the spectral domain with overlap-add, phase vocoder, and cross-synthesis for time/pitch and timbre transformation
  • learner can apply multiresolution analysis and spectral mapping to advanced sound-design and tuning problems

Use a phase vocoder to time-stretch a recording 2x without pitch change and pitch-shift it up a fifth without tempo change; then cross-synthesize its spectral envelope onto a synth pad, explaining the STFT parameters you chose.

Every live coder eventually hits the wall where sample manipulation stops being enough: the vocal chop needs to stretch across two bars without turning into a chipmunk, the found-sound texture needs to sit in the mix at a different tempo, the ambient set needs a pad that breathes with the formants of a field recording. This module builds toward that whole task — fluent spectral-domain transformation of real material, live, with parameter choices you can defend.

The arc starts supported. You first compute a DFT by hand (the double-loop pseudocode makes the phasor accumulation concrete), then immediately confront why real sounds need windowing to tame spectral leakage. From there you slide the window along a drum loop to build a spectrogram, drilling the habit that anchors everything downstream: reading time-frequency plots and choosing window length against the resolution tradeoff. A real-time spectroscope on your rig makes this a performance skill, not just a plotting exercise. Mid-module the scaffolding loosens — overlap-add reconstruction shows how block-based effects avoid boundary artifacts, and the phase vocoder atoms hand you the machinery to decouple time from pitch, exactly what naive rate-change playback cannot do. The capstone then removes the rails: stretch, shift, and cross-synthesize a recording of your choosing, justifying FFT size, window, and hop.

The required atoms gate this directly — you cannot pick sane STFT parameters without the tradeoff principle, nor explain vocoder artifacts without phase-frame reasoning, nor complete the final capstone step without cross-synthesis, the bin-by-bin spectral multiplication that imposes one sound’s envelope on another; the two L4 procedures (spectral mapping, scale design for inharmonic sources) extend the same toolkit into experimental tuning territory. Supporting atoms enrich the why: Gabor’s uncertainty relation grounds the tradeoff, convolution duality explains cross-synthesis as spectral multiplication, and critical-band psychoacoustics tells you which spectral details the audience will actually hear.

Runnable examples

Generated from the context/ instrument corpus by concept (redistributable idioms only). Do not edit — regenerate with gen-module-examples.mjs.

reverse-playback

d1 $ sound "bd sn" # speed "-1"

tidal-0056 · CC0

Atoms in this module

Required — these gate the capstone

FFT analysis of real sounds requires windowing to reduce spectral leakage from discontinuous segment boundaries
Concept L2 First instrument B
The DFT computes each frequency bin by accumulating every input sample times a rotating phasor
Procedure L2 First instrument B
The STFT slides a Fourier analysis window along a signal to create a time-frequency spectrogram
Concept L2 First instrument BF
A spectrogram is a time-frequency power map created by computing the STFT frame-by-frame and plotting energy per bin
Concept L2 First instrument BJ
The STFT window length trades time resolution against frequency resolution and cannot give both at once
Principle L2 First instrument BJ
Overlap-add processing reconstructs audio from overlapping FFT windows without boundary artifacts
Concept L3 Craft B
The phase vocoder converts audio to a time-varying spectrum enabling pitch-time manipulation
Concept L3 Craft B
The phase vocoder enables independent time-stretching and pitch-shifting by operating on FFT analysis frames
Procedure L3 Craft B
Time-stretching and pitch-shifting are decoupled operations requiring phase vocoder or WSOLA rather than sample rate change
Concept L2 First instrument BCD
Cross-synthesis imposes the spectral envelope of one sound onto another by multiplying their spectra
Concept L3 Craft BJ
Wavelet analysis uses variable-length windows for better time resolution at high frequencies
Concept L3 Craft B
Spectral mapping transforms the partials of one sound to a target spectrum while preserving the overall tonal character
Procedure L4 Performance B
Designing a scale for an inharmonic instrument requires FFT analysis followed by computing dissonance curve minima
Procedure L4 Performance BA

Supporting — enrichment, not gating

Time resolution and frequency resolution in windowed analysis are inversely constrained
Principle L2 First instrument B
Convolution in the time domain equals multiplication in the frequency domain, and vice versa
Principle L2 First instrument B
Coloured noise is made by scaling each DFT bin of white noise by 1/f^B before inverse-transforming
Procedure L3 Craft B
A spectroscope displays a signal's spectral content — amplitude vs. frequency — in real time
Concept L2 First instrument BN
The critical band is the ear's frequency resolution width; partials within it interfere and cause roughness
Concept L2 First instrument BA
The auditory system resolves frequency within critical bands: components within one band interact, components in separate bands do not
Concept L3 Craft BJ
Changing a sample's playback rate simultaneously shifts its pitch and duration
Principle L1 Foundations FB