Reference getPeaks()

getPeaks()

Returns an array of amplitude peaks in a p5.SoundFile that can be used to draw a static waveform. Scans through the p5.SoundFile's audio buffer to find the greatest amplitudes. Accepts one parameter, 'length', which determines size of the array. Larger arrays result in more precise waveform visualizations.

Inspired by Wavesurfer.js.

Syntax

getPeaks([length])

Parameters

length
Number:

length is the size of the returned array. Larger length results in more precision. Defaults to 5*width of the browser window.

Returns

Float32Array: Array of peaks.
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