Skip to main content

Dynamic Range (DR) algorithm implementation in python

Project description

Dynamic Range (DR) meter ๐ŸŽง

Tests Coverage Status Docker

PyPI PyPI - Python Version PyPI - Downloads

Linter/Formatter: Ruff Code style: Black Dependency management: poetry

A Dynamic Range (DR) analyzer for audiofiles.

Asciicast of installing and using drmeter

The algorithm has been reverse-engineered using the available information and officially endorsed software to calcuate the DR value. The analysis results of drmeter are verified to be within a ยฑ0.5 absolute tolerance from the results produced by officially endorsed software (see #testing).

This project is in no way affiliated with the Pleasurize Music Foundation or its Dynamic Range Project.

Installation

The recommended method for installing drmeter is pipx:

pipx install drmeter

Any regular pip install drmeter will do, too. The drmeter requires Python 3.9+ to run.

To use drmeter without installation, consider the dockerized approach below

Usage

See drmeter --help for usage instructions. drmeter expects a single path to a file or a directory to analyze, and defaults to an "animated" progress display, emitting the results to stdout in the process.

$ drmeter 'Nobody There (Beautiful Scars).wav'
Analyzing Dynamic Range of Nobody There (Beautiful Scars).wav ...

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ DR            Peak          RMS   Filename                           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ DR12      -0.10 dB    -15.02 dB   Nobody There (Beautiful Scars).wav โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Using the --quiet/-q flag will silence most of the output and only print the calculated DR score to stdout:

$ drmeter 'Nobody There (Beautiful Scars).wav' -q
DR12

Alternatively drmeter supports a more detailed JSON-formatted output using the --output/-o json parameter, including both per-channel and totaled results. Using the --output parameter redirects the progress display to stderr, so that the formatted output can be piped to other applications or to file. If you do not require the progress display, it can be silenced using --quiet/-q here, too.

# Save a copy to file
$ drmeter -ojson -q 'Nobody There (Beautiful Scars).wav' | tee dr.json
{
  "filename": "/โ€ฆ/Nobody There (Beautiful Scars).wav",
  "dr_score": [
    11.93,
    11.63
  ],
  "peak_db": [
    โ€ฆ
  ]
}
# Parse JSON using jq
$ drmeter -ojson -q 'Nobody There (Beautiful Scars).wav' | jq '.[].overall_dr_score'
11.78

Dockerized

A container image of drmeter is available at ghcr.io/janw/drmeter with the latest tag pointing to the latest commit on the main branch. The following command (with the files you're looking to analyze in/below the current working directory) behaves very similarly to an installed version, accepting arguments directly as expected:

docker run --rm --tty --workdir /src -v "$PWD:/src" \
    ghcr.io/janw/drmeter --output json path/to/files

Project details


Download files

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

Source Distribution

drmeter-0.2.2.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

drmeter-0.2.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file drmeter-0.2.2.tar.gz.

File metadata

  • Download URL: drmeter-0.2.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for drmeter-0.2.2.tar.gz
Algorithm Hash digest
SHA256 89a5ace5ae08ca3cae594fc0b9a00759de4d80061819535d2efa4afb18cd6dd2
MD5 3bb8a2ebe9e06aa498e1d7915e6ea073
BLAKE2b-256 67561d906283351e9e75d20c0d39466b8c349752f9e54c4e695e1de92547aa3e

See more details on using hashes here.

Provenance

File details

Details for the file drmeter-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: drmeter-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for drmeter-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a2848de34c6f2ac539338327b117c0adbe270d2368baf54f8e25fd5df21f30fe
MD5 aa50eb1b04339d6e40e0a4e60371311b
BLAKE2b-256 0d7fa6a9449d8140060070e80df805262a662416910e3ba8665bb67ab19b378e

See more details on using hashes here.

Provenance

Supported by

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