Skip to main content

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

ParameterType
listenerAudioListener
optionsThreeAudioPortOptions

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

AudioPort.dispose


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

ParameterType
cueAudioCue

Returns

Promise<AudioBuffer | null>

Implementation of

AudioPort.load


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

ParameterType
voiceIdnumber
gainnumber

Returns

void

Implementation of

AudioPort.setGain


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

ParameterType
requestAudioVoiceRequest

Returns

void

Implementation of

AudioPort.start


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

ParameterType
voiceIdnumber

Returns

void

Implementation of

AudioPort.stop