Skip to main content

LoudnessMeter

Struct LoudnessMeter 

Source
pub struct LoudnessMeter { /* private fields */ }
Expand description

A streaming BS.1770-4 / EBU R128 loudness meter.

Implementations§

Source§

impl LoudnessMeter

Source

pub fn new(sample_rate: u32, channels: usize) -> Result<Self, LoudnessError>

A meter for channels channels at sample_rate, in the layout a source of that many channels that declares none has (SpeakerLayout::default_for: FFmpeg’s default order, which the mix folds such a source by), weighted as Self::for_speakers weighs it.

ChannelsOrderWeights
1, 2C / L R1
3L R LFE1 1 0
4L R C Cs1 1 1 1
5L R C Ls Rs1 1 1 1.41 1.41
6L R C LFE Ls Rs1 1 1 0 1.41 1.41
7L R C LFE Cs Ls Rs1 1 1 0 1 1.41 1.41
8L R C LFE Lrs Rrs Lss Rss1 1 1 0 1 1 1.41 1.41

Above eight, the named layouts (5.1.4, 7.1.4, 9.1.4, 9.1.6, 22.2) weigh by their speakers too, and a count with none is a 7.1 whose further channels weigh 1.0.

§Errors

Returns LoudnessError::InvalidShape for zero channels, more than alpha2_media::MAX_AUDIO_CHANNELS, or a rate outside 8 to 96 kHz.

Source

pub fn for_speakers( sample_rate: u32, speakers: &[Speaker], ) -> Result<Self, LoudnessError>

A meter for planes feeding speakers, weighted as BS.1770-4 (Annex 1, Table 4) weighs them: the LFE does not count, a surround 60 to 120 degrees off centre at ear height weighs 1.41, and every other speaker 1.0.

The side speakers sit there (90 to 110 degrees), and so do the back pair of a layout without sides: the surrounds of 5.0 and 5.1, which FFmpeg names back left and right. Beside sides, the back pair is a 7.1’s rear (135 to 150 degrees) and weighs 1.0. A height or bottom speaker is 30 degrees off ear height and weighs 1.0, as does a speaker no position names.

§Errors

Returns LoudnessError::InvalidShape for no speakers or a rate outside 8 to 96 kHz.

Source

pub fn with_weights( sample_rate: u32, weights: &[f64], ) -> Result<Self, LoudnessError>

A meter with one explicit weight per channel.

§Errors

Returns LoudnessError::InvalidShape for no weights, a negative or non-finite weight, or a rate outside 8 to 96 kHz.

Source

pub fn push(&mut self, planes: &[&[f32]]) -> Result<(), LoudnessError>

Measures one block of planar samples, one slice per channel, all of one length. An infinite or NaN sample measures as silence.

§Errors

Returns LoudnessError::MismatchedBlock for another channel count or ragged planes.

Source

pub fn momentary_lufs(&self) -> Option<f64>

Momentary loudness of the last 400 ms, in LUFS.

Source

pub fn short_term_lufs(&self) -> Option<f64>

Short-term loudness of the last 3 s, in LUFS.

Source

pub fn report(&self) -> LoudnessReport

Everything measured so far.

Trait Implementations§

Source§

impl Clone for LoudnessMeter

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LoudnessMeter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.