CLI Reference
Complete reference for the sonare command-line interface.
Use the CLI when you want quick checks, batch jobs, or script-friendly JSON without writing application code. If you are building a UI, start with WebAssembly Guide, Python API, or Mixing Engine instead.
This page is the index of the CLI reference: which CLI carries which command, the global options, exit codes and format notes. The per-command reference is on CLI Commands, the editing commands on CLI Editing Commands, the mastering and repair commands on CLI Mastering and Repair, and the shell walkthroughs are on CLI Examples. For whole jobs carried end to end in the shell — stems to a finished master, a reference match, a delivery gate in CI — see Use Cases.
What You Will Learn
By the end of this page you should be able to:
- install the PyPI
sonarecommand and understand how it differs from the native CLI; - choose the right command for quick analysis, feature summaries, editing, mastering, acoustic checks, or simple mixing;
- decide when to use human-readable output and when to use
--jsonfor scripts; - recognize which workflows should move from CLI commands to Python, WASM, or native APIs.
First Commands To Try
| Goal | Command |
|---|---|
| Show the main summary | sonare analyze music.mp3 |
| Get only tempo | sonare bpm music.mp3 |
| Get only key | sonare key music.mp3 |
| Produce script-friendly output | sonare analyze music.mp3 --json |
Each of these also runs on the native CLI as sonare-cli <command> ....
What is a CLI?
CLI means Command Line Interface: a tool you run from a terminal. It is good for quick checks before integration, batch processing many files, and piping JSON into another script. If you are building a visual UI or live audio path, a WASM, Python, or C++ API is usually the better entry point.
Which CLI Are You Using?
There are two command-line entry points. They carry the same commands:
| CLI | Command name | How you get it | Best for |
|---|---|---|---|
| Python CLI | sonare | pip install libsonare | Installs next to the Python package; loads the native library at run time |
| Native CLI | sonare-cli | Release archive, or build from source with BUILD_CLI=ON | A standalone executable that needs no Python |
The native executable ships as sonare-cli in the FFmpeg-free Linux and macOS release archives (each with a SHA-256 checksum), so it installs alongside the Python sonare command instead of colliding with it. This page writes sonare in examples; substitute sonare-cli to run the same line on the native CLI.
Corresponding commands in both CLIs take the same options and use the same snake_case keys and payload shapes, so a script can read either one. Do not depend on byte-identical output: each front-end serializes independently. JSON values retain native precision; some focused human-readable summaries may still round. The --json payloads match across the two CLIs; the plain-text layouts do not (the native CLI prefixes result lines with > and prints Saved: where the Python CLI prints Wrote:; for gain, fade, filter, preemphasis, deemphasis, tone, chirp and clicks the Python CLI prints Saved to X), and the samples in these pages show the Python CLI.
Install via pip
The sonare CLI is installed from PyPI with the Python package:
pip install libsonare
sonare analyze music.mp3It is not installed by the npm WebAssembly package @libraz/libsonare.
The default PyPI wheels decode WAV and MP3. Rebuild with FFmpeg enabled for direct M4A/AAC/FLAC/OGG/Opus decoding.
Command Availability
Every command is on both CLIs, with one option contract each. A command in a gated family needs the matching feature in the build; sonare doctor lists the features a build carries. Get the native binary from a release archive, or see Building from Source.
| Family | Commands | Needs |
|---|---|---|
| Analysis | analyze, bpm, key, beats, downbeats, onsets, sections, chords, rhythm, dynamics, timbre, lufs, melody, boundaries, meter, clipping, dynamic-range, stereo, phase | — |
| Features | mel, chroma, spectral, pitch, onset-strength, tempogram, plp, nnls-chroma, fourier-tempogram, tempogram-ratio, tonnetz, cqt, vqt, pcen, mel-to-audio, mfcc-to-audio | — |
| Separation | hpss, decompose-stems | — |
| Notes and pitch editing | polyphonic-notes, polyphonic-render, vocal-notes, pitch-correct, pitch-correct-timevarying, note-move, note-stretch, scale-quantize | pitchEditor |
| Transcription | transcribe, tune-to-midi | arrangement, pitchEditor |
| Voice changer | voice-change, voice-presets, voice-preset, voice-preset-validate | voiceChanger |
| Editing | pitch-shift, time-stretch, normalize, trim-silence, split-silence, resample, gain, fade, filter, preemphasis, deemphasis | — |
| Room acoustics | acoustic | — |
estimate-room, synthesize-rir, room-morph | acousticSim, fx | |
| Mastering and repair | mastering, mastering-normalize-loudness, eq, repair, mastering-presets, mastering-profile, mastering-suggest, mastering-streaming, mastering-processors, mastering-processor, mastering-pair-processors, mastering-pair-processor, mastering-pair-analyses, mastering-pair-analyze, mastering-stereo-analyses, mastering-stereo-analyze | mastering |
| Mixing | mix | — |
mixing-presets, mixing-preset, mix-strip | mixing | |
suggest-mix | mixingAssistant | |
| Project and MIDI | project (abi, new, validate, compile, synth-presets, bounce, export-smf, import-smf, export-midi2, import-midi2, align-takes), midi-render | arrangement |
| Playback | playback | playback |
| Signal generators | tone, chirp, clicks | — |
| Numeric helpers (CLI Commands) | frames-to-samples, samples-to-frames, power-to-db, amplitude-to-db, db-to-power, db-to-amplitude, frame-signal, pad-center, fix-length, fix-frames, peak-pick, vector-normalize, system-info | — |
| Utility (CLI Commands) | info, version, doctor | — |
The mixer scene command is described in Mixing Workflow.
Overview
The sonare CLI is for terminal workflows: quick BPM/key checks, batch analysis, and JSON summaries for scripts. The heavy analysis runs in native C++ through the Python package, avoiding Python implementations of the DSP pipeline.
sonare <command> [options] <audio_file>Global Options
| Option | Description |
|---|---|
--json | Output results in JSON format |
--help, -h | Show help for command |
-o, --output | Output WAV path. Editing, mastering, eq, and mix commands write a WAV here; analysis/feature commands print to stdout and reject this option |
--n-fft <int> | FFT size. Most commands default to 2048 |
--hop-length <int> | Hop length. Most commands default to 512; melody defaults to 256, and the STFT-based editing and separation commands to n_fft/4 |
--n-mels <int> | Number of Mel bands (default: 128) |
--fmin-hz <hz>, --fmax-hz <hz> | Band edges, for the spectral and synthesis commands that take them |
--quiet, -q | Native CLI only. Suppress progress output |
sonare <command> --help lists only the options that command actually accepts and the default each one states, so the help is the authority for any one command. The DSP options above are accepted only by the commands that consume them: passing one to a command that ignores it is a usage error (exit code 2), rather than being silently dropped. So is an abbreviated option name, and an integer option outside the 32-bit range. --output on a command that produces no file is refused the same way.
Color is configured once at startup, so NO_COLOR in the environment — or sending stdout to a file or pipe instead of a terminal — disables ANSI escapes for the whole run.
--json outputs compact, script-friendly summaries. Feature commands such as mel and chroma do not dump full matrix data; they print dimensions and summary values.
Stereo and Mono Handling
Most CLI commands are mono by nature: the analysis they run, or the metering they report, is defined on one channel. Both front-ends decode a multi-channel input down to mono for those, and both print the same warning on stderr when they do, so a stereo file never loses its channels silently.
The commands that would deliver a worse result for it keep the pair instead:
| Command | Stereo input |
|---|---|
mastering, mastering-normalize-loudness | Mastered as a pair; the stereo image is preserved end to end |
eq, room-morph | A two-channel input is processed as a pair and written as a stereo file; --placement and --output-pan on eq act on the file's own channels. room-morph hears the target room at two receivers spaced --receiver-spacing metres apart (omitted, 0.5 where the pair fits around the listener, otherwise the largest spacing that fits; range above 0 up to 4). The JSON report carries stereo |
repair | A stereo input is measured per channel and repaired as a pair, writing a stereo file |
mastering-processor | A two-channel input is processed as a pair, and the result is written as a stereo file. A processor with no mono form (stereo.imager, eq.midSide, the multiband.* family) takes the stereo path from any input: a mono file is fed to both channels, and the output is stereo |
mix, mix-strip | Processed as a pair. A mono file is carried on both sides; a stereo one keeps its own two channels |
suggest-mix | Each --input keeps a stereo file as a pair instead of folding it, because the image analysis is the one part of the assistant that measures both channels. Each file is read at its own sample rate |
normalize | Kept as a pair. One gain is measured across both channels and applied to both: in --mode peak the louder channel lands on --target-db and the other keeps its level relative to it, and --mode rms measures the pair the same way. Normalizing each channel on its own would lift the quieter side until the two matched, which is a balance change, not a level change |
lufs | Measures every channel, summed as ITU-R BS.1770 specifies, so a stereo file reads its loudness as a pair |
playback | Keeps its channels, including 5.1 and 7.1 input |
| Everything else | Downmixed to mono, with a warning |
There is no option that selects the stereo path: the file's own channel count and the processor's own mono/stereo form decide it. mastering-processor refuses a --stereo flag as an unknown option (exit code 2) on both CLIs — drop the flag; a two-channel file takes the stereo path on its own. The JSON report says which path ran through its stereo field.
mastering-pair-processor, mastering-pair-analyze and mastering-stereo-analyze read each file as mono. For mastering-stereo-analyze the two mono files are the left and right channels of the pair under test.
Apart from playback, a source with more than two channels is always downmixed, because the offline operations come in a mono and a stereo form and nothing wider. Keeping channel 0 of a surround file and calling it the record would be worse than saying so.
When you need channel-preserving processing that the CLI does not offer, use the stereo entry points in the Python API or JavaScript API.
Supported Audio Formats
| Format | Extension | Notes |
|---|---|---|
| WAV | .wav | Uncompressed PCM |
| MP3 | .mp3 | Decoded using minimp3 |
| M4A / AAC / FLAC / OGG / Opus | varies | Supported only when libsonare is built with FFmpeg |
Check the active build from Python with libsonare.capabilities().features.ffmpeg.
Exit Codes
Both the Python and native CLIs use the following process-exit mapping, aligned with the C ABI error classes. The error contract shows the same failures as each library binding reports them.
| Code | Description |
|---|---|
| 0 | Success |
| 2 | Usage error: a refusal the command line alone decides (unknown option, unparsable number, missing required option, value outside its domain, conflicting options, wrong number of positionals), reported before any input is read |
| 3 | The library refused a parameter after the input was read |
| 4 | File not found: an input file could not be read |
| 5 | A document (JSON config, project, scene, MIDI) the library cannot parse |
| 6 | Decode failed |
| 7 | Out of memory |
| 8 | Not supported: the feature is compiled out of this build |
| 9 | Invalid state |
| 10 | Other error |
| 11 | Canceled |
| 12 | Encode failed: an output could not be produced or written, most often a -o path that cannot be written |
| 13 | ABI mismatch (Python CLI only) |
| 14 | Stale result |
Exit 13 exists only in the Python CLI: the pip package loads its native library at run time, and a library whose ABI version differs from the one the package was built against is refused before any work starts. The native CLI links its library statically and cannot skew. Installation covers the fix for 13.
Run sonare doctor if you are not sure whether a command is compiled into the build in front of you.
Performance Tips
Large files: For files over 10 minutes, consider analyzing segments:
bash# Analyze only first 60 seconds (using ffmpeg) ffmpeg -i long_song.mp3 -t 60 sample.wav sonare analyze sample.wavFFT size: On the commands that take it, a smaller FFT size (
--n-fft 1024) is faster but gives less frequency resolution.Hop length: On the commands that take it, a larger hop length (
--hop-length 1024) is faster but gives less time resolution.
Where to go next
| Page | What it holds |
|---|---|
| CLI Commands | Every analysis, feature, room and playback command, plus the utility commands and numeric helpers, with options and output |
| CLI Editing Commands | Editing, generators, split-silence, stem separation, voice presets and tune-to-midi |
| CLI Mastering and Repair | mastering, eq, the assistant commands, presets and chains, and repair |
| CLI Examples | Shell walkthroughs: analysis, batch, mixing, projects and MIDI |
| Use Cases | Whole jobs in the shell, from stems to a finished master |