pub struct EbuR128 { /* private fields */ }
Expand description
EBU R128 loudness analyzer.
Implementations§
source§impl EbuR128
impl EbuR128
sourcepub fn new(channels: u32, rate: u32, mode: Mode) -> Result<Self, Error>
pub fn new(channels: u32, rate: u32, mode: Mode) -> Result<Self, Error>
Create a new instance with the given configuration.
sourcepub fn channel_map(&self) -> &[Channel]
pub fn channel_map(&self) -> &[Channel]
Get the configured channel types.
sourcepub fn max_window(&self) -> usize
pub fn max_window(&self) -> usize
Get the configured maximum window duration in ms.
sourcepub fn max_history(&self) -> usize
pub fn max_history(&self) -> usize
Get the configured maximum history in ms.
sourcepub fn set_channel(
&mut self,
channel_number: u32,
value: Channel
) -> Result<(), Error>
pub fn set_channel( &mut self, channel_number: u32, value: Channel ) -> Result<(), Error>
Set channel type.
The default is:
- 0 ->
Left
- 1 ->
Right
- 2 ->
Center
- 3 ->
Unused
- 4 ->
LeftSurround
- 5 ->
RightSurround
- _ ->
Unused
sourcepub fn set_channel_map(&mut self, channel_map: &[Channel]) -> Result<(), Error>
pub fn set_channel_map(&mut self, channel_map: &[Channel]) -> Result<(), Error>
Set channel types.
The default is:
- 0 ->
Left
- 1 ->
Right
- 2 ->
Center
- 3 ->
Unused
- 4 ->
LeftSurround
- 5 ->
RightSurround
- _ ->
Unused
sourcepub fn change_parameters(
&mut self,
channels: u32,
rate: u32
) -> Result<(), Error>
pub fn change_parameters( &mut self, channels: u32, rate: u32 ) -> Result<(), Error>
Change library parameters.
Note that the channel map will be reset when setting a different number of channels. The current unfinished block will be lost.
sourcepub fn set_max_window(&mut self, window: u32) -> Result<(), Error>
pub fn set_max_window(&mut self, window: u32) -> Result<(), Error>
Set the maximum window duration.
Set the maximum duration in ms that will be used for
EbuR128::loudness_window
. Note that this
destroys the current content of the audio buffer.
sourcepub fn set_max_history(&mut self, history: u32) -> Result<(), Error>
pub fn set_max_history(&mut self, history: u32) -> Result<(), Error>
Set the maximum history.
Set the maximum history in ms that will be stored for loudness integration. More history provides more accurate results, but requires more resources.
Applies to EbuR128::loudness_range
and
EbuR128::loudness_global
when
Mode::HISTOGRAM
is not set.
Default is ULONG_MAX
(at least ~50 days). Minimum is 3000ms for Mode::LRA
and 400ms
for Mode::M
.
sourcepub fn add_frames_i16(&mut self, frames: &[i16]) -> Result<(), Error>
pub fn add_frames_i16(&mut self, frames: &[i16]) -> Result<(), Error>
Add interleaved frames to be processed.
sourcepub fn add_frames_i32(&mut self, frames: &[i32]) -> Result<(), Error>
pub fn add_frames_i32(&mut self, frames: &[i32]) -> Result<(), Error>
Add interleaved frames to be processed.
sourcepub fn add_frames_f32(&mut self, frames: &[f32]) -> Result<(), Error>
pub fn add_frames_f32(&mut self, frames: &[f32]) -> Result<(), Error>
Add interleaved frames to be processed.
sourcepub fn add_frames_f64(&mut self, frames: &[f64]) -> Result<(), Error>
pub fn add_frames_f64(&mut self, frames: &[f64]) -> Result<(), Error>
Add interleaved frames to be processed.
sourcepub fn add_frames_planar_i16(&mut self, frames: &[&[i16]]) -> Result<(), Error>
pub fn add_frames_planar_i16(&mut self, frames: &[&[i16]]) -> Result<(), Error>
Add planar frames to be processed.
sourcepub fn add_frames_planar_i32(&mut self, frames: &[&[i32]]) -> Result<(), Error>
pub fn add_frames_planar_i32(&mut self, frames: &[&[i32]]) -> Result<(), Error>
Add planar frames to be processed.
sourcepub fn add_frames_planar_f32(&mut self, frames: &[&[f32]]) -> Result<(), Error>
pub fn add_frames_planar_f32(&mut self, frames: &[&[f32]]) -> Result<(), Error>
Add planar frames to be processed.
sourcepub fn add_frames_planar_f64(&mut self, frames: &[&[f64]]) -> Result<(), Error>
pub fn add_frames_planar_f64(&mut self, frames: &[&[f64]]) -> Result<(), Error>
Add planar frames to be processed.
sourcepub fn seed_frames_i16(&mut self, frames: &[i16]) -> Result<(), Error>
pub fn seed_frames_i16(&mut self, frames: &[i16]) -> Result<(), Error>
Add interleaved frames to warmup filters, but not be considered for measurements.
See EbuR128::loudness_global_multiple
for example usage.
sourcepub fn seed_frames_i32(&mut self, frames: &[i32]) -> Result<(), Error>
pub fn seed_frames_i32(&mut self, frames: &[i32]) -> Result<(), Error>
Add interleaved frames to warmup filters, but not be considered for measurements.
See EbuR128::loudness_global_multiple
for example usage.
sourcepub fn seed_frames_f32(&mut self, frames: &[f32]) -> Result<(), Error>
pub fn seed_frames_f32(&mut self, frames: &[f32]) -> Result<(), Error>
Add interleaved frames to warmup filters, but not be considered for measurements.
See EbuR128::loudness_global_multiple
for example usage.
sourcepub fn seed_frames_f64(&mut self, frames: &[f64]) -> Result<(), Error>
pub fn seed_frames_f64(&mut self, frames: &[f64]) -> Result<(), Error>
Add interleaved frames to warmup filters, but not be considered for measurements.
See EbuR128::loudness_global_multiple
for example usage.
sourcepub fn seed_frames_planar_i16(&mut self, frames: &[&[i16]]) -> Result<(), Error>
pub fn seed_frames_planar_i16(&mut self, frames: &[&[i16]]) -> Result<(), Error>
Add planar frames to warmup filters, but not be considered for measurements.
See EbuR128::loudness_global_multiple
for example usage.
sourcepub fn seed_frames_planar_i32(&mut self, frames: &[&[i32]]) -> Result<(), Error>
pub fn seed_frames_planar_i32(&mut self, frames: &[&[i32]]) -> Result<(), Error>
Add planar frames to warmup filters, but not be considered for measurements.
See EbuR128::loudness_global_multiple
for example usage.
sourcepub fn seed_frames_planar_f32(&mut self, frames: &[&[f32]]) -> Result<(), Error>
pub fn seed_frames_planar_f32(&mut self, frames: &[&[f32]]) -> Result<(), Error>
Add planar frames to warmup filters, but not be considered for measurements.
See EbuR128::loudness_global_multiple
for example usage.
sourcepub fn seed_frames_planar_f64(&mut self, frames: &[&[f64]]) -> Result<(), Error>
pub fn seed_frames_planar_f64(&mut self, frames: &[&[f64]]) -> Result<(), Error>
Add planar frames to warmup filters, but not be considered for measurements.
See EbuR128::loudness_global_multiple
for example usage.
sourcepub fn loudness_global(&self) -> Result<f64, Error>
pub fn loudness_global(&self) -> Result<f64, Error>
Get global integrated loudness in LUFS.
sourcepub fn loudness_global_multiple<'a>(
iter: impl Iterator<Item = &'a Self>
) -> Result<f64, Error>
pub fn loudness_global_multiple<'a>( iter: impl Iterator<Item = &'a Self> ) -> Result<f64, Error>
Get global integrated loudness in LUFS across multiple instances.
This can be used to allow parallel iteration of long signals, assuming some care is taken:
- Divide input-signal up in “chunks” of even 100ms samples. Make chunks overlap by 400ms, for example (0-10s, 9.6-20s, 19.6-30s, …)
- The first chunk is processed as normal. Then in parallel, for each remaining chunk, create a new instance of
EbuR128
, and in parallel:- Feed the first 100ms of the chunk (these are samples overlapping with last chunk) through
seed_frames_*
function. This is sufficient to make filter-states in each instance what they would have been if a single analyzer would have reached this point. - Process the remaining samples of each chunk through the analyzer
- Feed the first 100ms of the chunk (these are samples overlapping with last chunk) through
- Call
EbuR128::loudness_global_multiple
over all the chunks to get the global loudness
sourcepub fn loudness_momentary(&self) -> Result<f64, Error>
pub fn loudness_momentary(&self) -> Result<f64, Error>
Get momentary loudness (last 400ms) in LUFS.
sourcepub fn loudness_shortterm(&self) -> Result<f64, Error>
pub fn loudness_shortterm(&self) -> Result<f64, Error>
Get short-term loudness (last 3s) in LUFS.
sourcepub fn loudness_window(&self, window: u32) -> Result<f64, Error>
pub fn loudness_window(&self, window: u32) -> Result<f64, Error>
Get loudness of the specified window in LUFS.
window must not be larger than the current window. The current window can be changed by
calling EbuR128::set_max_window
.
sourcepub fn loudness_range(&self) -> Result<f64, Error>
pub fn loudness_range(&self) -> Result<f64, Error>
Get loudness range (LRA) of programme in LU.
Calculates loudness range according to EBU 3342.
sourcepub fn loudness_range_multiple<'a>(
iter: impl IntoIterator<Item = &'a Self>
) -> Result<f64, Error>
pub fn loudness_range_multiple<'a>( iter: impl IntoIterator<Item = &'a Self> ) -> Result<f64, Error>
Get loudness range (LRA) of programme in LU across multiple instances.
Calculates loudness range according to EBU 3342.
sourcepub fn sample_peak(&self, channel_number: u32) -> Result<f64, Error>
pub fn sample_peak(&self, channel_number: u32) -> Result<f64, Error>
Get maximum sample peak from all frames that have been processed.
The equation to convert to dBFS is: 20 * log10(out)
sourcepub fn prev_sample_peak(&self, channel_number: u32) -> Result<f64, Error>
pub fn prev_sample_peak(&self, channel_number: u32) -> Result<f64, Error>
Get maximum sample peak from the last call to
EbuR128::add_frames
.
The equation to convert to dBFS is: 20 * log10(out)
sourcepub fn true_peak(&self, channel_number: u32) -> Result<f64, Error>
pub fn true_peak(&self, channel_number: u32) -> Result<f64, Error>
Get maximum true peak from all frames that have been processed.
Uses an implementation defined algorithm to calculate the true peak. Do not try to compare resulting values across different versions of the library, as the algorithm may change.
The current implementation uses a custom polyphase FIR interpolator to calculate true peak. Will oversample 4x for sample rates < 96000 Hz, 2x for sample rates < 192000 Hz and leave the signal unchanged for 192000 Hz.
The equation to convert to dBTP is: 20 * log10(out)
sourcepub fn prev_true_peak(&self, channel_number: u32) -> Result<f64, Error>
pub fn prev_true_peak(&self, channel_number: u32) -> Result<f64, Error>
Get maximum true peak from the last call to
EbuR128::add_frames
.
Uses an implementation defined algorithm to calculate the true peak. Do not try to compare resulting values across different versions of the library, as the algorithm may change.
The current implementation uses a custom polyphase FIR interpolator to calculate true peak. Will oversample 4x for sample rates < 96000 Hz, 2x for sample rates < 192000 Hz and leave the signal unchanged for 192000 Hz.
The equation to convert to dBTP is: 20 * log10(out)
sourcepub fn relative_threshold(&self) -> Result<f64, Error>
pub fn relative_threshold(&self) -> Result<f64, Error>
Get relative threshold in LUFS.