Struct synth_utils::adsr::Adsr
source · pub struct Adsr { /* private fields */ }Expand description
An ADSR envelope generator is represented here
Implementations§
source§impl Adsr
impl Adsr
sourcepub fn tick(&mut self)
pub fn tick(&mut self)
adsr.tick() advances the ADSR by 1 tick, must be called at the sample rate
sourcepub fn gate_on(&mut self)
pub fn gate_on(&mut self)
adsr.gate_on() sends a gate-on message to the ADSR, triggering an ATTACK phase if it’s not already in ATTACK
Attack phases may be re-triggered by sending a new gate-on message during any phase.
sourcepub fn gate_off(&mut self)
pub fn gate_off(&mut self)
adsr.gate_off() sends a gate-off message to the ADSR, triggering a RELEASE phase unless it’s already RELEASED
sourcepub fn set_input(&mut self, input: Input)
pub fn set_input(&mut self, input: Input)
adsr.set_input(i) sets the given ADSR input
Examples
// set attack time to 30 milliseconds
adsr.set_input(adsr::Input::Attack(0.03_f32.into()));
// set decay time to 100 milliseconds
adsr.set_input(adsr::Input::Decay(0.1_f32.into()));
// set sustain level to 3/4 way up
adsr.set_input(adsr::Input::Sustain(0.75_f32.into()));
// set release time to 150 milliseconds
adsr.set_input(adsr::Input::Release(0.15_f32.into()));Auto Trait Implementations§
impl RefUnwindSafe for Adsr
impl Send for Adsr
impl Sync for Adsr
impl Unpin for Adsr
impl UnwindSafe for Adsr
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