pub struct GainRamp { /* private fields */ }Expand description
Linear gain ramp for smooth transitions between tracks. Caches the current gain and per-sample delta so accessors stay cheap.
Use cases:
- Track-to-track gain changes
- Mute/unmute transitions
- Bypass switching
Implementations§
Source§impl GainRamp
impl GainRamp
Sourcepub fn new(from: f64, to: f64, sample_rate: u32, ramp_ms: u32) -> Self
pub fn new(from: f64, to: f64, sample_rate: u32, ramp_ms: u32) -> Self
Create a new gain ramp
§Arguments
from- Starting gain (linear)to- Target gain (linear)sample_rate- Sample rate in Hzramp_ms- Ramp duration in milliseconds
Sourcepub fn fade_in(target: f64, sample_rate: u32, ramp_ms: u32) -> Self
pub fn fade_in(target: f64, sample_rate: u32, ramp_ms: u32) -> Self
Create a ramp from 0 to target (fade in)
Sourcepub fn fade_out(from: f64, sample_rate: u32, ramp_ms: u32) -> Self
pub fn fade_out(from: f64, sample_rate: u32, ramp_ms: u32) -> Self
Create a ramp from current to 0 (fade out)
Sourcepub fn next_gain(&mut self) -> f64
pub fn next_gain(&mut self) -> f64
Get the next gain value (call once per sample) Uses a cached per-sample delta and snaps to the target at ramp end.
Sourcepub fn apply(&mut self, samples: &mut [f64])
pub fn apply(&mut self, samples: &mut [f64])
Apply gain ramp to a buffer (more efficient than per-sample calls)
Sourcepub fn remaining_samples(&self) -> usize
pub fn remaining_samples(&self) -> usize
Get remaining samples
Auto Trait Implementations§
impl Freeze for GainRamp
impl RefUnwindSafe for GainRamp
impl Send for GainRamp
impl Sync for GainRamp
impl Unpin for GainRamp
impl UnsafeUnpin for GainRamp
impl UnwindSafe for GainRamp
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