ebur128_stream/report.rs
1//! Final measurements after [`Analyzer::finalize`].
2//!
3//! [`Report`] is what the analyzer produces when streaming is finished.
4//! Compared to [`Snapshot`](crate::Snapshot), it includes programme-final
5//! values like the maximum momentary / short-term LUFS observed and the
6//! finalized loudness range.
7
8/// Programme-final loudness measurements.
9///
10/// Returned from [`Analyzer::finalize`]. Each accessor returns
11/// `Option<f64>`:
12/// - `Some(value)` when the corresponding [`Mode`](crate::Mode) was
13/// requested *and* enough data was ingested.
14/// - `None` otherwise.
15///
16/// [`Analyzer::finalize`]: crate::Analyzer::finalize
17#[derive(Debug, Clone, Copy, Default, PartialEq)]
18#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
19pub struct Report {
20 pub(crate) integrated_lufs: Option<f64>,
21 pub(crate) loudness_range_lu: Option<f64>,
22 pub(crate) true_peak_dbtp: Option<f64>,
23 pub(crate) momentary_max_lufs: Option<f64>,
24 pub(crate) short_term_max_lufs: Option<f64>,
25 pub(crate) programme_duration_seconds: f64,
26}
27
28impl Report {
29 /// Integrated programme loudness in LUFS, gated per BS.1770-4 §5.6.
30 #[inline]
31 #[must_use]
32 pub fn integrated_lufs(&self) -> Option<f64> {
33 self.integrated_lufs
34 }
35
36 /// Loudness range in LU per EBU Tech 3342.
37 #[inline]
38 #[must_use]
39 pub fn loudness_range_lu(&self) -> Option<f64> {
40 self.loudness_range_lu
41 }
42
43 /// Maximum true peak in dBTP (decibels relative to full scale, true
44 /// peak — i.e. measured after 4× oversampling per BS.1770 Annex 2).
45 #[inline]
46 #[must_use]
47 pub fn true_peak_dbtp(&self) -> Option<f64> {
48 self.true_peak_dbtp
49 }
50
51 /// Maximum momentary loudness observed during the programme, in LUFS.
52 #[inline]
53 #[must_use]
54 pub fn momentary_max_lufs(&self) -> Option<f64> {
55 self.momentary_max_lufs
56 }
57
58 /// Maximum short-term loudness observed during the programme, in LUFS.
59 #[inline]
60 #[must_use]
61 pub fn short_term_max_lufs(&self) -> Option<f64> {
62 self.short_term_max_lufs
63 }
64
65 /// Total programme duration ingested, in seconds.
66 #[inline]
67 #[must_use]
68 pub fn programme_duration_seconds(&self) -> f64 {
69 self.programme_duration_seconds
70 }
71}