### Install pyloudnorm with pip Source: https://github.com/csteinmetz1/pyloudnorm/blob/master/README.md Install the library using pip for standard usage. ```bash pip install pyloudnorm ``` -------------------------------- ### Install pyloudnorm from GitHub Source: https://github.com/csteinmetz1/pyloudnorm/blob/master/README.md Install the latest release directly from the GitHub repository. ```bash pip install git+https://github.com/csteinmetz1/pyloudnorm ``` -------------------------------- ### Measure Integrated Loudness of Audio File Source: https://github.com/csteinmetz1/pyloudnorm/blob/master/README.md Load a WAV file using PySoundFile and measure its integrated loudness using a pyloudnorm Meter. Requires 'soundfile' and 'pyloudnorm' to be installed. ```python import soundfile as sf import pyloudnorm as pyln data, rate = sf.read("test.wav") # load audio (with shape (samples, channels)) meter = pyln.Meter(rate) # create BS.1770 meter loudness = meter.integrated_loudness(data) # measure loudness ``` -------------------------------- ### Create and Apply Custom IIR Biquad Filters Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Demonstrates creating custom IIR biquad filters with configurable parameters and applying them directly to audio data or injecting them into a custom Meter instance for loudness measurement. ```python import soundfile as sf import pyloudnorm as pyln from pyloudnorm import IIRfilter import numpy as np # Inspect a filter's coefficients and parameters hp = IIRfilter(0.0, 0.5, 80.0, 48000, 'high_pass') print(hp) # type: high_pass | Gain=0.0 dB | Q=0.5 | fc=80.0 Hz | rate=48000 Hz print("b:", hp.b) # numerator coefficients [b0, b1, b2] print("a:", hp.a) # denominator coefficients [a0, a1, a2] # Apply a filter directly to a signal data, rate = sf.read("audio.wav") filtered = hp.apply_filter(data[:, 0] if data.ndim == 2 else data) # Build a custom meter with user-defined filters my_high_pass = IIRfilter(0.0, 0.5, 20.0, 48000, 'high_pass') my_high_shelf = IIRfilter(2.0, 0.7, 1525.0, 48000, 'high_shelf') meter = pyln.Meter(48000, filter_class="custom") meter._filters = { 'my_high_pass': my_high_pass, 'my_high_shelf': my_high_shelf, } data, rate = sf.read("audio.wav") loudness = meter.integrated_loudness(data) print(f"Custom-filtered loudness: {loudness:.2f} LUFS") ``` -------------------------------- ### Advanced pyloudnorm Meter Configuration Source: https://github.com/csteinmetz1/pyloudnorm/blob/master/README.md Demonstrates creating pyloudnorm Meter instances with custom block sizes and different IIR filter classes, including user-defined filters. ```python import soundfile as sf import pyloudnorm as pyln from pyloudnorm import IIRfilter data, rate = sf.read("test.wav") # load audio # block size meter1 = pyln.Meter(rate) # 400ms block size meter2 = pyln.Meter(rate, block_size=0.200) # 200ms block size # filter classes meter3 = pyln.Meter(rate) # BS.1770 meter meter4 = pyln.Meter(rate, filter_class="DeMan") # fully compliant filters meter5 = pyln.Meter(rate, filter_class="Fenton/Lee 1") # low complexity improvement by Fenton and Lee meter6 = pyln.Meter(rate, filter_class="Fenton/Lee 2") # higher complexity improvement by Fenton and Lee meter7 = pyln.Meter(rate, filter_class="Dash et al.") # early modification option # create your own IIR filters my_high_pass = IIRfilter(0.0, 0.5, 20.0, rate, 'high_pass') my_high_shelf = IIRfilter(2.0, 0.7, 1525.0, rate, 'high_shelf') # create a meter initialized without filters meter8 = pyln.Meter(rate, filter_class="custom") # load your filters into the meter meter8._filters = {'my_high_pass' : my_high_pass, 'my_high_shelf' : my_high_shelf} ``` -------------------------------- ### Create a pyloudnorm Meter instance Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Instantiate a Meter object with specified sample rate, filter class, block size, and overlap. Default K-weighting filter is used if not specified. Supports custom filter classes and non-standard block sizes. ```python import pyloudnorm as pyln # Standard ITU-R BS.1770-4 meter at 48 kHz meter = pyln.Meter(48000) # 200 ms block size (instead of the standard 400 ms) meter_short = pyln.Meter(48000, block_size=0.200) # Fully ITU-compliant coefficient derivation (DeMan method) meter_deman = pyln.Meter(44100, filter_class="DeMan") # Fenton/Lee 1 alternative weighting filter meter_fl = pyln.Meter(48000, filter_class="Fenton/Lee 1") # Custom filter class — no filters loaded; inject manually later meter_custom = pyln.Meter(48000, filter_class="custom") print(meter.rate) # 48000 print(meter.block_size) # 0.4 print(meter.filter_class) # K-weighting ``` -------------------------------- ### Measure Loudness Range and Integrated Loudness Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Demonstrates how to measure both loudness range (LRA) and integrated loudness (LUFS) from an audio file using the Meter class. Also shows how meter state is preserved and how silent signals result in NaN. ```python import soundfile as sf import pyloudnorm as pyln import numpy as np # --- Verify meter state is preserved after LRA call --- rate = 48000 meter = pyln.Meter(rate) print(meter.block_size) # still 0.4 (not 3.0) print(meter.overlap) # still 0.75 (not 0.97) # --- Silent signal returns NaN --- silent = 1e-10 * np.random.randn(rate * 10) lra_silent = meter.loudness_range(silent) print(np.isnan(lra_silent)) # True # --- Combined measurement: integrated loudness + LRA --- data, rate = sf.read("audio.wav") meter = pyln.Meter(rate) lufs = meter.integrated_loudness(data) lra = meter.loudness_range(data) print(f"Loudness: {lufs:.1f} LUFS | Range: {lra:.1f} LU") ``` -------------------------------- ### pyln.Meter Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Instantiates a Meter object configured for a given sample rate. Supports various pre-filter chains, configurable block sizes, and overlap settings. ```APIDOC ## pyln.Meter(rate, filter_class, block_size, overlap) ### Description Instantiates a `Meter` object configured for a given sample rate. The `filter_class` parameter selects the pre-filter chain applied before loudness computation; supported values are `"K-weighting"` (default, per ITU-R BS.1770-4), `"Fenton/Lee 1"`, `"Fenton/Lee 2"`, `"Dash et al."`, `"DeMan"` (fully spec-compliant coefficient derivation), and `"custom"` (no pre-loaded filters). `block_size` sets the gating block duration in seconds (default 0.400 s); `overlap` sets the fractional overlap between blocks (default 0.75). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import pyloudnorm as pyln # Standard ITU-R BS.1770-4 meter at 48 kHz meter = pyln.Meter(48000) # 200 ms block size (instead of the standard 400 ms) meter_short = pyln.Meter(48000, block_size=0.200) # Fully ITU-compliant coefficient derivation (DeMan method) meter_deman = pyln.Meter(44100, filter_class="DeMan") # Fenton/Lee 1 alternative weighting filter meter_fl = pyln.Meter(48000, filter_class="Fenton/Lee 1") # Custom filter class — no filters loaded; inject manually later meter_custom = pyln.Meter(48000, filter_class="custom") print(meter.rate) # 48000 print(meter.block_size) # 0.4 print(meter.filter_class) # K-weighting ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### pyln.IIRfilter Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Creates a biquad IIR filter with configurable parameters. Coefficients are generated using standard or custom derivations. Filters can be applied directly or used within a custom meter. ```APIDOC ## pyln.IIRfilter(G, Q, fc, rate, filter_type) — Custom IIR biquad filter ### Description Creates a biquad IIR filter with configurable gain (`G`, dB), Q factor (`Q`), center/cutoff frequency (`fc`, Hz), and type. Supported `filter_type` values: `'high_shelf'`, `'low_shelf'`, `'high_pass'`, `'low_pass'`, `'peaking'`, `'notch'`, `'high_shelf_DeMan'`, `'high_pass_DeMan'`. Coefficients are generated via the RBJ Audio EQ Cookbook (standard types) or Brecht De Man's ITU-compliant derivation (DeMan types). Filters can be injected into a `"custom"` meter via its `_filters` dict. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **G** (float) - Gain in dB. - **Q** (float) - Q factor. - **fc** (float) - Center or cutoff frequency in Hz. - **rate** (int) - Sample rate in Hz. - **filter_type** (str) - Type of filter (e.g., 'high_pass', 'low_shelf'). ### Request Example ```python import soundfile as sf import pyloudnorm as pyln from pyloudnorm import IIRfilter import numpy as np # Inspect a filter's coefficients and parameters hp = IIRfilter(0.0, 0.5, 80.0, 48000, 'high_pass') print(hp) # type: high_pass | Gain=0.0 dB | Q=0.5 | fc=80.0 Hz | rate=48000 Hz print("b:", hp.b) # numerator coefficients [b0, b1, b2] print("a:", hp.a) # denominator coefficients [a0, a1, a2] # Apply a filter directly to a signal data, rate = sf.read("audio.wav") filtered = hp.apply_filter(data[:, 0] if data.ndim == 2 else data) # Build a custom meter with user-defined filters my_high_pass = IIRfilter(0.0, 0.5, 20.0, 48000, 'high_pass') my_high_shelf = IIRfilter(2.0, 0.7, 1525.0, 48000, 'high_shelf') meter = pyln.Meter(48000, filter_class="custom") meter._filters = { 'my_high_pass': my_high_pass, 'my_high_shelf': my_high_shelf, } data, rate = sf.read("audio.wav") loudness = meter.integrated_loudness(data) print(f"Custom-filtered loudness: {loudness:.2f} LUFS") ``` ### Response #### Success Response (200) - **filter_object** (IIRfilter) - The created IIR filter object. - **filtered_data** (numpy.ndarray) - The audio data after applying the filter. - **loudness** (float) - The loudness measurement after applying custom filters. #### Response Example ```json { "example": "[filter object details or processed audio data]" } ``` ``` -------------------------------- ### pyln.normalize.loudness Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Applies a linear gain to audio data to bring its loudness from an input level to a target level in dB LUFS. Issues a UserWarning if the output clips. ```APIDOC ## pyln.normalize.loudness(data, input_loudness, target_loudness) — Loudness normalize audio ### Description Applies a linear gain to `data` to bring its loudness from `input_loudness` to `target_loudness` (both in dB LUFS). The gain is computed as `10^((target − input) / 20)`. Issues a `UserWarning` if the output clips. Typically used after measuring integrated loudness with `Meter.integrated_loudness()`. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **data** (numpy.ndarray) - The audio data to normalize. - **input_loudness** (float) - The current loudness of the audio in dB LUFS. - **target_loudness** (float) - The desired target loudness in dB LUFS. ### Request Example ```python import soundfile as sf import pyloudnorm as pyln data, rate = sf.read("audio.wav") meter = pyln.Meter(rate) # Measure current loudness current_lufs = meter.integrated_loudness(data) print(f"Input loudness: {current_lufs:.2f} LUFS") # Normalize to -23 LUFS (EBU R 128 broadcast target) normalized = pyln.normalize.loudness(data, current_lufs, -23.0) # Verify achieved_lufs = meter.integrated_loudness(normalized) print(f"Output loudness: {achieved_lufs:.2f} LUFS") # ≈ -23.00 LUFS sf.write("normalized_ebu_r128.wav", normalized, rate) # Normalize to -14 LUFS (streaming platform target, e.g. Spotify) streaming_norm = pyln.normalize.loudness(data, current_lufs, -14.0) sf.write("normalized_streaming.wav", streaming_norm, rate) ``` ### Response #### Success Response (200) - **normalized_data** (numpy.ndarray) - The loudness-normalized audio data. #### Response Example ```json { "example": "[normalized audio data]" } ``` ``` -------------------------------- ### Validate Audio Data Type and Length Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Demonstrates validation of audio data using `util.valid_audio`. Ensures data is floating point, longer than the block size, and has five channels or less. Raises ValueError for invalid inputs. ```python try: util.valid_audio(np.zeros((rate * 5,), dtype=np.int16), rate, block_size) except ValueError as e: print(e) # "Data must be floating point." ``` ```python try: util.valid_audio(np.zeros(100, dtype=np.float64), rate, block_size) except ValueError as e: print(e) # "Audio must have length greater than the block size." ``` ```python try: util.valid_audio(np.zeros((rate * 5, 6), dtype=np.float64), rate, block_size) except ValueError as e: print(e) # "Audio must have five channels or less." ``` -------------------------------- ### Peak Normalize Audio to Target dBFS Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Scales audio data so its maximum absolute sample value equals a specified target level in dBFS. Issues a UserWarning if output samples reach or exceed full scale (≥ 1.0). Useful for headroom control. ```python import numpy as np import pyloudnorm as pyln import soundfile as sf data = np.array([0.1, -0.4, 0.25, -0.2], dtype=np.float32) # Normalize peak to -1 dBFS peak_norm = pyln.normalize.peak(data, -1.0) print(np.max(np.abs(peak_norm))) # ~0.891 (≈ -1 dBFS) # Normalize peak to 0 dBFS peak_0db = pyln.normalize.peak(data, 0.0) print(np.max(np.abs(peak_0db))) # 1.0 # With a real audio file audio, rate = sf.read("audio.wav") normalized = pyln.normalize.peak(audio, -1.0) sf.write("peak_normalized.wav", normalized, rate) ``` -------------------------------- ### Measure Loudness Range (LRA) of Audio File Source: https://github.com/csteinmetz1/pyloudnorm/blob/master/README.md Calculate the Loudness Range (LRA) of an audio file, which quantifies loudness variation over time in LU. Requires 'soundfile' and 'pyloudnorm'. ```python import soundfile as sf import pyloudnorm as pyln data, rate = sf.read("test.wav") # load audio meter = pyln.Meter(rate) # create BS.1770 meter lra = meter.loudness_range(data) # measure loudness range print(f"Loudness Range: {lra:.1f} LU") ``` -------------------------------- ### pyln.normalize.peak Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Scales audio data so that its maximum absolute sample value equals the specified target level in dBFS. Useful for headroom control. ```APIDOC ## pyln.normalize.peak(data, target) — Peak normalize audio ### Description Scales `data` so that its maximum absolute sample value equals the specified `target` level in dBFS. Issues a `UserWarning` if any output samples are at or above full scale (≥ 1.0). Useful for headroom control before export or further processing. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **data** (numpy.ndarray) - The audio data to normalize. - **target** (float) - The target peak level in dBFS. ### Request Example ```python import numpy as np import pyloudnorm as pyln data = np.array([0.1, -0.4, 0.25, -0.2], dtype=np.float32) # Normalize peak to -1 dBFS peak_norm = pyln.normalize.peak(data, -1.0) print(np.max(np.abs(peak_norm))) # ~0.891 (≈ -1 dBFS) # Normalize peak to 0 dBFS peak_0db = pyln.normalize.peak(data, 0.0) print(np.max(np.abs(peak_0db))) # 1.0 # With a real audio file import soundfile as sf audio, rate = sf.read("audio.wav") normalized = pyln.normalize.peak(audio, -1.0) sf.write("peak_normalized.wav", normalized, rate) ``` ### Response #### Success Response (200) - **normalized_data** (numpy.ndarray) - The peak-normalized audio data. #### Response Example ```json { "example": "[normalized audio data]" } ``` ``` -------------------------------- ### Validate Audio Input with util.valid_audio Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Uses the internal validation utility to check if a NumPy array is suitable for meter processing. It verifies data type, channel count, and sample length. Returns True if valid, raises ValueError otherwise. ```python import numpy as np import pyloudnorm as pyln from pyloudnorm import util rate = 44100 block_size = 0.4 # Valid stereo float audio stereo = np.random.randn(rate * 5, 2).astype(np.float32) print(util.valid_audio(stereo, rate, block_size)) # True ``` -------------------------------- ### Normalize Audio Files by Peak or Loudness Source: https://github.com/csteinmetz1/pyloudnorm/blob/master/README.md Normalize audio data to a specified peak level or loudness (LUFS). This involves loading audio, applying normalization, and optionally measuring loudness first. ```python import soundfile as sf import pyloudnorm as pyln data, rate = sf.read("test.wav") # load audio # peak normalize audio to -1 dB peak_normalized_audio = pyln.normalize.peak(data, -1.0) # measure the loudness first meter = pyln.Meter(rate) # create BS.1770 meter loudness = meter.integrated_loudness(data) # loudness normalize audio to -12 dB LUFS loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -12.0) ``` -------------------------------- ### Meter.integrated_loudness Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Computes the integrated gated loudness of an audio signal in dB LUFS, following the full two-pass gating algorithm in ITU-R BS.1770-4. ```APIDOC ## Meter.integrated_loudness(data) ### Description Computes the integrated gated loudness of an audio signal in dB LUFS, following the full two-pass gating algorithm in ITU-R BS.1770-4. The input `data` must be a NumPy `float` array of shape `(samples,)` for mono or `(samples, channels)` for multichannel audio (up to 5 channels, ordered: Left, Right, Center, Left surround, Right surround). Returns a single `float` (−inf for silence or signals entirely below the absolute gate). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **data** (numpy.ndarray) - Required - A NumPy float array representing the audio signal. ### Request Example ```python import soundfile as sf import pyloudnorm as pyln import numpy as np # --- Mono audio from file --- data, rate = sf.read("audio.wav") # shape: (samples,) or (samples, ch) meter = pyln.Meter(rate) loudness = meter.integrated_loudness(data) print(f"Integrated loudness: {loudness:.2f} LUFS") # Example output: Integrated loudness: -23.04 LUFS # --- Stereo synthetic signal --- rate = 48000 duration = 5.0 t = np.linspace(0, duration, int(rate * duration), endpoint=False) left = 0.5 * np.sin(2 * np.pi * 1000 * t) right = 0.3 * np.sin(2 * np.pi * 1000 * t) stereo = np.column_stack([left, right]) # shape: (samples, 2) meter = pyln.Meter(rate) loudness = meter.integrated_loudness(stereo) print(f"Stereo loudness: {loudness:.2f} LUFS") # --- Validation errors --- try: meter.integrated_loudness(np.array([1, 2, 3], dtype=np.int16)) # not float except ValueError as e: print(e) # "Data must be floating point." try: meter.integrated_loudness(np.zeros((100, 6), dtype=np.float64)) # >5 channels except ValueError as e: print(e) # "Audio must have five channels or less." ``` ### Response #### Success Response (200) - **loudness** (float) - The integrated loudness in dB LUFS. #### Response Example ```json { "loudness": -23.04 } ``` ``` -------------------------------- ### Measure integrated loudness of audio data Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Calculate integrated gated loudness in dB LUFS using the `integrated_loudness` method. Input data must be a NumPy float array. Supports mono and multichannel audio up to 5 channels. Handles validation errors for incorrect data types or channel counts. ```python import soundfile as sf import pyloudnorm as pyln import numpy as np # --- Mono audio from file --- data, rate = sf.read("audio.wav") # shape: (samples,) or (samples, ch) meter = pyln.Meter(rate) loudness = meter.integrated_loudness(data) print(f"Integrated loudness: {loudness:.2f} LUFS") # Example output: Integrated loudness: -23.04 LUFS # --- Stereo synthetic signal --- rate = 48000 duration = 5.0 t = np.linspace(0, duration, int(rate * duration), endpoint=False) left = 0.5 * np.sin(2 * np.pi * 1000 * t) right = 0.3 * np.sin(2 * np.pi * 1000 * t) stereo = np.column_stack([left, right]) # shape: (samples, 2) meter = pyln.Meter(rate) loudness = meter.integrated_loudness(stereo) print(f"Stereo loudness: {loudness:.2f} LUFS") # --- Validation errors --- try: meter.integrated_loudness(np.array([1, 2, 3], dtype=np.int16)) # not float except ValueError as e: print(e) # "Data must be floating point." try: meter.integrated_loudness(np.zeros((100, 6), dtype=np.float64)) # >5 channels except ValueError as e: print(e) # "Audio must have five channels or less." ``` -------------------------------- ### pyln.util.valid_audio Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Internal utility to validate if NumPy array is suitable for meter processing. Checks for data type, channel count, and length. ```APIDOC ## pyln.util.valid_audio(data, rate, block_size) — Validate audio input ### Description Internal validation utility that checks whether a NumPy array is a valid audio input for the meter: must be a floating-point `ndarray`, have at most 5 channels, and be longer than `block_size * rate` samples. Raises `ValueError` with a descriptive message on failure; returns `True` when valid. Called automatically by `Meter.integrated_loudness()`, but can also be used independently for pre-flight checks. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **data** (numpy.ndarray) - The audio data to validate. - **rate** (int) - The sample rate of the audio. - **block_size** (float) - The block size used for processing. ### Request Example ```python import numpy as np import pyloudnorm as pyln from pyloudnorm import util rate = 44100 block_size = 0.4 # Valid stereo float audio stereo = np.random.randn(rate * 5, 2).astype(np.float32) print(util.valid_audio(stereo, rate, block_size)) # True ``` ### Response #### Success Response (200) - **is_valid** (bool) - True if the audio is valid, False otherwise. #### Response Example ```json { "example": "true" } ``` ``` -------------------------------- ### Loudness Normalize Audio to Target LUFS Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Applies linear gain to audio data to adjust its loudness from a measured input LUFS to a target LUFS. Issues a UserWarning if the output clips. Typically used after measuring integrated loudness. ```python import soundfile as sf import pyloudnorm as pyln data, rate = sf.read("audio.wav") meter = pyln.Meter(rate) # Measure current loudness current_lufs = meter.integrated_loudness(data) print(f"Input loudness: {current_lufs:.2f} LUFS") # Normalize to -23 LUFS (EBU R 128 broadcast target) normalized = pyln.normalize.loudness(data, current_lufs, -23.0) # Verify achieved_lufs = meter.integrated_loudness(normalized) print(f"Output loudness: {achieved_lufs:.2f} LUFS") # ≈ -23.00 LUFS sf.write("normalized_ebu_r128.wav", normalized, rate) # Normalize to -14 LUFS (streaming platform target, e.g. Spotify) streaming_norm = pyln.normalize.loudness(data, current_lufs, -14.0) sf.write("normalized_streaming.wav", streaming_norm, rate) ``` -------------------------------- ### Measure Loudness Range (LRA) of audio Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Calculate the Loudness Range (LRA) in LU using the `loudness_range` method, following EBU Tech 3342. This method internally uses specific block sizes and overlap settings and restores original meter settings afterward. Returns NaN for very quiet signals. ```python import soundfile as sf import pyloudnorm as pyln import numpy as np # --- Real audio file --- data, rate = sf.read("audio.wav") meter = pyln.Meter(rate) lra = meter.loudness_range(data) print(f"Loudness Range: {lra:.1f} LU") # Typical music: 5–15 LU; speech: 2–8 LU; constant tone: ~0 LU ``` -------------------------------- ### Meter.loudness_range Source: https://context7.com/csteinmetz1/pyloudnorm/llms.txt Measures the Loudness Range (LRA) of a signal in LU (Loudness Units) per EBU Tech 3342, quantifying variation in loudness over time. ```APIDOC ## Meter.loudness_range(data) ### Description Measures the Loudness Range (LRA) of a signal in LU (Loudness Units) per EBU Tech 3342, which quantifies variation in loudness over time. Internally switches to 3-second blocks with ~97% overlap (10 Hz refresh rate), applies absolute gating at −70 LUFS and relative gating at −20 LU below ungated integrated loudness, then returns the difference between the 95th and 10th percentiles of the gated short-term loudness distribution. Original meter `block_size` and `overlap` settings are fully restored after the call. Returns `NaN` if the signal is too quiet to measure. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **data** (numpy.ndarray) - Required - A NumPy float array representing the audio signal. ### Request Example ```python import soundfile as sf import pyloudnorm as pyln import numpy as np # --- Real audio file --- data, rate = sf.read("audio.wav") meter = pyln.Meter(rate) lra = meter.loudness_range(data) print(f"Loudness Range: {lra:.1f} LU") # Typical music: 5–15 LU; speech: 2–8 LU; constant tone: ~0 LU ``` ### Response #### Success Response (200) - **lra** (float) - The Loudness Range in LU, or NaN if the signal is too quiet. #### Response Example ```json { "lra": 8.5 } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.