Skip to main content

Function: analyzeAudio()

function analyzeAudio(source, options?): Promise<Peaks>;

Defined in: analyzer.ts:261

Decodes an audio file once, on a background thread and in constant working memory, and returns per-bucket statistics (min, max, RMS) at a fixed resolution. Turn them into bars with resample as often as needed — changing the bar count, zooming or switching metrics never decodes again.

Formats: WAV, FLAC, MP3 and OGG Vorbis everywhere, plus what the platform decodes — AAC/M4A on iOS and Android, ALAC/AIFF/CAF on iOS, Opus on Android.

Parameters​

ParameterType
sourceAudioSource
options?AnalyzeOptions

Returns​

Promise<Peaks>

Example​

const peaks = await analyzeAudio('https://example.com/song.mp3');
const bars = normalize(resample(peaks, 64));