FFT decomposes audio into frequency bins that can be mapped to individual visual elements
The Fast Fourier Transform converts a time-domain audio buffer into an array of frequency bins, each bin representing the energy at a frequency band. In p5.sound, p5.FFT.analyze() returns an array of values (0–255) covering 0 Hz up to the Nyquist frequency (half the sample rate, ~22 050 Hz at 44.1 kHz). Each bin’s index maps to a frequency band, so visualizing the spectrum as a bar chart — one bar per bin, height proportional to energy — is the foundational audio-reactive display. The same bin array can drive particle systems, spectrographs (time × frequency heatmaps), or sculpted meshes.
Examples
let spectrum = fft.analyze(); for (let i = 0; i < spectrum.length; i++) { let x = map(i, 0, spectrum.length, 0, width); let h = map(spectrum[i], 0, 255, 0, height); rect(x, height - h, width/spectrum.length, h); }
Assessment
Describe what fft.analyze() returns and how a bar-chart spectrum maps bin index and bin value onto screen coordinates.