API

Interface IAudioEngine

This represents an audio engine and it is responsible to play, synchronize and analyse sounds throughout the application.

interface IAudioEngine {
    audioContext: Nullable<AudioContext>;
    canUseWebAudio: boolean;
    isMP3supported: boolean;
    isOGGsupported: boolean;
    masterGain: GainNode;
    onAudioLockedObservable: Observable<IAudioEngine>;
    onAudioUnlockedObservable: Observable<IAudioEngine>;
    unlocked: boolean;
    useCustomUnlockedButton: boolean;
    WarnedWebAudioUnsupported: boolean;
    connectToAnalyser(analyser: Analyser): void;
    dispose(): void;
    getGlobalVolume(): number;
    lock(): void;
    setGlobalVolume(newVolume: number): void;
    unlock(): void;
}

Hierarchy (View Summary)

Implemented by

Index
audioContext: Nullable<AudioContext>

Gets the current AudioContext if available.

canUseWebAudio: boolean

Gets whether the current host supports Web Audio and thus could create AudioContexts.

isMP3supported: boolean

Gets whether or not mp3 are supported by your browser.

isOGGsupported: boolean

Gets whether or not ogg are supported by your browser.

masterGain: GainNode

The master gain node defines the global audio volume of your audio engine.

onAudioLockedObservable: Observable<IAudioEngine>

Event raised when audio has been locked on the browser.

onAudioUnlockedObservable: Observable<IAudioEngine>

Event raised when audio has been unlocked on the browser.

unlocked: boolean

Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).

useCustomUnlockedButton: boolean

Defines if the audio engine relies on a custom unlocked button. In this case, the embedded button will not be displayed.

WarnedWebAudioUnsupported: boolean

Defines if Babylon should emit a warning if WebAudio is not supported.