Analysis

Tempo and beats, spectrum, and silence.

On this page

Tempo and beats, spectrum, and silence.

audioBpm

Detect the tempo of audio and where its beats fall

audioBpm( audio, minBpm=60, maxBpm=200 )
ArgumentTypeDefault
audioanyrequiredThe audio buffer.
minBpmdouble60Lowest tempo to consider. Defaults to 60.
maxBpmdouble200Highest tempo to consider. Defaults to 200.

Returns A struct with bpm (0 if there is no clear pulse), confidence (0 to 1) and beats, the beat times in seconds.

audioSpectrum

Get the level of audio in log spaced frequency bands, in dB

audioSpectrum( audio, bands=16, minHz=40, maxHz=16000, start=0, seconds=0 )
ArgumentTypeDefault
audioanyrequiredThe audio buffer.
bandsinteger16How many bands. Defaults to 16.
minHzdouble40Lower edge of the first band. Defaults to 40.
maxHzdouble16000Upper edge of the last band, capped at half the sample rate. Defaults to 16000.
startdouble0Start in seconds. Defaults to 0.
secondsdouble0Length to analyse in seconds, 0 for the rest. Defaults to 0.

Returns An array of band levels in dB, lowest frequency first. -120 means nothing.

audioSpectrogram

Get the band levels of audio over time, for drawing or analysis

audioSpectrogram( audio, bands=16, frames=64, minHz=40, maxHz=16000 )
ArgumentTypeDefault
audioanyrequiredThe audio buffer.
bandsinteger16How many bands. Defaults to 16.
framesinteger64How many time slices. Defaults to 64.
minHzdouble40Lower edge of the first band. Defaults to 40.
maxHzdouble16000Upper edge of the last band. Defaults to 16000.

Returns An array of frames, each an array of band levels in dB.

audioFft

Get the frequency spectrum of one window of audio

audioFft( audio, size=2048, start=0 )
ArgumentTypeDefault
audioanyrequiredThe audio buffer.
sizeinteger2048FFT size, a power of two. Defaults to 2048.
startdouble0Where the window starts, in seconds. Defaults to 0.

Returns A struct with frequencies (Hz) and magnitudes (1 for a full scale sine), arrays of size/2+1 values.

audioDetectSilence

Find the silent stretches of audio

audioDetectSilence( audio, thresholdDb=-50, minSeconds=0.3 )
ArgumentTypeDefault
audioanyrequiredThe audio buffer.
thresholdDbdouble-50Level below which audio counts as silent, in dB. Defaults to -50.
minSecondsdouble0.3The shortest silence to report. Defaults to 0.3.

Returns An array of structs with start, end and duration in seconds.

audioTrimSilence

Cut the silence off the start and the end of audio

audioTrimSilence( audio, thresholdDb=-50, pad=0 )
ArgumentTypeDefault
audioanyrequiredThe audio buffer.
thresholdDbdouble-50Level below which audio counts as silent, in dB. Defaults to -50.
paddouble0Seconds of silence to keep on each side. Defaults to 0.

Returns A new audio buffer.

Edit this page Download Markdown Last updated Oct 16, 2026, 11:59:46 AM Report an issue