pub struct LoudnessMeter { /* private fields */ }Expand description
A streaming BS.1770-4 / EBU R128 loudness meter.
Implementations§
Source§impl LoudnessMeter
impl LoudnessMeter
Sourcepub fn new(sample_rate: u32, channels: usize) -> Result<Self, LoudnessError>
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.
| Channels | Order | Weights |
|---|---|---|
| 1, 2 | C / L R | 1 |
| 3 | L R LFE | 1 1 0 |
| 4 | L R C Cs | 1 1 1 1 |
| 5 | L R C Ls Rs | 1 1 1 1.41 1.41 |
| 6 | L R C LFE Ls Rs | 1 1 1 0 1.41 1.41 |
| 7 | L R C LFE Cs Ls Rs | 1 1 1 0 1 1.41 1.41 |
| 8 | L R C LFE Lrs Rrs Lss Rss | 1 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.
Sourcepub fn for_speakers(
sample_rate: u32,
speakers: &[Speaker],
) -> Result<Self, LoudnessError>
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.
Sourcepub fn with_weights(
sample_rate: u32,
weights: &[f64],
) -> Result<Self, LoudnessError>
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.
Sourcepub fn push(&mut self, planes: &[&[f32]]) -> Result<(), LoudnessError>
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.
Sourcepub fn momentary_lufs(&self) -> Option<f64>
pub fn momentary_lufs(&self) -> Option<f64>
Momentary loudness of the last 400 ms, in LUFS.
Sourcepub fn short_term_lufs(&self) -> Option<f64>
pub fn short_term_lufs(&self) -> Option<f64>
Short-term loudness of the last 3 s, in LUFS.
Sourcepub fn report(&self) -> LoudnessReport
pub fn report(&self) -> LoudnessReport
Everything measured so far.