home/ atoms/ fft-waveform-dual-analysis

p5.FFT provides both frequency-domain analyze() and time-domain waveform() readings

The p5.FFT object exposes two analysis modes from a single class. fft.analyze() returns a frequency-domain snapshot: an array of values (0–255) representing energy across the spectrum from 0 Hz to Nyquist. fft.waveform() returns a time-domain snapshot: an array of values from -1 to 1 representing the raw waveform samples — the classic oscilloscope view. Both are computed on the same underlying Web Audio API AnalyserNode. The two representations are complementary: frequency domain reveals spectral content (what pitches/timbres), time domain reveals waveform shape (the pressure wave moment-by-moment).

Examples

Oscilloscope: let wave = fft.waveform(); for each sample draw a line segment. Spectrum: let spectrum = fft.analyze(); for each bin draw a rectangle.

Assessment

Given p5.FFT, describe the output of analyze() vs. waveform() — value range, and what each represents; name a visual application suited to each.

“`.analyze()` returns amplitude readings from 0-255 in the frequency domain. - `.waveform()` returns amplitude readings from -1 to 1 in the time domain.”
corpus · visualizing-music-with-p5-js-jason-sigal-audio-reactive-work · chunk 2