Skip to main content

Interface: AudioPort

Defined in: packages/webxr-environment/src/ports.ts:95

Plays sounds.

The core owns voice ids, gain resolution and policy; a port owns decoding, routing and the actual noise.

Methods​

dispose()?​

optional dispose(): void;

Defined in: packages/webxr-environment/src/ports.ts:124

Release anything the port created. Optional.

Returns​

void


load()?​

optional load(cue: AudioCue): void | Promise<unknown>;

Defined in: packages/webxr-environment/src/ports.ts:102

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​

void | Promise<unknown>


setGain()?​

optional setGain(voiceId: number, gain: number): void;

Defined in: packages/webxr-environment/src/ports.ts:112

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


start()​

start(request: AudioVoiceRequest): void;

Defined in: packages/webxr-environment/src/ports.ts:104

Begin a voice. See AudioVoiceRequest.ended for the retirement contract.

Parameters​

ParameterType
requestAudioVoiceRequest

Returns​

void


stop()​

stop(voiceId: number): void;

Defined in: packages/webxr-environment/src/ports.ts:106

Stop a voice early. Called at most once per voice, never after ended.

Parameters​

ParameterType
voiceIdnumber

Returns​

void


update()?​

optional update(deltaMs: number): void;

Defined in: packages/webxr-environment/src/ports.ts:122

Called from AudioDirector.update, before the director's own sweep.

This exists for a port whose engine reports playback state but not playback END - IWSDK is one - so that it can poll and call ended. Without it those ports would have to degrade to fire-and-forget and restart / ignore would behave differently per engine, which is precisely the kind of divergence this stack exists to remove.

Parameters​

ParameterType
deltaMsnumber

Returns​

void