lupy.meter¶
- class lupy.meter.Meter(block_size: int, num_channels: NumChannelsT, sampler_class: type[Sampler] = <class 'lupy.sampling.Sampler'>, tp_sampler_class: type[TruePeakSampler] = <class 'lupy.sampling.TruePeakSampler'>, sample_rate: int = 48000, true_peak_gate_duration: Fraction = Fraction(2, 5), true_peak_enabled: bool = True, momentary_enabled: bool = True, short_term_enabled: bool = True, lra_enabled: bool = True)[source]¶
Bases:
Generic[NumChannelsT]- Parameters:
block_size (int) – Number of input samples per call to
write()num_channels (NumChannelsT) – Number of audio channels
sampler_class (type[Sampler]) – The class to use for the
samplertp_sampler_class (type[TruePeakSampler]) – The class to use for the
true_peak_samplersample_rate (int) – The sample rate of the audio data
true_peak_gate_duration (Fraction) – The processing duration for the
true_peak_processorin seconds. SeeTruePeakSampler.gate_durationfor details.true_peak_enabled (bool) – Whether to enable True Peak processing (default:
True)momentary_enabled (bool) – Whether to enable Momentary Loudness processing (default:
True)short_term_enabled (bool) – Whether to enable Short-Term Loudness processing (default:
True)lra_enabled (bool) – Whether to enable Loudness Range processing (default:
True)
Important
If short_term_enabled is
False, lra_enabled must also beFalse. This is because Loudness Range calculation depends on Short-Term Loudness values.- Raises:
ValueError – If short_term_enabled is
Falseand lra_enabled isTrue
- num_channels: NumChannelsT¶
Number of audio channels
- sampler: Sampler[NumChannelsT]¶
The
Samplerinstance to buffer input data
- true_peak_sampler: TruePeakSampler[NumChannelsT]¶
Sample buffer to hold un-filtered samples for
true_peak_processor
- processor: BlockProcessor[NumChannelsT]¶
The
BlockProcessorto perform the calulations
- true_peak_processor: TruePeakProcessor[NumChannelsT]¶
- 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)
- can_write() bool[source]¶
Whether there is enough room on the internal buffer for at least one call to
write()
- can_process() bool[source]¶
Whether there are enough samples in the internal buffer for at least one call to
process()
- write(samples: ndarray[tuple[int, int], dtype[float64]] | ndarray[tuple[int, int], dtype[float32]], process: bool = True, process_all: bool = True) None[source]¶
Store input data into the internal buffer
The input data must be of shape
(num_channels, block_size)
- write_all(samples: ndarray[tuple[int, int], dtype[float32] | dtype[float64]]) None[source]¶
Write an arbitrary number of samples and process them
If the number of samples is not a multiple of
block_size, the samples will be truncated to the nearest multiple.
- process(process_all: bool = True) None[source]¶
Process the samples for at least one gating block
- Parameters:
process_all (bool) – If
True(the default), theread()method of thesamplerwill be called and the data passed to theprocess_block()method on theprocessorrepeatedly until there are no gating block samples available. Otherwise, only one call to each will be performed.
- set_paused(paused: bool) None[source]¶
Pause or unpause processing
When paused, the current state of the
processoris preserved and any input provided to thewrite()method will be discarded.
- property integrated_lkfs: floating¶
The current Integrated Loudness
- property lra: float¶
The current Loudness Range
If
lra_enabledisFalse, this will always return0.0.
- property block_data: MeterArray¶
A structured array of measurement values with dtype
MeterDtype
- property current_measurement: CurrentMeasurement[NumChannelsT]¶
The current measurement values as a
CurrentMeasurementinstanceThis is a snapshot of the most recent measurement values for each metric as of the last processed gating block.
It provides the latest values for:
The
measurement timefor the last processed gating blockThe
momentary_lkfsThe maximum of the
true_peak_currentarray
If no gating blocks have been processed yet, the values returned will correspond to their initial silence states.
- property momentary_lkfs: ndarray[tuple[int], dtype[float64]]¶
Momentary Loudness for each 100ms block, averaged over 400ms (not gated)
If
momentary_enabledisFalse, this will return an array of zeroes.
- 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_enabledisFalse, this will return an array of zeroes.
- property t: ndarray[tuple[int], dtype[float64]]¶
The measurement time for each element in
short_term_lkfsandmomentary_lkfs
- property true_peak_array: TruePeakArray[NumChannelsT]¶
A structured array of True Peak measurement values with dtype
TruePeakDtype
- property true_peak_max: floating¶
Maximum True Peak value detected
If
true_peak_enabledisFalse, this will always return-inf.
- property true_peak_current: ndarray[tuple[NumChannelsT], dtype[float64]]¶
True Peak values per channel from the last processing period
If
true_peak_enabledisFalse, this will always return an array of-infvalues.