What is Realtime BPM Analyzer? โ
Realtime BPM Analyzer is a powerful, dependency-free TypeScript/JavaScript library that enables you to detect the beats-per-minute (BPM) or tempo of audio and video sources directly in the browser.
Key Features โ
๐ต Real-Time Analysis โ
Analyze BPM while audio or video is playing. Get instant feedback with both continuous updates and stable BPM detection events.
โก Zero Dependencies โ
Built entirely on the Web Audio API with no external dependencies. This keeps the library lightweight (< 5KB gzipped) and ensures compatibility across modern browsers.
๐ฏ Accurate Detection โ
Uses an advanced algorithm based on:
- Amplitude threshold scanning - Detects peaks in the audio signal
- Interval analysis - Identifies patterns in peak timing
- Tempo grouping - Groups similar tempos and selects the best candidates
๐ฌ Multiple Input Sources โ
Works with various audio sources:
- HTML
<audio>and<video>elements - File uploads (MP3, FLAC, WAV)
- Microphone/getUserMedia streams
- Network audio streams
- Any source compatible with Web Audio API
๐ฆ TypeScript Support โ
Written in TypeScript with complete type definitions for excellent IDE integration and type safety.
How It Works โ
The library analyzes audio data in real-time using the Web Audio API's AudioWorkletProcessor. Here's a simplified flow:
- Audio Input โ Audio is captured from your source
- Filtering โ Optional low-pass filter to isolate bass frequencies
- Peak Detection โ Identifies peaks in the audio signal at various threshold levels
- Interval Analysis โ Calculates time intervals between peaks
- BPM Calculation โ Converts intervals to BPM and groups similar tempos
- Result Output โ Emits BPM candidates with vote counts and a confidence share
Use Cases โ
Perfect for:
- ๐ง DJ Applications - Auto-sync tracks, beatmatching
- ๐ต Music Players - Display current track tempo
- ๐ Audio Visualization - Sync visuals to detected BPM
- ๐ช Fitness Apps - Match workout intensity to music tempo
- ๐น Music Production Tools - Analyze and catalog track tempos
- ๐ช Interactive Experiences - Create tempo-reactive installations
Browser Support โ
Works in all modern browsers that support:
- โ Web Audio API
- โ AudioWorklet
TIP
For older browser support, consider using a polyfill or fallback strategy.
Next Steps โ
Ready to get started?
- ๐ Getting Started - Install and use the library
- ๐ฏ Core Concepts - Understand key concepts
- ๐ก Examples - See practical examples