Class: ThreeAudioPort
Defined in: threejs-environment/src/audio-port.ts:60
Plays sounds.
The core owns voice ids, gain resolution and policy; a port owns decoding, routing and the actual noise.
Implements
Constructors
Constructor
new ThreeAudioPort(listener: AudioListener, options?: ThreeAudioPortOptions): ThreeAudioPort;
Defined in: threejs-environment/src/audio-port.ts:73
Parameters
| Parameter | Type |
|---|---|
listener | AudioListener |
options | ThreeAudioPortOptions |
Returns
ThreeAudioPort
Methods
dispose()
dispose(): void;
Defined in: threejs-environment/src/audio-port.ts:130
Release anything the port created. Optional.
Returns
void
Implementation of
load()
load(cue: AudioCue): Promise<AudioBuffer | null>;
Defined in: threejs-environment/src/audio-port.ts:91
Prepare a cue. Called once per registration, and may be asynchronous - the
director does not wait on it, because a cue that is still loading when it
is first played is the adapter's problem to smooth over (queue it, or drop
that one play), not a reason to make play async for everybody.
Parameters
| Parameter | Type |
|---|---|
cue | AudioCue |
Returns
Promise<AudioBuffer | null>
Implementation of
resume()
resume(): Promise<boolean>;
Defined in: threejs-environment/src/audio-port.ts:84
Resume the audio context. Call from a user gesture; safe to call twice. Resolves false when there is no context to resume.
Returns
Promise<boolean>
setGain()
setGain(voiceId: number, gain: number): void;
Defined in: threejs-environment/src/audio-port.ts:126
Change the gain of a sounding voice, because a bus or the master moved under it. Optional: a port without it simply does not follow live mix changes on voices that are already playing.
Parameters
| Parameter | Type |
|---|---|
voiceId | number |
gain | number |
Returns
void
Implementation of
start()
start(request: AudioVoiceRequest): void;
Defined in: threejs-environment/src/audio-port.ts:95
Begin a voice. See AudioVoiceRequest.ended for the retirement contract.
Parameters
| Parameter | Type |
|---|---|
request | AudioVoiceRequest |
Returns
void
Implementation of
stop()
stop(voiceId: number): void;
Defined in: threejs-environment/src/audio-port.ts:118
Stop a voice early. Called at most once per voice, never after ended.
Parameters
| Parameter | Type |
|---|---|
voiceId | number |
Returns
void