pub struct Envelope {
pub attack: Duration,
pub decay: Duration,
pub sustain: f64,
pub release: Duration,
pub shape: EnvelopeShape,
}Expand description
An attack/decay/sustain/release amplitude envelope.
Fields§
§attack: DurationTime taken to rise from silence to full level.
decay: DurationTime taken to fall from full level to the sustain level.
sustain: f64Held level during the sustain phase, in 0.0..=1.0.
release: DurationTime taken to fall from the sustain level back to silence.
shape: EnvelopeShapeInterpolation curve applied across the stages.
Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn new(
attack: Duration,
decay: Duration,
sustain: f64,
release: Duration,
shape: EnvelopeShape,
) -> Result<Self, SoundCoreError>
pub fn new( attack: Duration, decay: Duration, sustain: f64, release: Duration, shape: EnvelopeShape, ) -> Result<Self, SoundCoreError>
Builds an envelope, returning SoundCoreError::InvalidSustain when
sustain falls outside 0.0..=1.0.
Sourcepub fn sample_level(&self, t: Duration, total: Duration) -> f64
pub fn sample_level(&self, t: Duration, total: Duration) -> f64
Returns the envelope level in 0.0..=1.0 at elapsed time t for a tone
of length total.
Trait Implementations§
impl StructuralPartialEq for Envelope
Auto Trait Implementations§
impl Freeze for Envelope
impl RefUnwindSafe for Envelope
impl Send for Envelope
impl Sync for Envelope
impl Unpin for Envelope
impl UnsafeUnpin for Envelope
impl UnwindSafe for Envelope
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