Class AudioEngineV2Abstract
Implements
Properties
Abstract Readonlycurrent Time
The elapsed time since the audio engine was started, in seconds.
Abstract Readonlylistener
The spatial audio listener properties for the audio engine.
- Each audio engine has exactly one listener.
Abstract Readonlymain Out
The main output node.
- This is the last node in the audio graph before the audio is sent to the speakers.
Abstract Readonlystate
The current state of the audio engine.
Possible values are:
"closed": The audio engine has been closed."interrupted": The audio engine has been interrupted and is not running."running": The audio engine is running normally."suspended": The audio engine is suspended and is not running.
Abstractvolume
The output volume of the audio engine.
Accessors
default Main Bus
-
The default main bus that will be used for audio buses and sounds if their
outBusoption is not set.Returns Nullable<MainAudioBus>
nodes
-
The list of top-level audio nodes (sounds, sound sources, buses, main buses) owned by the audio engine.
Returns ReadonlySet<AbstractNamedAudioNode>
on Dispose Observable
-
Observable that notifies when this engine is disposed.
- Fires from AudioEngineV2.dispose after the engine has been removed from AudioEngineV2.Instances.
Returns IReadonlyObservable<AudioEngineV2>
on Node Added Observable
-
Observable that notifies when a top-level audio node (sound, sound source, bus, or main bus) is added to this engine.
Returns IReadonlyObservable<AbstractNamedAudioNode>
on Node Removed Observable
-
Observable that notifies when a top-level audio node (sound, sound source, bus, or main bus) is removed from this engine.
Returns IReadonlyObservable<AbstractNamedAudioNode>
parameter Ramp Duration
-
get parameterRampDuration(): number
The smoothing duration to use when changing audio parameters, in seconds. Defaults to
0.01(10 milliseconds).Returns number
-
set parameterRampDuration(value: number): void
Parameters
- value: number
Returns void
sounds
-
The list of static and streaming sounds created by the audio engine.
Returns readonly AbstractSound[]
StaticInstances
-
The list of v2 audio engines that have been created and not yet disposed.
- Engines are added on construction and removed on AudioEngineV2.dispose.
Returns readonly AudioEngineV2[]
Methods
Abstractcreate Bus Async
-
Creates a new audio bus.
Parameters
- name: string
The name of the audio bus.
Optionaloptions: Partial<IAudioBusOptions>The options to use when creating the audio bus.
Returns Promise<AudioBus>
A promise that resolves with the created audio bus.
- name: string
Abstractcreate Main Bus Async
-
Creates a new main audio bus.
Parameters
- name: string
The name of the main audio bus.
Optionaloptions: Partial<IMainAudioBusOptions>The options to use when creating the main audio bus.
Returns Promise<MainAudioBus>
A promise that resolves with the created main audio bus.
- name: string
Abstractcreate Microphone Sound Source Async
-
createMicrophoneSoundSourceAsync(
name: string,
options?: Partial<ISoundSourceOptions>,
): Promise<AbstractSoundSource>Creates a new microphone sound source.
Parameters
- name: string
The name of the sound.
Optionaloptions: Partial<ISoundSourceOptions>The options for the sound source.
Returns Promise<AbstractSoundSource>
A promise that resolves to the created sound source.
- name: string
Abstractcreate Sound Async
-
createSoundAsync(
name: string,
source: string | string[] | ArrayBuffer | AudioBuffer | StaticSoundBuffer,
options?: Partial<IStaticSoundOptions>,
): Promise<StaticSound>Creates a new static sound.
Parameters
- name: string
The name of the sound.
- source: string | string[] | ArrayBuffer | AudioBuffer | StaticSoundBuffer
The source of the sound.
Optionaloptions: Partial<IStaticSoundOptions>The options for the static sound.
Returns Promise<StaticSound>
A promise that resolves to the created static sound.
- name: string
Abstractcreate Sound Buffer Async
-
createSoundBufferAsync(
source:
| string
| string[]
| ArrayBuffer
| AudioBuffer
| StaticSoundBuffer,
options?: Partial<IStaticSoundBufferOptions>,
): Promise<StaticSoundBuffer>Creates a new static sound buffer.
Parameters
- source: string | string[] | ArrayBuffer | AudioBuffer | StaticSoundBuffer
The source of the sound buffer.
Optionaloptions: Partial<IStaticSoundBufferOptions>The options for the static sound buffer.
Returns Promise<StaticSoundBuffer>
A promise that resolves to the created static sound buffer.
- source: string | string[] | ArrayBuffer | AudioBuffer | StaticSoundBuffer
Abstractcreate Sound Source Async
-
createSoundSourceAsync(
name: string,
source: AudioNode,
options?: Partial<ISoundSourceOptions>,
): Promise<AbstractSoundSource>Creates a new sound source.
Parameters
- name: string
The name of the sound.
- source: AudioNode
The source of the sound.
Optionaloptions: Partial<ISoundSourceOptions>The options for the sound source.
Returns Promise<AbstractSoundSource>
A promise that resolves to the created sound source.
- name: string
Abstractcreate Streaming Sound Async
-
createStreamingSoundAsync(
name: string,
source: string | string[] | HTMLMediaElement,
options?: Partial<IStreamingSoundOptions>,
): Promise<StreamingSound>Creates a new streaming sound.
Parameters
- name: string
The name of the sound.
- source: string | string[] | HTMLMediaElement
The source of the sound.
Optionaloptions: Partial<IStreamingSoundOptions>The options for the streaming sound.
Returns Promise<StreamingSound>
A promise that resolves to the created streaming sound.
- name: string
dispose
-
Releases associated resources.
Returns void
Abstractis Format Valid
-
Checks if the specified format is valid.
Parameters
- format: string
The format to check as an audio file extension like "mp3" or "wav".
Returns boolean
trueif the format is valid; otherwisefalse. - format: string
Abstractpause Async
-
Pauses the audio engine if it is running.
Returns Promise<void>
A promise that resolves when the audio engine is paused.
Abstractresume Async
-
Resumes the audio engine if it is not running.
Returns Promise<void>
A promise that resolves when the audio engine is running.
Abstractset Volume
-
Sets the audio output volume with optional ramping. If the duration is 0 then the volume is set immediately, otherwise it is ramped to the new value over the given duration using the given shape. If a ramp is already in progress then the volume is not set and an error is thrown.
Parameters
- value: number
The value to set the volume to.
Optionaloptions: Partial<IAudioParameterRampOptions>The options to use for ramping the volume change.
Returns void
- value: number
unlock Async
-
Unlocks the audio engine if it is locked.
- Note that the returned promise may already be resolved if the audio engine is already unlocked.
Returns Promise<void>
A promise that is resolved when the audio engine is unlocked.
Abstract base class for v2 audio engines.
A v2 audio engine based on the WebAudio API can be created with the CreateAudioEngineAsync function.