Skip to content

API Reference


API Reference / RealTimeBpmAnalyzer

Class: RealTimeBpmAnalyzer ​

Defined in: core/realtime-bpm-analyzer.ts:46

Core analyzer class for real-time BPM detection.

This class manages the state and logic for analyzing audio chunks in real-time to detect beats per minute. It's used internally by the AudioWorklet processor.

Remarks ​

Most users should use createRealtimeBpmAnalyzer instead of instantiating this class directly. This class is primarily for internal use or advanced scenarios.

Deprecated ​

This class is an internal implementation detail and will be removed in a future major release. Use createRealtimeBpmAnalyzer instead.

Constructors ​

Constructor ​

ts
new RealTimeBpmAnalyzer(options?): RealTimeBpmAnalyzer;

Defined in: core/realtime-bpm-analyzer.ts:80

Parameters ​

ParameterType
options?RealTimeBpmAnalyzerParameters

Returns ​

RealTimeBpmAnalyzer

Methods ​

updateComputedValues() ​

ts
updateComputedValues(): void;

Defined in: core/realtime-bpm-analyzer.ts:89

Update the computed values

Returns ​

void


reset() ​

ts
reset(): void;

Defined in: core/realtime-bpm-analyzer.ts:97

Reset BPM computation properties to get a fresh start

Returns ​

void


clearValidPeaks() ​

ts
clearValidPeaks(minThreshold): Promise<void>;

Defined in: core/realtime-bpm-analyzer.ts:109

Remve all validPeaks between the minThreshold pass in param to optimize the weight of datas

Parameters ​

ParameterTypeDescription
minThresholdnumberValue between 0.9 and 0.2

Returns ​

Promise<void>


analyzeChunk() ​

ts
analyzeChunk(options): Promise<void>;

Defined in: core/realtime-bpm-analyzer.ts:133

Attach this function to an audioprocess event on a audio/video node to compute BPM / Tempo in realtime

Parameters ​

ParameterTypeDescription
optionsRealtimeAnalyzeChunkOptionsRealtimeAnalyzeChunkOptions

Returns ​

Promise<void>


findPeaks() ​

ts
findPeaks(options): Promise<void>;

Defined in: core/realtime-bpm-analyzer.ts:219

Find the best threshold with enought peaks

Parameters ​

ParameterTypeDescription
optionsRealtimeFindPeaksOptionsOptions for finding peaks

Returns ​

Promise<void>

Properties ​

PropertyTypeDefault valueDescriptionDefined in
optionsRealTimeBpmAnalyzerOptions...Default configurationcore/realtime-bpm-analyzer.ts:50
minValidThresholdnumber...Minimum valid threshold, below this level result would be irrelevant.core/realtime-bpm-analyzer.ts:61
validPeaksValidPeaks...Contain all valid peakscore/realtime-bpm-analyzer.ts:65
nextIndexPeaksNextIndexPeaks...Next index (+muteTimeInIndexes samples, see consts.defaultMuteTimeInIndexes) to take care about peakscore/realtime-bpm-analyzer.ts:69
skipIndexesnumber...Number / Position of chunkscore/realtime-bpm-analyzer.ts:73
effectiveBufferTimenumber...-core/realtime-bpm-analyzer.ts:74
computedStabilizationTimeInSecondsnumber0Computed valuescore/realtime-bpm-analyzer.ts:78