librosa-like audio analysis for C++, Python, and browsers. Fast, dependency-free, runs anywhere.
Tens of times faster than librosa/Python.
npm install @libraz/libsonare # JavaScript / TypeScript (WASM)
pip install libsonare # Pythonimport { init, detectBpm, detectKey, analyze } from '@libraz/libsonare';
await init();
const bpm = detectBpm(samples, sampleRate);
const key = detectKey(samples, sampleRate); // { name: "C major", confidence: 0.95 }
const result = analyze(samples, sampleRate);import libsonare
bpm = libsonare.detect_bpm(samples, sample_rate=22050)
key = libsonare.detect_key(samples, sample_rate=22050)
result = libsonare.analyze(samples, sample_rate=22050)
# Or use the Audio class
audio = libsonare.Audio.from_file("song.mp3")
print(f"BPM: {audio.detect_bpm()}, Key: {audio.detect_key()}")pip install libsonare
sonare analyze song.mp3
# > Estimated BPM : 161.00 BPM (conf 75.0%)
# > Estimated Key : C major (conf 100.0%)
sonare bpm song.mp3 --json
# {"bpm": 161.0}#include <sonare/sonare.h>
auto audio = sonare::Audio::from_file("music.mp3");
auto result = sonare::MusicAnalyzer(audio).analyze();
std::cout << "BPM: " << result.bpm << ", Key: " << result.key.to_string() << std::endl;| Analysis | DSP | Effects |
|---|---|---|
| BPM / Tempo | STFT / iSTFT | HPSS |
| Key Detection | Mel Spectrogram | Time Stretch |
| Beat Tracking | MFCC | Pitch Shift |
| Chord Recognition | Chroma | Normalize / Trim |
| Section Detection | CQT / VQT | |
| Timbre / Dynamics | Spectral Features | |
| Pitch Tracking (YIN/pYIN) | Onset Detection | |
| Real-time Streaming | Resample |
Dramatically faster than Python-based alternatives. Parallelized analysis with automatic CPU detection, optimized HPSS with multi-threaded median filter.
See Benchmarks for detailed comparisons.
Default parameters match librosa:
- Sample rate: 22050 Hz
- n_fft: 2048, hop_length: 512, n_mels: 128
- fmin: 0.0, fmax: sr/2
# Native (C++ library + CLI)
make build && make test
# WebAssembly
make wasm
# Release (optimized)
make release