libsonare
Turn audio into data and back, from Python. Analyze songs (BPM, key, chords, loudness), master and mix to broadcast loudness, and render MIDI through built-in instruments — a fast C++ core whose only Python dependency is NumPy 2.4.6 or later. Mastering ships 92 named DSP processors implemented against published references; analysis defaults match librosa where the two overlap. Apache-2.0, no model weights.
Guides, API reference and CLI docs: libsonare.libraz.net
Installation
pip install libsonare
Supported platforms: Linux (x86_64, aarch64), macOS (Apple Silicon).
Quick Start
import libsonare
audio = libsonare.Audio.from_file("song.mp3") # or "song.wav"
result = audio.analyze() # BPM + key + time signature + beats
print(f"BPM: {result.bpm:.1f} Key: {result.key.root.name} {result.key.mode.name}")
# Master toward a target loudness with a named preset
mastered = libsonare.master_audio(
audio.data, sample_rate=audio.sample_rate, preset_name="streaming",
)
print(mastered.output_lufs, mastered.applied_gain_db)
Render a MIDI arrangement through a built-in instrument with the headless Project (a context manager):
with libsonare.Project() as project:
project.set_sample_rate(48000)
_, clip_id = project.add_midi_clip(0.0, 4.0)
project.set_midi_events(clip_id, [
libsonare.Project.midi_note_on(0.0, 0, 0, 60, 100), # ppq, group, channel, note, velocity
libsonare.Project.midi_note_off(2.0, 0, 0, 60),
])
audio = project.bounce_with_synth_instrument("saw-lead", num_channels=2)
Samples passed directly must be mono float32 (downmix stereo first); the defaults follow librosa (22050 Hz, n_fft 2048, hop_length 512). See librosa compatibility.
Capabilities
- Analysis — BPM, key, chords, downbeats, sections, melody, tuning, pitch, timbre, spectral features and metering. → Analysis
- Stem decomposition and transcription —
decompose_stemssplits a mix into stems, andtranscribeturns audio into MIDI events. → Analysis, CLI examples - Mastering — 92 named DSP processors, the configurable
mastering_chain, 30 named presets viamaster_audio, and reference-matching. → Mastering processors - Restoration — five repair-only presets,
vinyl,tapeHiss,fieldRecording,voiceMemoandshellac78. → Mastering processors - Mixing — offline
mix_stereo, the block-basedMixerwith scene presets, andsuggest_mix_scene, which suggests a mixer scene with a written explanation without applying it. → Mixing, Mixing assistant - Editing DSP — time-stretch, pitch-shift, HPSS, phase vocoder, normalize, trim, remix. → Editing DSP
- Note editing and takes — edit the notes of monophonic takes (
extract_notes) and polyphonic material (PolyphonicAnalysis), align a take to a reference withalign_take_to_reference, and build tuning targets from a MIDI melody withnote_targets_from_smf. → Project editing, Recording and takes - Room acoustics — blind RT60, impulse-response metrics,
estimate_room,synthesize_rir,room_morph. → Room acoustics - Realtime and streaming —
RealtimeEnginewith MIDI 1.0 / 2.0 input, bus-to-bus routing with sends, sidechain keys (set_bus_sidechain),StreamAnalyzer,StreamingMasteringChainandRealtimeVoiceChanger. → Realtime engine - Instruments and synthesis — built-in synth, the patch-driven NativeSynth, and a GS-compatible SoundFont (SF2) player that receives GS SysEx and offers two GS insertion-effect realisations (
gs_efx_realization). The acoustic piano is calibrated; the other physical-model voices are still being tuned and will change in 1.8.x patch releases. → GM and GS, Native synth - Headless DAW —
Projectwith audio and MIDI tracks, undo/redo, SMF and MIDI 2.0 Clip File I/O, and offlinebounce;transcribe_to_clipwrites a transcription into a clip. → Project editing - Playback —
PlaybackRendererrenders PCM up to 7.1 to speakers or HRTF binaural headphones. → Playback
The whole surface is listed in the Python API reference.
CLI
The sonare command exposes the analysis, mastering, mixing, effects and project surfaces.
sonare analyze song.mp3 # BPM + key summary
sonare master song.wav -o mastered.wav --preset pop # preset mastering
sonare project bounce --in project.json -o out.wav --synth saw-lead
Run sonare --help, or see the CLI reference.
Supported audio formats
WAV and MP3 decode out of the box. M4A / AAC / FLAC / OGG / Opus need FFmpeg, which the PyPI wheels are built without; build from source with SONARE_FFMPEG=1 to enable it (see the installation guide).
Documentation
Getting started · Python API · CLI · Examples · Binding parity. The wheel bundles the JSON Schemas for realtime voice changer presets; see Realtime voice changer.
Also available
npm install @libraz/libsonare # JavaScript / TypeScript (WASM)
License
Apache-2.0
Metadata
Release files for libsonare 1.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| libsonare-1.8.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 | Details |
| libsonare-1.8.1-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 | Details |
| libsonare-1.8.1-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
Total release size: 15.2 MB
Release files / libsonare-1.8.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | libsonare-1.8.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
064deee9253399b3967ba51106e9ae1a3baefbffdf466251389adf2c5fb269f8
|
|
BLAKE2b-256 checksum How to use checksums |
c383092209b06ff1e19bd26148ac91956f43a40a8aa17c7478437ab5c7711961
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / libsonare-1.8.1-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
| Download URL | libsonare-1.8.1-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
5df237a229ac98c056c0c61ad0a73729f5b4c5d6d9f595ca7966a4fd002441db
|
|
BLAKE2b-256 checksum How to use checksums |
17792c88131968557d8907cd4f1c9bc31a167bb40a63102b6a2b638fe15d5d58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / libsonare-1.8.1-py3-none-macosx_11_0_arm64.whl
| Download URL | libsonare-1.8.1-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9c6197a8a6f87a35d5af661675e444f1e607d28db81d8e37b886edbbdda8897c
|
|
BLAKE2b-256 checksum How to use checksums |
bd4d169fea6a4c4241922b49e59eea26b0c0e4aa7d59a22777655ad2c7d2e6e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency log