Skip to main content

dsp-audio-metrics

Pure numpy/scipy BS.1770-4 loudness metering and audio analysis for Python.

Measures integrated loudness (LUFS), loudness range (LRA), true peak (dBTP) per ITU-R BS.1770-4 / EBU R128, plus spectral balance, stereo-width and level helpers — with zero dependencies beyond numpy and scipy.

Install

pip install dsp-audio-metrics

Quick start

import numpy as np
import dsp_audio_metrics as dm

sr = 44100
t = np.arange(sr * 60) / sr
programme = 0.5 * np.sin(2 * np.pi * 997 * t)

res = dm.measure(programme, sr)
print(res.integrated_lufs)      # ~ -9.0 LUFS
print(res.true_peak_db)         # ~ -6.0 dBTP
print(res.gain_to_target_db)    # gain to hit -14 LUFS

normalized = dm.normalize_loudness(programme, sr, target_lufs=-14.0)

API

Loudness (BS.1770-4 / EBU R128)

Function Returns
integrated_lufs(audio, sr) integrated programme loudness in LUFS (-inf on silence)
short_term_lufs(audio, sr) (lkfs, times_s) per-window loudness
loudness_range(audio, sr) LRA in LU (NaN when unmeasurable)
true_peak_db(audio, sr) true-peak level in dBTP (oversampled to ≥ 192 kHz)
measure(audio, sr) LoudnessResult dataclass summary
normalize_loudness(audio, sr, target_lufs) gain-normalized copy

Analysis

Function Returns
band_balance(audio, sr) {sub, low, mid, high} energy percentages (mono mix)
stereo_width(audio, sr) (times_s, width_db, mid_db) per-window mid/side stats
rms_db(audio) / peak_db(audio) broadband level, dBFS
crest_factor_db(audio) peak/RMS ratio in dB

All functions accept mono (n,), (n, 1), stereo (n, 2) or multichannel (n, c) input and internally resample to the 48 kHz rate the standards mandate, so 44.1 kHz files are measured correctly.

Why this package

  • Correct: every loudness path follows BS.1770-4 (48 kHz measurement rate, K-weighting, two-stage gating, 4×-or-more true-peak oversampling).
  • Honest: silence is -inf, unmeasurable LRA is NaN — no fake 0.0.
  • Small: two hard dependencies, ~400 lines, no audio I/O, no UI.

References

  • ITU-R BS.1770-4 — Algorithms to measure audio programme loudness and true-peak audio level
  • EBU Tech 3341 / R128 — Loudness normalisation and permitted maximum level

License

Apache-2.0

Download files

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

Source Distribution

dsp_audio_metrics-0.1.1.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

dsp_audio_metrics-0.1.1-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file dsp_audio_metrics-0.1.1.tar.gz.

File metadata

  • Download URL: dsp_audio_metrics-0.1.1.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for dsp_audio_metrics-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b06ad7af450aa78d39c275e2edde0da1b8e4a42fcc350154bc2821271c0dc4e0
MD5 4e46aacb68c306636eff977b424cc343
BLAKE2b-256 602dd538feb438d78cac5fce551d3419c5e9a29a53dd2ba99e0ed2d141c7bfb1

See more details on using hashes here.

File details

Details for the file dsp_audio_metrics-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dsp_audio_metrics-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 faccbb8f191c3aeb23edfc1eee5f838015135b790dc5b7fb2fa32ca90b88a0d0
MD5 fd1bf6860222b4fadfd713c3518dd47b
BLAKE2b-256 dd349f6157718524795735e34c9b573c4f25f2cea8a0114223a5fbb8740dcc3e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

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