pub struct Gain<T: ?Sized> { /* private fields */ }Expand description
Amplifies a signal dynamically
To implement a volume control, place a gain combinator near the end of your pipeline where the
input amplitude is initially in the range [0, 1] and pass decibels to GainControl::set_gain,
mapping the maximum volume to 0 decibels, and the minimum to e.g. -60.
Implementations§
source§impl<T> Gain<T>
impl<T> Gain<T>
sourcepub fn new(signal: T) -> (GainControl, Self)
pub fn new(signal: T) -> (GainControl, Self)
Apply dynamic amplification to signal
sourcepub fn set_gain(&mut self, db: f32)
pub fn set_gain(&mut self, db: f32)
Set the initial amplification to db decibels
Perceptually linear. Negative values make the signal quieter.
Equivalent to self.set_amplitude_ratio(10.0f32.powf(db / 20.0)).
sourcepub fn set_amplitude_ratio(&mut self, factor: f32)
pub fn set_amplitude_ratio(&mut self, factor: f32)
Set the initial amplitude scaling of the signal directly
This is nonlinear in terms of both perception and power. Most users should prefer
set_gain. Unlike set_gain, this method allows a signal to be completely zeroed out if
needed, or even have its phase inverted with a negative factor.