API

Interface IWebAudioEngineOptions

Options for creating a v2 audio engine that uses the WebAudio API.

interface IWebAudioEngineOptions {
    audioContext: AudioContext;
    defaultUIParentElement?: HTMLElement;
    disableDefaultUI?: boolean;
    disableIOSRingerSwitchWorkaround?: boolean;
    listenerAutoUpdate: boolean;
    listenerEnabled: boolean;
    listenerMinUpdateTime: number;
    listenerPosition: Vector3;
    listenerRotation: Vector3;
    listenerRotationQuaternion: Quaternion;
    parameterRampDuration: number;
    resumeOnInteraction: boolean;
    resumeOnPause: boolean;
    resumeOnPauseRetryInterval: number;
    volume: number;
}

Hierarchy (View Summary)

Index
audioContext: AudioContext

The audio context to be used by the engine.

defaultUIParentElement?: HTMLElement

The default UI's parent element. Defaults to the last created graphics engine's canvas if it exists; otherwise the HTML document's body.

disableDefaultUI?: boolean

Set to true to disable the default UI. Defaults to false.

disableIOSRingerSwitchWorkaround?: boolean

Set to true to disable the silent HTML audio element used to allow WebAudio playback when the iOS ringer switch is off. This can avoid rendering performance degradation on affected iOS and iPadOS devices, but WebAudio may be muted when the ringer switch is off. Defaults to false.

listenerAutoUpdate: boolean

Whether to automatically update the position and rotation of the listener. Defaults to true.

listenerEnabled: boolean

Set to true to enable the listener. Defaults to false.

listenerMinUpdateTime: number

The minimum update time in seconds of the listener if it is attached to a mesh, scene or transform node. Defaults to 0.

  • The listener's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.
listenerPosition: Vector3

The listener position. Defaults to (0, 0, 0).

listenerRotation: Vector3

The listener rotation, as Euler angles. Defaults to (0, 0, 0).

listenerRotationQuaternion: Quaternion

The listener rotation, as a quaternion. Defaults to (0, 0, 0, 1).

parameterRampDuration: number

The smoothing duration to use when changing audio parameters, in seconds. Defaults to 0.01 (10 milliseconds).

resumeOnInteraction: boolean

Set to true to automatically resume the audio context when the user interacts with the page. Defaults to true.

resumeOnPause: boolean

Set to true to automatically resume the audio context when the browser pauses audio playback. Defaults to true.

resumeOnPauseRetryInterval: number

The interval in milliseconds to try resuming audio playback when resumeOnPause is true. Defaults to 1000.

volume: number

The initial output volume of the audio engine. Defaults to 1.