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 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.
| 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, 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.
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 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.
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 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.
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.