• Returns an envelope: a function from Sound to Sound. When the adsr envelope is applied to a Sound, it returns a new Sound with its amplitude modified according to parameters The relative amplitude increases from 0 to 1 linearly over the attack proportion, then decreases from 1 to sustain level over the decay proportion, and remains at that level until the release proportion when it decays back to 0.

    Parameters

    • attack_ratio: number

      proportion of Sound in attack phase

    • decay_ratio: number

      proportion of Sound decay phase

    • sustain_level: number

      sustain level between 0 and 1

    • release_ratio: number

      proportion of Sound in release phase

    Returns SoundTransformer

    Envelope a function from Sound to Sound

    Example

    adsr(0.2, 0.3, 0.3, 0.1)(sound);