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 in the SpeakerLayout::default_for layout, weighted as Self::for_speakers does.

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, named layouts (5.1.4, 7.1.4, 9.1.4, 9.1.6, 22.2) weigh by speaker; other counts are 7.1 plus channels of weight 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 per BS.1770-4 Annex 1 Table 4: LFE 0, ear-height surrounds 60 to 120 degrees off centre 1.41, everything else 1.0.

Side speakers get 1.41, as do back speakers in layouts without sides (5.0 and 5.1 surrounds, which FFmpeg calls back left and right). With sides present, the back pair is a 7.1 rear and weighs 1.0. Height, bottom and unnamed speakers weigh 1.0.

§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 equal-length planes. Non-finite samples measure 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.