Skip to main content

Fast audio analysis library with C++ and Python bindings

Project description

libsonare

PyPI npm License

Fast audio analysis library for Python.

Built on a C++ core with zero Python dependencies.

Installation

pip install libsonare

Supported platforms: Linux (x86_64, aarch64), macOS (Apple Silicon).

Quick Start

import libsonare

# From raw samples
bpm = libsonare.detect_bpm(samples, sample_rate=22050)
key = libsonare.detect_key(samples, sample_rate=22050)
print(f"{key.root.name} {key.mode.name}")  # e.g. "C MAJOR"

# Full analysis
result = libsonare.analyze(samples, sample_rate=22050)
print(f"BPM: {result.bpm}, Key: {result.key}")

# Audio class (load files directly)
audio = libsonare.Audio.from_file("song.mp3")
print(f"BPM: {audio.detect_bpm()}")
print(f"Key: {audio.detect_key()}")
print(f"Mel: {audio.mel_spectrogram().n_mels}x{audio.mel_spectrogram().n_frames}")

CLI

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}
sonare key song.mp3              # Key: C major (confidence: 100.0%)
sonare spectral song.mp3         # Spectral features table
sonare pitch song.mp3            # Pitch tracking (pYIN)
sonare mel song.mp3              # Mel spectrogram shape
sonare chroma song.mp3           # Chromagram with visualization

Features

  • Detection: BPM, key, beats, onsets
  • Analysis: Full music analysis (BPM + key + time signature + beats)
  • Effects: HPSS, pitch shift, time stretch, normalize, trim
  • Features: STFT, mel spectrogram, MFCC, chroma, spectral features, pitch tracking (YIN/pYIN)
  • Conversions: Hz/mel/MIDI/note, frames/time
  • I/O: Load WAV/MP3 files, resample

Compatibility

Default parameters:

  • Sample rate: 22050 Hz
  • n_fft: 2048
  • hop_length: 512
  • n_mels: 128

Also available

npm install @libraz/libsonare  # JavaScript/TypeScript (WASM)

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

libsonare-1.0.3-py3-none-manylinux_2_17_x86_64.whl (488.8 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

libsonare-1.0.3-py3-none-manylinux_2_17_aarch64.whl (450.6 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

libsonare-1.0.3-py3-none-macosx_11_0_arm64.whl (372.4 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file libsonare-1.0.3-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for libsonare-1.0.3-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 2c1a83cbe2a063572ab7ed3d2b01bb47268a4235711f63334df0782c9edb444d
MD5 3c6e4f77b48c1b6f7b0f36617223c29f
BLAKE2b-256 2b662855dc7b965c18b388a07b1ec6ef46d38977096e5e731778ce8f31f984d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for libsonare-1.0.3-py3-none-manylinux_2_17_x86_64.whl:

Publisher: publish.yml on libraz/libsonare

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libsonare-1.0.3-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for libsonare-1.0.3-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 745f182195915e80525f37da076384f87e2f783db4f3695276763dcc27edb115
MD5 bcbe1e6fddc8a3a79d83714fe68cb54d
BLAKE2b-256 c11301ae21d57c6b9d0731fd740a6c73c32ead45785c7376ff5be839c131b94a

See more details on using hashes here.

Provenance

The following attestation bundles were made for libsonare-1.0.3-py3-none-manylinux_2_17_aarch64.whl:

Publisher: publish.yml on libraz/libsonare

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libsonare-1.0.3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libsonare-1.0.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bf0dec966a168309bbf0f7c6c2988b91e0af93c6d26e212b1bed0a9e6b6ae68a
MD5 195a6330df1986464457b9f568414a2c
BLAKE2b-256 129e8228a9667fddece7b64a7b3e7bae9fc5cfa14f7b6ff0e64dc57251a698d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for libsonare-1.0.3-py3-none-macosx_11_0_arm64.whl:

Publisher: publish.yml on libraz/libsonare

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page