Usage
Simple
The simplest way to use an envelope is adsr . It provides a function which in turn gives a number from 0..1 for the amplitude of the envelope. See options for more on the options that can be passed in.
More practically, you’d likely read the value of the envelope when you’re updating other sketch state. A limit of adsr
is that you can’t control the envelope (eg re-trigger) or know exactly when it finishes. For this you want the more advanced usage…
Advanced
The Envelopes.Adsr class allows for more control over an envelope. See options for more on the options that can be passed in.
In basic usage, you first trigger the envelope, and then read its value over time, probably from some kind of loop.
You can ‘trigger-and-hold’, making the envelope stay at the sustain stage until ‘release’ is called:
The value
property gives you the value of the envelope at that point in time. You can get additional data with compute()
:
Other functions:
Envelopes have events: