Returns 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
ProtectedcomputeProtectedfireFire event
Type of event
Arguments for event
ProtectedonRelease if 'trigger(true)' was previouslly called. Has no effect if not triggered or held.
Remove event listener
ProtectedswitchChanges state based on timer status
True if state was changed
Triggers 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
ReadonlyattackProtectedattackReadonlyattackReadonlydecayProtecteddecayProtecteddecayReadonlydecayReadonlyinitialProtectedinitialReadonlypeakReadonlyreleaseProtectedreleaseReadonlyreleaseReadonlyreleaseReadonlyretriggerIf true envelope will loop
Readonlysustain
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
retriggeris false (default), a re-triggered envelope continues at current value rather than resetting toinitialLevel.If
shouldLoopis true, envelope loops untilrelease()is called.Example: Using
stateis a string, one of the following: 'attack', 'decay', 'sustain', 'release', 'complete'scaledis a value scaled according to the stage's levelsrawis 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 thevalueproperty, 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: