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()));
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Adsr
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