gameforge - v0.1.12
    Preparing search index...

    Main class to handle WebAudio API. There's a simple chain of AudioNode elements: analyser > compressor > context.destination. any filters that are added are inserted between the analyser and compressor nodes

    webaudio

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    analyser: AnalyserNode

    Context Analyser node

    autoPause: boolean

    Set to false ignore suspending when window is blurred

    compressor: DynamicsCompressorNode

    Context Compressor node

    Handle global events

    muted: boolean

    Sets the muted state.

    false
    
    speed: number

    Global speed of all sounds

    volume: number

    Sets the volume from 0 to 1.

    1
    

    Accessors

    • get audioContext(): AudioContext

      The WebAudio API AudioContext object.

      Returns AudioContext

    • get destination(): AudioNode

      The destination output audio node

      Returns AudioNode

    • get offlineContext(): OfflineAudioContext

      The WebAudio API OfflineAudioContext object.

      Returns OfflineAudioContext

    • get paused(): boolean

      Set the paused state for all sound

      Returns boolean

    • set paused(paused: boolean): void

      Pauses all sounds, even though we handle this at the instance level, we'll also pause the audioContext so that the time used to compute progress isn't messed up.

      Parameters

      • paused: boolean

      Returns void

      false
      
    • get AudioContext(): {
          prototype: AudioContext;
          new (contextOptions?: AudioContextOptions): AudioContext;
      }

      Get AudioContext class, if not supported returns null

      Returns {
          prototype: AudioContext;
          new (contextOptions?: AudioContextOptions): AudioContext;
      }

    • get OfflineAudioContext(): {
          prototype: OfflineAudioContext;
          new (contextOptions: OfflineAudioContextOptions): OfflineAudioContext;
          new (
              numberOfChannels: number,
              length: number,
              sampleRate: number,
          ): OfflineAudioContext;
      }

      Get OfflineAudioContext class, if not supported returns null

      Returns {
          prototype: OfflineAudioContext;
          new (contextOptions: OfflineAudioContextOptions): OfflineAudioContext;
          new (
              numberOfChannels: number,
              length: number,
              sampleRate: number,
          ): OfflineAudioContext;
      }

    Methods

    • Decode the audio data

      Parameters

      • arrayBuffer: ArrayBuffer

        Buffer from loader

      • callback: (err?: Error, buffer?: AudioBuffer) => void

        When completed, error and audioBuffer are parameters.

      Returns void

    • Destroy this context.

      Returns void

    • Plays an empty sound in the web audio context. This is used to enable web audio on iOS devices, as they require the first sound to be played inside of a user initiated event (touch/click).

      Returns void

    • Emit event when muted, volume or speed changes

      Returns void

    • Emit event when muted, volume or speed changes

      Returns void

    • Toggles the muted state.

      Returns boolean

      The current muted state.

    • Toggles the paused state.

      Returns boolean

      The current muted state.