Skip to content

Realtime BPM AnalyzerDetect Tempo in Real-Time

A powerful, dependency-free TypeScript library for analyzing beats-per-minute (BPM) of audio and video sources directly in your browser

Quick Start

Install via npm:

bash
npm install realtime-bpm-analyzer

Analyze BPM in real-time:

typescript
import { createRealtimeBpmAnalyzer, getBiquadFilter } from 'realtime-bpm-analyzer';

// Create audio context
const audioContext = new AudioContext();

// Create the BPM analyzer processor
const bpmAnalyzer = await createRealtimeBpmAnalyzer(audioContext);

// Set up audio source
const track = document.getElementById('audio') as HTMLAudioElement;
const source = audioContext.createMediaElementSource(track);
const lowpass = getBiquadFilter(audioContext);

// Connect nodes
source.connect(lowpass).connect(bpmAnalyzer.node);
source.connect(audioContext.destination);

// Listen for BPM events
const handleBpm = (data) => console.log('Current BPM:', data.bpm);
const handleStable = (data) => console.log('Stable BPM detected:', data.bpm);

bpmAnalyzer.on('bpm', handleBpm);
bpmAnalyzer.on('bpmStable', handleStable);

// Cleanup when done
// bpmAnalyzer.removeEventListener('bpm', handleBpm);
// bpmAnalyzer.removeEventListener('bpmStable', handleStable);

Why Realtime BPM Analyzer?

🎵 Perfect for:

  • DJ applications and music players
  • Audio visualization tools
  • Music analysis platforms
  • Fitness and dance applications
  • Interactive audio experiences

Released under the Apache License 2.0