Base class for an ADSR envelope.

It outputs values on a scale of 0..1 corresponding to each phase.

Hierarchy (view full)

Constructors

  • Parameters

    • opts: Partial<{
          attackDuration: number;
          decayDuration: number;
          releaseDuration: number;
          shouldLoop: boolean;
      }> = {}

    Returns AdsrBase

Properties

attackDuration: number
decayDuration: number
decayDurationTotal: number
releaseDuration: number
shouldLoop: boolean

If true envelope will loop

Accessors

  • get hasTriggered(): boolean
  • Returns boolean

  • get isDisposed(): boolean
  • Returns boolean

  • get isDone(): boolean
  • Returns true if envelope has finished

    Returns boolean

Methods

  • Returns void

  • Computes a stage's progress from 0-1

    Parameters

    • allowStateChange: boolean = true
    • allowLooping: boolean = true

    Returns [stage: string, amount: number, prevStage: string]

  • Returns void

  • Release if 'trigger(true)' was previouslly called. Has no effect if not triggered or held.

    Returns void

  • Changes state based on timer status

    Parameters

    • allowLooping: boolean

    Returns boolean

    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

    • false (default): envelope continues at current value.
    • true: envelope value resets to opts.initialValue.

    Parameters

    • hold: boolean = false

      If true envelope will hold at sustain stage

    Returns void