{"id":2222,"library":"pyloudnorm","title":"pyloudnorm","description":"pyloudnorm is an active Python library (version 0.2.0) that provides an implementation of the ITU-R BS.1770-4 loudness algorithm. It enables flexible and programmatic control over loudness measurement parameters, including integrated loudness (LUFS) and Loudness Range (LRA). The library is primarily feature-driven, with recent major updates introducing new capabilities and refining Python compatibility.","status":"active","version":"0.2.0","language":"en","source_language":"en","source_url":"https://github.com/csteinmetz1/pyloudnorm","tags":["audio","loudness","signal processing","ebu r128","itu-r bs.1770","audio analysis"],"install":[{"cmd":"pip install pyloudnorm","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for numerical operations and audio array handling.","package":"numpy","optional":false},{"reason":"Core dependency for signal processing, especially filter design.","package":"scipy","optional":false}],"imports":[{"note":"Commonly imported with the alias 'pyln'.","symbol":"Meter","correct":"import pyloudnorm as pyln\nmeter = pyln.Meter(rate)"}],"quickstart":{"code":"import numpy as np\nimport pyloudnorm as pyln\n\n# Create dummy mono audio data (e.g., 2 seconds at 44.1 kHz)\nsample_rate = 44100  # Hz\nduration = 2.0      # seconds\nchannels = 1        # mono\ndata = np.random.uniform(-0.5, 0.5, int(sample_rate * duration))\n\n# pyloudnorm expects a 2D array (samples, channels) if multi-channel,\n# or 1D array for mono if you adjust it.\n# For integrated_loudness, a 1D mono signal works directly.\n\n# Create a BS.1770 meter\nmeter = pyln.Meter(sample_rate)\n\n# Measure the integrated loudness\nloudness = meter.integrated_loudness(data)\n\nprint(f\"Integrated Loudness: {loudness:.2f} LUFS\")\n\n# Example for Loudness Range (LRA) - requires sufficient audio length\n# (Often more than 2 seconds, but demonstrating usage)\nlra = meter.loudness_range(data)\nprint(f\"Loudness Range: {lra:.2f} LU\")","lang":"python","description":"This quickstart demonstrates how to initialize a `pyloudnorm.Meter` and measure the integrated loudness (LUFS) and Loudness Range (LRA) of a dummy audio signal. It highlights the primary API calls for basic loudness analysis."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or a newer compatible version.","message":"As of version 0.2.0, pyloudnorm officially requires Python 3.9 or newer. Earlier Python versions (3.7, 3.8) are no longer supported.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Ensure the `sample_rate` argument passed to `pyln.Meter()` precisely matches the sample rate of your audio data.","message":"The `Meter` class must be initialized with the correct audio sample rate. Providing an incorrect sample rate will lead to inaccurate loudness measurements.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Provide audio data of sufficient length for meaningful measurements. For integrated loudness, generally at least 400ms is required for the gating algorithm to operate correctly.","message":"Measuring integrated loudness or loudness range with very short audio segments (e.g., less than 400ms, due to internal block processing) may yield undefined or incorrect results.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Process audio at standard or typical audio sample rates (e.g., 44.1 kHz, 48 kHz). If working with very low-frequency audio, consider resampling or understand that loudness measurements might not be perceptually valid.","message":"Using very low sample rates (e.g., below 8000 Hz) can lead to numerical instability, overflow issues, or nonsensical loudness values, as the ITU-R BS.1770 algorithm is not intended for such rates. The library may produce very large positive numbers or -inf.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}