pub struct PeakLimiter { /* private fields */ }Expand description
True Peak Limiter with look-ahead and proper release behavior.
§Design
- 10ms look-ahead buffer for peak detection
- -1.0 dBTP threshold (EBU R128 recommendation)
- Proper release coefficient using exponential smoothing
- Fixed ring buffer avoids heap allocation in audio callback
Implementations§
Source§impl PeakLimiter
impl PeakLimiter
Sourcepub fn new(
channels: usize,
sample_rate: u32,
threshold_db: f64,
lookahead_ms: f64,
release_ms: f64,
) -> Self
pub fn new( channels: usize, sample_rate: u32, threshold_db: f64, lookahead_ms: f64, release_ms: f64, ) -> Self
Create a new True Peak Limiter
§Arguments
channels- Number of audio channelssample_rate- Sample rate in Hzthreshold_db- Threshold in dBTP (default: -1.0)lookahead_ms- Look-ahead time in ms (default: 10.0)release_ms- Release time in ms (default: 100.0)
Sourcepub fn process(&mut self, samples: &mut [f64])
pub fn process(&mut self, samples: &mut [f64])
Process interleaved samples in-place
This function is real-time safe:
- No heap allocations
- No system calls
- O(n) complexity where n = number of samples
Sourcepub fn set_threshold_db(&mut self, threshold_db: f64)
pub fn set_threshold_db(&mut self, threshold_db: f64)
Set threshold in dB
Sourcepub fn set_threshold(&mut self, threshold_db: f64)
pub fn set_threshold(&mut self, threshold_db: f64)
Update threshold in-place without reallocating lookahead buffer.
Sourcepub fn set_release_ms(&mut self, release_ms: f64)
pub fn set_release_ms(&mut self, release_ms: f64)
Update release time in-place without reallocating lookahead buffer.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if limiter is conceptually enabled (always true for PeakLimiter)
Sourcepub fn gain_reduction_db(&self) -> f64
pub fn gain_reduction_db(&self) -> f64
Get current gain reduction in dB (for metering)
Auto Trait Implementations§
impl Freeze for PeakLimiter
impl RefUnwindSafe for PeakLimiter
impl Send for PeakLimiter
impl Sync for PeakLimiter
impl Unpin for PeakLimiter
impl UnsafeUnpin for PeakLimiter
impl UnwindSafe for PeakLimiter
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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