Readonly
attackProtected
attackReadonly
attackReadonly
decayProtected
decayProtected
decayReadonly
decayReadonly
initialProtected
initialReadonly
peakReadonly
releaseProtected
releaseReadonly
releaseReadonly
releaseReadonly
retriggerIf true envelope will loop
Readonly
sustainReturns true if envelope has finished
Returns the scaled value Same as .compute()[1]
Adds event listener.
Events
Event name
Event handler
Compute value of envelope at this point in time.
Returns an array of [stage, scaled, raw]. Most likely you want to use value to just get the scaled value.
If true (default) envelope will be allowed to change state if necessary before returning value
Protected
computeProtected
fireFire event
Type of event
Arguments for event
Protected
onRemove event listener
Protected
switchTriggers envelope, optionally holding it.
If hold
is false (default), envelope will run through all stages,
but sustain stage won't have an affect.
If hold
is true, it will run to, and stay at the sustain stage.
Use release to later release the envelope.
If event is already trigged it will be retriggered.
Initial value depends on opts.retrigger
opts.initialValue
.If true envelope will hold at sustain stage
ADSR (Attack Decay Sustain Release) envelope. An envelope is a value that changes over time, usually in response to an intial trigger.
See the ixfx Guide on Envelopes.
Example: Setup
Options for envelope are as follows:
If
retrigger
is false (default), a re-triggered envelope continues at current value rather than resetting toinitialLevel
.If
shouldLoop
is true, envelope loops untilrelease()
is called.Example: Using
state
is a string, one of the following: 'attack', 'decay', 'sustain', 'release', 'complete'scaled
is a value scaled according to the stage's levelsraw
is the progress from 0 to 1 within a stage. ie. 0.5 means we're halfway through a stage.Instead of
compute()
, most usage of the envelope is just fetching thevalue
property, which returns the same scaled value ofcompute()
:Example: Hold & release
Check if it's done:
Envelope has events to track activity: 'change' and 'complete':
It's also possible to iterate over the values of the envelope: