home/ modules/ extracting-loudness-and-spectrum

Extracting Loudness and Spectrum From Live Audio

  • learner can compute an RMS loudness value and a perceptually meaningful FFT spectrum from an audio stream
  • learner can rescale FFT bins logarithmically to match human pitch perception and read both frequency and waveform data
  • learner can derive a spectral-centroid brightness feature and explain what musical quality it tracks

From a running audio source, build an analysis readout that shows live RMS loudness, a log-scaled FFT spectrum, the time-domain waveform, and a spectral-centroid brightness number, and annotate which musical events move each meter.

Every audio-reactive rig — a p5.js visual layer riding on a TidalCycles or Ableton set, a VJ patch listening to the house feed — starts with the same question: what is the music doing right now? This module builds the answer as a whole artifact: a live analysis dashboard that turns a raw audio stream into four honest numbers-and-pictures — loudness, spectrum, waveform, brightness. In performance, this dashboard is what you map from; a bass drop, a hi-hat run, or a filter sweep each move a different meter, and knowing which is what makes your visuals feel musical rather than random.

The arc runs from supported to solo. Start with a single meter: wire up an amplitude analyser and lean on “RMS amplitude gives a perceptually smooth loudness value” to understand why you read RMS, not peaks, and why smoothing matters. Next, add the spectrum bar chart using the FFT-decomposition atom as your how-to, then confront its flaw — all the musical action squashed into a few bass bars — and fix it with “logarithmic and 1/3-octave FFT scaling”. Add the oscilloscope view via the dual analyze()/waveform() fact, and finally compute the centroid as a weighted mean over your existing bins. The capstone then removes the scaffolding: you assemble all four readouts yourself and annotate, by ear and eye, which musical events drive each.

Every required atom gates the capstone directly — drop any one and a panel of the readout can’t be built or explained. There are no supporting atoms here; this module is deliberately lean, a foundation the mapping and reactive-visuals modules build on.

Atoms in this module

Required — these gate the capstone

RMS amplitude gives a perceptually smooth loudness value between 0 and 1
Concept L2 First instrument JB
FFT decomposes audio into frequency bins that can be mapped to individual visual elements
Concept L2 First instrument JH
Logarithmic and 1/3-octave FFT scaling match frequency display to human pitch perception
Concept L3 Craft JH
p5.FFT provides both frequency-domain analyze() and time-domain waveform() readings
Fact L2 First instrument JH
The spectral centroid is the frequency-domain centre of mass of a sound spectrum and correlates with perceived brightness
Concept L2 First instrument JB