Class: WebAudioContext

webaudio.WebAudioContext

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

Extends

Implements

Members

webaudio.WebAudioContext.AudioContext AudioContext staticreadonly

Get AudioContext class, if not supported returns null

webaudio.WebAudioContext.OfflineAudioContext OfflineAudioContext staticreadonly

Get OfflineAudioContext class, if not supported returns null

analyser AnalyserNode readonly

Context Analyser node

audioContext AudioContext readonly

The WebAudio API AudioContext object.

compressor DynamicsCompressorNode readonly

Context Compressor node

events PIXI.utils.EventEmitter

Handle global events

muted boolean

Sets the muted state.

Default Value:
  • false

offlineContext OfflineAudioContext readonly

The WebAudio API OfflineAudioContext object.

paused boolean

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.

Default Value:
  • false

speed number readonly

Global speed of all sounds

volume number

Sets the volume from 0 to 1.

Default Value:
  • 1

Methods

_unlock () void

Try to unlock audio on iOS. This is triggered from either WebAudio plugin setup (which will work if inside of a mousedown or touchend event stack), or the first document touchend/mousedown event. If it fails (touchend will fail if the user presses for too long, indicating a scroll event instead of a click event.

Note that earlier versions of iOS supported touchstart for this, but iOS9 removed this functionality. Adding a touchstart event to support older platforms may preclude a mousedown even from getting fired on iOS9, so we stick with mousedown and touchend.

decode (arrayBuffer, callback) void

Decode the audio data

Name Type Description
arrayBuffer ArrayBuffer

Buffer from loader

callback Function

When completed, error and audioBuffer are parameters.

destroy () void overrides

Destroy this context.

playEmptySound () 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).

refresh () void

Emit event when muted, volume or speed changes

refreshPaused () void

Emit event when muted, volume or speed changes

toggleMute () boolean

Toggles the muted state.

Returns:
Type Description
boolean The current muted state.

togglePause () boolean

Toggles the paused state.

Returns:
Type Description
boolean The current muted state.

Inherited Properties

From class Filterable

destination inherited

The destination output audio node

filters Array<filters.Filter> inherited

The collection of filters