Skip to content

API Reference


API Reference / BpmAnalyzerEventMap

Type Alias: BpmAnalyzerEventMap ​

ts
type BpmAnalyzerEventMap = {
  bpm: BpmCandidates;
  bpmStable: BpmCandidates;
  analyzerReset: void;
  progress: BpmProgress;
  analyzeChunk: Float32Array;
  validPeak: {
     threshold: Threshold;
     index: number;
  };
  error: {
     message: string;
     error: Error;
  };
};

Defined in: core/types.ts:32

Type-safe event listener map for BPM analyzer events

Properties ​

PropertyTypeDescriptionDefined in
bpmBpmCandidatesEmitted continuously during BPM analysis with current tempo candidatescore/types.ts:34
bpmStableBpmCandidatesEmitted when BPM detection has stabilized with high confidencecore/types.ts:36
analyzerResetvoidEmitted when the analyzer state has been resetcore/types.ts:38
progressBpmProgressEmitted once per analysed chunk with how close the analyzer is to its first BPM. Remarks Not debug-only. After analyzerReset a progress event with peaks: 0 follows, so a progress bar can restart in step with the analysis. Example analyzer.on('progress', ({peaks, requiredPeaks}) => { progressBar.value = peaks / requiredPeaks; });core/types.ts:51
analyzeChunkFloat32ArrayEmitted in debug mode when analyzing audio chunkscore/types.ts:53
validPeak{ threshold: Threshold; index: number; }Emitted in debug mode when a valid peak is detectedcore/types.ts:55
validPeak.thresholdThreshold-core/types.ts:55
validPeak.indexnumber-core/types.ts:55
error{ message: string; error: Error; }Emitted when an error occurs during processing. Remarks Worklet-load failures thrown by createRealtimeBpmAnalyzer wrap the underlying cause via Error.cause (ES2022). Inspect error.cause to read the originating DOMException. Example analyzer.on('error', ({error}) => { console.log(error.message); console.log((error as Error).cause); });core/types.ts:70
error.messagestring-core/types.ts:70
error.errorError-core/types.ts:70