lupy.processing

class lupy.processing.RunningSum[source]

Bases: object

Helper class to calculate the running sum of a series of values

property value: floating

The current running sum

property count: int

The number of values in the running sum

property mean: floating

The mean of the running sum

add(value: floating) None[source]

Add a data point to the running sum

clear() None[source]

Reset value and count to zero

lupy.processing.square_and_sum(a: ndarray[tuple[int, int], dtype[float64]]) ndarray[tuple[int], dtype[float64]][source]

Compute the per-row sum-of-squares of a 2-D array

Equivalent to np.square(a).sum(axis=1) but avoids allocating the intermediate (rows, cols) squared array, which can be large when a has many columns.

class lupy.processing.BaseProcessor(num_channels: NumChannelsT, sample_rate: int = 48000)[source]

Bases: ABC, Generic[NumChannelsT]

Abstract base class for audio measurement processors

num_channels: NumChannelsT

Number of audio channels

sample_rate: int

The sample rate of the audio data

abstractmethod __call__(samples: ndarray[tuple[int, int], dtype[float64]]) None[source]

Process one gating block

Input data must be of shape (num_channels, gate_size)

abstractmethod reset() None[source]

Reset all measurement data

class lupy.processing.BlockProcessor(num_channels: NumChannelsT, gate_size: int, sample_rate: int = 48000, momentary_enabled: bool = True, short_term_enabled: bool = True, lra_enabled: bool = True)[source]

Bases: BaseProcessor[NumChannelsT]

Process audio samples and store the resulting loudness data

Parameters:

Important

If short_term_enabled is False, lra_enabled must also be False. Loudness Range calculation depends on Short-Term Loudness values.

Raises:

ValueError – If short_term_enabled is False and lra_enabled is True

gate_size: int

The length of one gating block in samples

integrated_lkfs: floating

The current Integrated Loudness

lra: float

The current Loudness Range

If lra_enabled is False, this will always be 0

property momentary_enabled: bool

Whether Momentary Loudness processing is enabled (read-only)

property short_term_enabled: bool

Whether Short-Term Loudness processing is enabled (read-only)

property lra_enabled: bool

Whether Loudness Range processing is enabled (read-only)

property block_data: MeterArray

A structured array of measurement values with dtype MeterDtype

property momentary_lkfs: ndarray[tuple[int], dtype[float64]]

Momentary Loudness for each 100ms block, averaged over 400ms (not gated)

If momentary_enabled is False, this will be an array of zeros

property short_term_lkfs: ndarray[tuple[int], dtype[float64]]

Short-Term Loudness for each 100ms block, averaged over 3 seconds (not gated)

If short_term_enabled is False, this will be an array of zeros

property t: ndarray[tuple[int], dtype[float64]]

The measurement time for each element in short_term_lkfs and momentary_lkfs

property Zij: ndarray[tuple[int, int], dtype[float64]]

Mean-squared values per channel in each 400ms block (not weighted)

reset() None[source]

Reset all measurement data

__call__(samples: ndarray[tuple[int, int], dtype[float64]]) None[source]

Process one gating block

Input data must be of shape (num_channels, gate_size)

process_block(samples: ndarray[tuple[int, int], dtype[float64]])[source]

Process one gating block

Input data must be of shape (num_channels, gate_size)

class lupy.processing.TruePeakProcessor(num_channels: NumChannelsT, gate_size: int, sample_rate: int = 48000)[source]

Bases: BaseProcessor[NumChannelsT]

Process audio samples to extract their True Peak values

max_peak: floating

Maximum True Peak value detected

gate_size: int

The length in samples to process per call

property tp_array: TruePeakArray[NumChannelsT]

A structured array of measurement values with dtype TruePeakDtype

property t: ndarray[tuple[int], dtype[float64]]

The measurement times for all processed blocks in tp_array

property all_tp_values: ndarray[tuple[int, NumChannelsT], dtype[float64]]

All True Peak values per channel for each processed block

property current_peaks: ndarray[tuple[NumChannelsT], dtype[float64]]

True Peak values per channel from the last processing period

__call__(samples: ndarray[tuple[int, int], dtype[float64]]) None[source]

Process one gating block

Input data must be of shape (num_channels, gate_size)

reset() None[source]

Reset all measurement data