Skip to content
librazPublic

About

Dependency-free audio engine for C++, Python, Node.js & WASM: analysis, mastering, mixing, built-in instruments, and a headless-DAW runtime

Topics

Resources

Contributing

Security policy

Stars

32 stars

Watchers

0 watching

Forks

Repository files navigation

libsonare

CI npm PyPI codecov License C++17 Platform Docs

libsonare turns audio into data and data back into audio. Load a song to get its BPM, key, chords, and structure. Master and mix it to broadcast loudness, turn MIDI into sound with built-in instruments, or build a DAW. C++, Python, Node.js, and the browser share the same engine. Optional codec support can add runtime dependencies to the C++ core. The Python package depends on NumPy. There is no GPL/AGPL code or model weights.

📖 Documentation  ·  🎧 Browser-local demos  ·  Getting started

sonare studio

sonare studio is a browser-based DAW whose audio runs on the libsonare WASM engine: multi-track playback, instruments, mixer, mastering, and audio export, all client-side. Its music theory and composition features come from @libraz/libcantus, and score rendering from a separate library. It is a hosted live demo that exercises the engine end to end, not a production product. Source: libraz/sonare-studio.

What's inside

  • Analysis — BPM, key, chords, beats, sections and which of them repeat, pitch, tuning, loudness (EBU R128), and room acoustics; defaults match librosa where they overlap, and CI checks them against librosa reference values. Analysis
  • Stems and transcription — split a mix into stems with decomposeStems, and transcribe audio to MIDI with transcribe, which has a singing model that keeps vibrato and intonation drift inside one note. Source separation · Audio to notes · CLI transcribe
  • Mastering — Named DSP processors (EQ, dynamics, multiband, stereo, saturation, repair, maximizer, reference matching), restoration presets (vinyl, tape hiss, field recording, voice memo, shellac 78), and repair that works on audio of any channel count. Mastering processors · Mastering assistant · Audio repair
  • Mixing and routing — channel strips, buses, sends, bus-to-bus routing, track- or bus-keyed sidechains, scene presets, and an optional assistant that suggests a mixer scene. Mixing · Realtime engine · Mixing assistant
  • Editing and creative FX — time stretch, pitch shift, pitch correction (including auto-tune to a detected key), voice change, reverbs, modulation, delay, and amp sim. Editing DSP · Spectral editing
  • Note editing and takes — edit notes of monophonic and polyphonic takes, align a take to a reference (alignTakeToReference), tune it to a MIDI melody (tune-to-midi), and edit vocal takes offline with undo/redo (createVocalEditSession). MIDI editing · Takes
  • Room acoustics — synthesize, estimate, and morph room impulse responses, in stereo too. Acoustic analysis
  • Built-in instruments — a NativeSynth with 18 synthesis engines, one of them a singing voice, and a GM/GS fallback covering all 128 programs, with a selectable rig per part (setPartRig). The acoustic piano is calibrated; the other physical-model voices are still being tuned and will change in 2.0.x patch releases. NativeSynth · Physical models
  • GS and SoundFont — GS SysEx reception, two realisations of the GS insertion effects (modern and classic), and a GS-compatible 16-part SF2 player for host-supplied SoundFonts. The effects.gsEfx insert applies either realisation to audio tracks and buses. GM/GS · SoundFont player
  • Headless DAW runtime — projects with audio and MIDI tracks, takes, warp, MIDI 1.0/2.0 sequencing, SMF I/O, offline bounce, and compilation into a timeline the realtime engine plays (compile({ withTimeline: true })). Project editing
  • Realtime engine — allocation-free playback, streaming, live MIDI 1.0/2.0 input, lock-free automation, recording, and a voice changer (low-latency pitch shifting, auto pitch and robot, scale harmony, MIDI note input, a channel vocoder with an internal or external carrier, megaphone, radio, chorus and strobe character, echo and tempo delay) that also runs as an insert, in the browser through an AudioWorklet too. Realtime engine · MIDI input
  • Playback renderer — channel conversion, loudness matching, bass management, and HRTF binaural rendering for headphones and speakers. Playback
  • Parameter descriptors — capabilityCatalog(), synthEngineParamInfo and synthPatchParamInfo provide defaults and applicable ranges, units, display scales and conditions. Patch enum descriptors list accepted tokens and their default. Build controls from descriptors
  • C++ package — the C++ library installs as a CMake package (find_package(sonare)). C++ API

Installation

npm install @libraz/libsonare   # JavaScript / TypeScript (WASM, takes Float32Array)
pip install libsonare            # Python (built-in WAV and MP3 decoding, and WAV encoding)

@libraz/libsonare-native is not published to npm; clone this repository and use it as a local dependency. See Installation for formats, FFmpeg, and the runtime choice. Each binding checks the native module's ABI version on load and refuses a mismatch (AbiMismatch).

Quick start

JavaScript / TypeScript (WASM)

import { Audio, init } from '@libraz/libsonare';

await init();

const bytes = new Uint8Array(await file.arrayBuffer());
const audio = await Audio.fromMemoryWithBrowserFallback(bytes);
const result = audio.analyze(); // BPM, key, chords, sections, ...
console.log(result.key.name);

→ JavaScript API · Browser / WASM

Python

import libsonare

audio = libsonare.Audio.from_file("song.mp3")
print(f"BPM: {audio.detect_bpm()}, Key: {audio.detect_key()}")

result = audio.mastering(target_lufs=-14.0, ceiling_dbtp=-1.0)
print(f"{result.input_lufs:.1f} LUFS → {result.output_lufs:.1f} LUFS")

The sonare command-line tool ships with the Python package; the native CLI is sonare-cli. → Python API · CLI

C++

find_package(sonare REQUIRED)
target_link_libraries(app PRIVATE sonare::sonare)
#include <iostream>

#include "sonare.h"

int main() {
  auto audio = sonare::Audio::from_file("music.mp3");
  auto result = sonare::MusicAnalyzer(audio).analyze();
  std::cout << "BPM: " << result.bpm
            << ", Key: " << result.key.to_string() << '\n';
}

→ C++ API

Build from source

make build && make test   # native
make wasm                  # WebAssembly
make release               # optimized native build

Build options (BUILD_MASTERING, BUILD_MIXING, BUILD_MIXING_ASSISTANT, FFmpeg) are covered in Architecture.

Documentation

Full docs and browser-local demos live at libsonare.libraz.net.

Every runtime calls the same C++17 DSP core, but each API surface is hand-written and not identical; see Binding parity and the generated runtime capability matrix.

Non-goals

libsonare is the headless engine, not an application. It does not include a UI or DAW workflow, VST/CLAP plugin hosting, a cross-platform real-time I/O abstraction, bundled sample data, or deep-learning models. Windows is not supported; use Linux, macOS, WebAssembly, or WSL2. Note-level composition belongs to the separate @libraz/libcantus. See Architecture for the rationale.

License

Apache-2.0

About

Dependency-free audio engine for C++, Python, Node.js & WASM: analysis, mastering, mixing, built-in instruments, and a headless-DAW runtime

Topics

Resources

Contributing

Security policy

Stars

32 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages