API Reference
API Reference
Functions
| Function | Description |
|---|---|
| getBiquadFilter | Creates a biquad lowpass filter for audio processing. |
| analyzeFullBuffer | Detects the tempo of a whole decoded file at once. |
| createRealtimeBpmAnalyzer | Creates a real-time BPM analyzer for live audio. |
Classes
| Class | Description |
|---|---|
| BpmAnalyzer | Real-time BPM analyzer: the AudioNode-like EventTarget that createRealtimeBpmAnalyzer returns. |
Type Aliases
| Type Alias | Description |
|---|---|
| EngineName | The tempo engine. May grow in a minor release, like every exported union but Status: give a switch over it a default branch. |
| EngineOption | The realtime engine option: a bare name, or a name with the settings only that engine understands. Realtime and offline take different settings, so each has its own type and none is accepted where it does nothing. An object takes name and that engine's settings only: restartAfterSeconds for peaks, mode for tempogram. Any other key, such as lowpass (realtime peaks has a fixed lowpass inside analyzer.input) or a typo, makes the factory's promise reject with a TypeError that names it, whatever its value. null or undefined means the default, tempogram. |
| LowpassOption | The lowpass settings: the offline engine: {name: 'peaks', lowpass}, getBiquadFilter and Node's applyLowpass take the same ones. null or undefined means the defaults. Anything else that is not an object, an array included, throws a TypeError that names its type. No key but frequency and q is accepted: another throws a TypeError that names it, whatever its value, undefined included. That covers the 5.x names frequencyValue and qualityValue, the DOM's Q, detune, type and gain, which TypeScript lets through from a BiquadFilterOptions, and typos. Each setting is a finite number: another type throws a TypeError, and NaN or an infinity a RangeError, as does a value outside its range. |
| OfflineEngineOption | The offline engine option. Realtime peaks has a fixed lowpass inside analyzer.input, so only offline takes lowpass settings. The object form is peaks only, and takes name and lowpass only: any other key, such as restartAfterSeconds or a typo, makes the promise reject with a TypeError that names it, whatever its value. null or undefined means the default, tempogram. |
| TempoRange | Range every tempo is reported in, in BPM. max must be at least twice min, so every tempo has an octave inside it. max must be at most 2^31 - 1, so a whole BPM fits a signed 32-bit integer, and max / min must be a finite number; a value past either bound is refused with a RangeError. Default 90 to 180, the range Reading.confidence was measured on: any other range gives every reading confidence null, and an explicit {min: 90, max: 180} is the default. Any key other than min and max is refused with a TypeError that names it. |
| AnalyzerOptions | Options for the realtime analyzer. createRealtimeBpmAnalyzer checks them before it loads the processor: for an invalid value, the promise it returns rejects with a RangeError or a TypeError. It takes these keys only: any other own key, a typo included, rejects with a TypeError that names it, whatever its value. |
| OfflineOptions | Options for whole-buffer analysis, in the browser and in Node. Only these two keys: any other own key, a typo or a realtime option included, rejects with a TypeError that names it, whatever its value. |
| CandidateRelation | How a candidate's tempo relates to the reading's tempo. May grow in a minor release. |
| Candidate | Another tempo the engine considered. |
| AudioSpan | The audio a reading covers, in seconds of analysed audio since the epoch began (since the analyzer started or since the last reset()). Lost live input counted as silence is included, so this is audio time, not wall time. from <= to, and to never decreases within an epoch. |
| Reading | One measurement: the tempo the engine reports for a span of audio. |
| OfflineResult | Whole-buffer result: the same Reading realtime emits, or null when no tempo was found. audio spans the analysed buffer. |
| AnalyzerErrorName | Error names, after the DOM's ...Error names. May grow in a minor release. Serialisable through postMessage: never an Error instance. The detail is in message, which has no stable format. |
| AnalyzerError | - |
| Status | The analyzer's status, the discriminant of AnalyzerState. The one closed union: a new status would change what the existing ones mean, so it waits for a major release, and an exhaustive switch over it is safe. |
| ListeningReason | Why the analyzer is listening, so a late subscriber can tell a fresh start from a lost pulse or lost input. May grow in a minor release. |
| AnalyzerState | What the analyzer is doing now: a snapshot, like AudioContext.state. An object rather than a string, because each status carries its own fields. |
| EngineReason | Reasons the engine gives, inside a worklet message. May grow in a minor release. |
| CallerReason | Reasons that come from the caller: reset() and stop(). |
| StateChangeReason | Every reason a statechange can carry. May grow in a minor release: branch on to.status, which is closed, and treat an unknown reason as informational. |
| StateChange | Payload of statechange. to is the object analyzer.state holds at dispatch. A reset() while listening is a change too, from listening to listening: the epoch moved. |
| Progress | Payload of progress: the same number as state.progress. |
| Kick | Payload of kick: one kick drum the analyzer heard, as soon as it heard it, whichever engine runs. |
| DebugInfo | Engine detail, only with debug: true. Not part of the contract: its shape changes with any release. |
| AnalyzerEventMap | The analyzer's events. May grow in a minor release: a new event type is additive, as nobody listens to it yet. |
| AnalyzerEventType | - |
| ListenOptions | Options for on(), a subset of AddEventListenerOptions. |
Variables
RELATION_TOLERANCE
ts
const RELATION_TOLERANCE: 0.02 = 0.02;Defined in: contract/types.ts:162
Relative tolerance for half and double: 0.02 means within 2% of the exact ratio.