detectBPM
detectBPM(
input,options?):Promise<any>
Defined in: packages/pleco-xa/src/scripts/xa-bpm-detection.js:24
Detect BPM from audio.
Input contract (explicit — no silent guessing):
- An AudioBuffer (channel 0 and its sampleRate are read), or
- A Float32Array of raw mono PCM, in which case
options.sampleRate(a positive number) is REQUIRED. Anything else throws a TypeError with a clear diagnostic. A genuine detection failure on valid audio (no steady pulse found) resolves to { bpm: null, confidence: 0, error } rather than a fabricated tempo.
Parameters
Section titled “Parameters”AudioBuffer | Float32Array<ArrayBufferLike>
Audio to analyze
options?
Section titled “options?”any = {}
Detection options (sampleRate required for Float32Array)
Returns
Section titled “Returns”Promise<any>
BPM result