pub struct NoiseShaper { /* private fields */ }Expand description
High-order noise shaping quantizer with SoX-verified coefficients
Features:
- 9-tap error feedback (supports all SoX curves)
- Internal xorshift64 RNG (realtime-safe, no thread_rng overhead)
- TPDF dither at ±1 LSB (standard amplitude)
- Error clamp ±2 LSB (prevents burst noise)
- Runtime curve switching with history reset
Implementations§
Source§impl NoiseShaper
impl NoiseShaper
Sourcepub fn new(channels: usize, sample_rate: u32, bits: u32) -> Self
pub fn new(channels: usize, sample_rate: u32, bits: u32) -> Self
Create new NoiseShaper with auto-selected curve
Sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Enable or disable noise shaping
Sourcepub fn set_bits(&mut self, bits: u32)
pub fn set_bits(&mut self, bits: u32)
Set target bit depth (Defect 37 fix)
Reachable from the audio thread via NoiseShaperProcessor::sync_params, so
this must stay allocation- and log-free.
Sourcepub fn curve(&self) -> NoiseShaperCurve
pub fn curve(&self) -> NoiseShaperCurve
Get current curve
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
Get current sample rate
Sourcepub fn set_curve(&mut self, curve: NoiseShaperCurve)
pub fn set_curve(&mut self, curve: NoiseShaperCurve)
Switch to a different noise shaping curve.
Clears error history to prevent artifacts from coefficient mismatch, and
respects the caller’s explicit choice even when the curve is not recommended
for the current sample rate (callers can query NoiseShaperCurve::is_recommended_for
beforehand). Reachable from the audio thread via
NoiseShaperProcessor::sync_params, so it stays allocation- and log-free.
Sourcepub fn set_sample_rate(&mut self, sample_rate: u32)
pub fn set_sample_rate(&mut self, sample_rate: u32)
Update sample rate (triggers curve auto-selection)
Sourcepub fn process_sample(&mut self, sample: f64, ch: usize) -> f64
pub fn process_sample(&mut self, sample: f64, ch: usize) -> f64
Auto Trait Implementations§
impl Freeze for NoiseShaper
impl RefUnwindSafe for NoiseShaper
impl Send for NoiseShaper
impl Sync for NoiseShaper
impl Unpin for NoiseShaper
impl UnsafeUnpin for NoiseShaper
impl UnwindSafe for NoiseShaper
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