Skip to main content

libsonare

PyPI npm License Docs

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.0.2 or later. Mastering ships 95 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_stems splits a mix into stems, and transcribe turns audio into MIDI events. → Analysis, CLI examples
  • Mastering — 95 named DSP processors, the configurable mastering_chain, 30 named presets via master_audio, and reference-matching. → Mastering processors
  • Restoration — five repair-only presets, vinyl, tapeHiss, fieldRecording, voiceMemo and shellac78, plus repair of any channel count in one call (mastering_repair_analyze / mastering_repair_apply). → Mastering processors
  • Mixing — offline mix_stereo, the block-based Mixer with scene presets, and suggest_mix_scene, which suggests a mixer scene with a written explanation without applying it. → Mixing, Mixing assistant
  • Editing DSP — time-stretch, pitch-shift, auto_tune, 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 with align_take_to_reference, and build tuning targets from a MIDI melody with note_targets_from_smf, and edit vocal takes offline with undo/redo through create_vocal_edit_session. → Project editing, Recording and takes
  • Room acoustics — blind RT60, impulse-response metrics, estimate_room, synthesize_rir, room_morph, room_morph_stereo. → Room acoustics
  • Realtime and streaming — RealtimeEngine with MIDI 1.0 / 2.0 input, bus-to-bus routing with sends, sidechain keys (set_bus_sidechain), StreamAnalyzer, StreamingMasteringChain and RealtimeVoiceChanger (also an insert, voice.changer). → 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), with a selectable rig per part (set_part_rig). The acoustic piano is calibrated; the other physical-model voices are still being tuned and will change in 1.10.x patch releases. → GM and GS, Native synth
  • Headless DAW — Project with audio and MIDI tracks, undo/redo, SMF and MIDI 2.0 Clip File I/O, and offline bounce; transcribe_to_clip writes a transcription into a clip, and compile_timeline turns a project into a timeline a stopped RealtimeEngine plays. → Project editing
  • Playback — PlaybackRenderer renders PCM up to 7.1 to speakers or HRTF binaural headphones. → Playback
  • Parameter descriptors — capability_catalog, mastering_insert_param_info, synth_engine_param_info and synth_patch_param_info describe every parameter's range, default, unit, display scale and the other parameters that bound or switch it, so a host builds its controls without a hand-written table. → Build controls from descriptors

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.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for libsonare 1.10.0
File Interpreter ABI Platform Actions
libsonare-1.10.0-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 for libsonare-1.10.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
libsonare-1.10.0-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 for libsonare-1.10.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
libsonare-1.10.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for libsonare-1.10.0-py3-none-macosx_11_0_arm64.whl

Total release size: 18.5 MB

Release files / libsonare-1.10.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libsonare-1.10.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 7.0 MB
Tags Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
1a6068bf16951e6cbabe2cc9c0091af4fecdaaa0390a198be2026badaffd1e0c
BLAKE2b-256 checksum
How to use checksums
e82ea760756feb658879f01101ec72a51e6b7cdc3d1ed126ad3d36562518d09f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 27, 2026.

Transparency log

Release files / libsonare-1.10.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL libsonare-1.10.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 6.4 MB
Tags Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
062251901f55943f668099724771d2477f083d83babd81c4bd1c77eb3a07a7b5
BLAKE2b-256 checksum
How to use checksums
895e31307a06bbcb703c67f3c2a02733a3b8305d5a5f736e41ce127a10eaacf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 27, 2026.

Transparency log

Release files / libsonare-1.10.0-py3-none-macosx_11_0_arm64.whl

Download URL libsonare-1.10.0-py3-none-macosx_11_0_arm64.whl
Size 5.1 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
aba2fb11d59f9a01d0e1991be98ade42767eb63a71f870d124c4ee9acee66051
BLAKE2b-256 checksum
How to use checksums
9cb8df9e8f71cc10429b78bc1cc71d278694710d7821b7d24f0361fe9d9e9753
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 27, 2026.

Transparency log

Security for libsonare 1.10.0

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.

Full provenance

All 3 files in this release have been uploaded with provenance metadata.

Select from 3 files

Attestation for libsonare-1.10.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

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 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.10.0 This release

3 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page