pub struct LoudnessNormalizer { /* private fields */ }Expand description
Loudness normalizer with EBU R128 compliance. Supports track-based pre-analysis and real-time streaming modes.
Implementations§
Source§impl LoudnessNormalizer
impl LoudnessNormalizer
pub fn new(channels: usize, sample_rate: u32, config: LoudnessConfig) -> Self
pub fn atomic_state(&self) -> Arc<AtomicLoudnessState>
pub fn set_enabled(&mut self, enabled: bool)
pub fn set_config(&mut self, config: LoudnessConfig)
pub fn set_target_lufs(&mut self, target_lufs: f64)
pub fn set_album_gain(&self, gain_db: f64)
pub fn set_preamp_gain(&self, gain_db: f64)
pub fn set_mode(&self, mode: NormalizationMode)
Sourcepub fn analyze_track(&mut self, samples: &[f64]) -> f64
pub fn analyze_track(&mut self, samples: &[f64]) -> f64
Pre-analyze track loudness (call before streaming playback)
FIX for Defect 39: Check loudness.is_finite() to prevent +inf gain when ebur128 returns -inf (silent or very short tracks <400ms). Invalid loudness values result in 0 dB gain (no normalization).
Sourcepub fn calculate_gain(&mut self, samples: &[f64]) -> f64
pub fn calculate_gain(&mut self, samples: &[f64]) -> f64
Calculate track gain without updating atomic state (for gapless preload) Returns the target gain in dB that should be applied after buffer swap. This prevents premature gain update during the last seconds of current track.
FIX for Defect 39: Check loudness.is_finite() to prevent +inf gain when ebur128 returns -inf (silent or very short tracks <400ms).
Sourcepub fn calculate_gain_with_mode(
&mut self,
samples: &[f64],
mode: NormalizationMode,
metadata: &TrackMetadata,
) -> f64
pub fn calculate_gain_with_mode( &mut self, samples: &[f64], mode: NormalizationMode, metadata: &TrackMetadata, ) -> f64
Calculate gain for gapless preload with mode awareness (Bug-4 fix)
For ReplayGain modes, reads gain from metadata tags instead of EBU R128 analysis. Falls back to EBU R128 if tags are missing.
pub fn reset(&mut self)
pub fn get_loudness_info(&self) -> LoudnessInfo
pub fn track_loudness(&self) -> Option<f64>
pub fn is_analyzed(&self) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for LoudnessNormalizer
impl !UnwindSafe for LoudnessNormalizer
impl Freeze for LoudnessNormalizer
impl Send for LoudnessNormalizer
impl Sync for LoudnessNormalizer
impl Unpin for LoudnessNormalizer
impl UnsafeUnpin for LoudnessNormalizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more