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 isNaN— no fake0.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
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dsp_audio_metrics-0.1.0.tar.gz.
File metadata
- Download URL: dsp_audio_metrics-0.1.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab96ebe98932fde1bb79a89b9290e6a0fbbb33f984e124591d72bfb4dded4412
|
|
| MD5 |
6b12acfdf787807a34005da0d06006a6
|
|
| BLAKE2b-256 |
9ca039c456de3a3d5833887e7745b8382c3fe80c62ad8da46c6896c3bc6beadd
|
File details
Details for the file dsp_audio_metrics-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dsp_audio_metrics-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
008a07090f33e193f3a5a7dbf71f4600468e3fa3b21b3988d3140d5e2cca445f
|
|
| MD5 |
d188c67efe929a95772b7ce9ae26c865
|
|
| BLAKE2b-256 |
68a6aa4a0e815f612389a052130a0a13270471b253fad61976e9a657f87f98bb
|