Reference analyze()

analyze()

Returns an array of amplitude values (between 0 and 255) across the frequency spectrum. Length is equal to FFT bins (1024 by default). The array indices correspond to frequencies (i.e. pitches), from the lowest to the highest that humans can hear. Each value represents amplitude at that slice of the frequency spectrum. Must be called prior to using getEnergy().

Examples

Syntax

analyze([bins], [scale])

Parameters

bins
Number:

Must be a power of two between 16 and 1024. Defaults to 1024.

scale
Number:

If "dB," returns decibel float measurements between -140 and 0 (max). Otherwise returns integers from 0-255.

Returns

Array: spectrum Array of energy (amplitude/volume) values across the frequency spectrum. Lowest energy (silence) = 0, highest possible is 255.
Notice any errors or typos? Please let us know. Please feel free to edit lib/addons/p5.sound.js and open a pull request!

Related References