[][src]Struct bs1770::ChannelLoudnessMeter

pub struct ChannelLoudnessMeter { /* fields omitted */ }

Measures K-weighted power of non-overlapping 100ms windows of a single channel of audio.

Output

The output of the meter is an intermediate result in the form of power for 100ms non-overlapping windows. The windows need to be processed further to get one of the instantaneous, momentary, and integrated loudness measurements defined in BS.1770.

The windows can also be inspected directly; the data is meaningful on its own (the K-weighted power delivered in that window of time), but it is not something that BS.1770 defines a term for.

Multichannel audio

To perform a loudness measurement of multichannel audio, construct a ChannelLoudnessMeter per channel, and later combine the measured power with e.g. reduce_stereo.

Instantaneous loudness

The instantaneous loudness is the power over a 400ms window, so you can average four 100ms windows. No special functionality is implemented to help with that at this time. (Pull requests would be accepted.)

Momentary loudness

The momentary loudness is the power over a 3-second window, so you can average thirty 100ms windows. No special functionality is implemented to help with that at this time. (Pull requests would be accepted.)

Integrated loudness

Use gated_mean to perform an integrated loudness measurement:

let integrated_loudness_lkfs = gated_mean(meter.as_100ms_windows()).loudness_lkfs();

Implementations

impl ChannelLoudnessMeter[src]

pub fn new(sample_rate_hz: u32) -> ChannelLoudnessMeter[src]

Construct a new loudness meter for the given sample rate.

pub fn push<I: Iterator<Item = f32>>(&mut self, samples: I)[src]

Feed input samples for loudness analysis.

Full scale

Full scale for the input samples is the interval [-1.0, 1.0]. If your input consists of signed integer samples, you can convert as follows:

// Note that the maximum amplitude is `1 << (bits_per_sample - 1)`,
// one bit is the sign bit.
let normalizer = 1.0 / (1_u64 << (bits_per_sample - 1)) as f32;
meter.push(samples.iter().map(|&s| s as f32 * normalizer));

Repeated calls

You can call push multiple times to feed multiple batches of samples. This is equivalent to feeding a single chained iterator. The leftover of samples that did not fill a full 100ms window is not discarded:

let sample_rate_hz = 44_100;
let samples_per_100ms = sample_rate_hz / 10;
let mut meter = ChannelLoudnessMeter::new(sample_rate_hz);

meter.push(iter::repeat(0.0).take(samples_per_100ms as usize - 1));
assert_eq!(meter.as_100ms_windows().len(), 0);

meter.push(iter::once(0.0));
assert_eq!(meter.as_100ms_windows().len(), 1);

pub fn as_100ms_windows(&self) -> Windows100ms<&[Power]>[src]

Return a reference to the 100ms windows analyzed so far.

pub fn into_100ms_windows(self) -> Windows100ms<Vec<Power>>[src]

Return all 100ms windows analyzed so far.

Trait Implementations

impl Clone for ChannelLoudnessMeter[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.