Skip to content

API Class AudioSource

github-actions[bot] edited this page Dec 2, 2026 · 6 revisions

Class: AudioSource

Defined in: src/plugins/audio/runtime/AudioSource.ts:62

Plays a clip from its node. With spatial on it sounds from the node's position, panning and fading with distance from the World's AudioListener (ADR 0074).

Extends

Implements

  • AwakeWaiter

Constructors

Constructor

new AudioSource(): AudioSource;

Returns

AudioSource

Inherited from

Component.constructor

Properties

ambisonicYaw

ambisonicYaw: number = 0;

Defined in: src/plugins/audio/runtime/AudioSource.ts:93


clip

clip: string = "";

Defined in: src/plugins/audio/runtime/AudioSource.ts:68

What to play: a clip (an audio file) or a playlist (*.playlist.json, ADR 0343). For a playlist, loop and spatial come from the asset and minDistance/maxDistance stretch its attenuation; volume and pitch still apply on top. An old audio event file (*.audioevent.json) is refused with a message naming the migration.


dopplerLevel

dopplerLevel: number = 1;

Defined in: src/plugins/audio/runtime/AudioSource.ts:90


loop

loop: boolean = false;

Defined in: src/plugins/audio/runtime/AudioSource.ts:70


maxDistance

maxDistance: number = 100;

Defined in: src/plugins/audio/runtime/AudioSource.ts:79

Spatial: the distance where the falloff stops, in metres.


minDistance

minDistance: number = 1;

Defined in: src/plugins/audio/runtime/AudioSource.ts:77

Spatial: full volume inside this distance, in metres.


occlusion

occlusion: boolean = true;

Defined in: src/plugins/audio/runtime/AudioSource.ts:89


output

output: string = "";

Defined in: src/plugins/audio/runtime/AudioSource.ts:84

The mixer bus this sound plays on (ADR 0097): a bus name from the project's Audio settings. Empty is Master.


pitch

pitch: number = 1;

Defined in: src/plugins/audio/runtime/AudioSource.ts:73

Playback speed and pitch: 1 is normal, 2 an octave up.


playOnAwake

playOnAwake: boolean = true;

Defined in: src/plugins/audio/runtime/AudioSource.ts:71


priority

priority: number = 128;

Defined in: src/plugins/audio/runtime/AudioSource.ts:86

0..255. Mostly decides who is stolen when a voice limit is hit.


reverbSend

reverbSend: number = 1;

Defined in: src/plugins/audio/runtime/AudioSource.ts:91


reverbSendCurve

reverbSendCurve: Curve;

Defined in: src/plugins/audio/runtime/AudioSource.ts:92


rolloff

rolloff: Rolloff = "inverse";

Defined in: src/plugins/audio/runtime/AudioSource.ts:81

Spatial: how volume falls between minDistance and maxDistance.


spatial

spatial: boolean = false;

Defined in: src/plugins/audio/runtime/AudioSource.ts:75

Sound from the node's position instead of flat. On the Babylon fallback, clips that stream play flat.


volume

volume: number = 1;

Defined in: src/plugins/audio/runtime/AudioSource.ts:69

Accessors

enabled

Get Signature

get enabled(): boolean;

Defined in: src/engine/core/Component.ts:63

Returns

boolean

Set Signature

set enabled(value): void;

Defined in: src/engine/core/Component.ts:67

Parameters
value

boolean

Returns

void

Inherited from

Component.enabled


gameObject

Get Signature

get gameObject(): GameObject;

Defined in: src/engine/core/Component.ts:43

Unity-style alias for node.

Returns

GameObject

Inherited from

Component.gameObject


isActiveAndEnabled

Get Signature

get isActiveAndEnabled(): boolean;

Defined in: src/engine/core/Component.ts:74

True when enabled, the node is active in the hierarchy, and the node is in a loaded world.

Returns

boolean

Inherited from

Component.isActiveAndEnabled


isPlaying

Get Signature

get isPlaying(): boolean;

Defined in: src/plugins/audio/runtime/AudioSource.ts:137

Returns

boolean


node

Get Signature

get node(): GameObject;

Defined in: src/engine/core/Component.ts:38

The node this component is on.

Returns

GameObject

Inherited from

Component.node


occlusionGain

Get Signature

get occlusionGain(): number;

Defined in: src/plugins/audio/runtime/AudioSource.ts:126

ADR 0162 §1.2 (occlusionGain: the field occlusion holds the switch): the playing sound's smoothed dry occlusion gain, 1 open (and while not playing).

Returns

number


owner

Get Signature

get owner(): GameObject;

Defined in: src/engine/core/Component.ts:51

The node this component acts for: the node itself when attached directly, or the parent node when this component lives on a component node (ADR 0009).

Returns

GameObject

Inherited from

Component.owner


panner

Get Signature

get panner(): AudioPanner | null;

Defined in: src/plugins/audio/runtime/AudioSource.ts:132

ADR 0162 §1.2: the panner the playing sound uses, or null when not playing (or on a backend without panners).

Returns

AudioPanner | null


time

Get Signature

get time(): Readonly<TimeState>;

Defined in: src/engine/core/Component.ts:99

This component's World's clock (ADR 0032): the same values as Time, but safe to read outside the World's frame too (after an await, say).

Returns

Readonly<TimeState>

Inherited from

Component.time


transform

Get Signature

get transform(): Transform;

Defined in: src/engine/core/Component.ts:57

The Transform of the node this component is on, if it has one.

Returns

Transform

Inherited from

Component.transform


velocity

Get Signature

get velocity(): Vector3;

Defined in: src/plugins/audio/runtime/AudioSource.ts:118

ADR 0162 §1.2: the source's velocity in world units per second (Doppler). Read-only: the Doppler pass's estimate (zero while not playing, or on a backend without it).

Returns

Vector3


world

Get Signature

get world(): WorldHandle;

Defined in: src/engine/core/Component.ts:88

A handle on this component's World (ADR 0132): the same one Engine.findWorld returns. Load a scene into it, pause, connect or destroy it: this.world.loadScene("scenes/level2.scene.json"). Throws for a World no Engine owns.

Returns

WorldHandle

Inherited from

Component.world

Methods

getParameter()

getParameter(name): string | number | undefined;

Defined in: src/plugins/audio/runtime/AudioSource.ts:212

One of the playing playlist's parameters (else a global one); undefined for a clip or when not playing.

Parameters

name

string

Returns

string | number | undefined


instantiate()

instantiate(prefabPath, options?): GameObject;

Defined in: src/engine/core/Component.ts:109

Instantiate a prefab in this component's World (ADR 0034), like GameObject.instantiate. Use it in code that may run after an await: by then the frame is over and the current World is the Engine's default one, which may not be this component's. A parent from another World throws.

Parameters

prefabPath

string

options?

InstantiateOptions = {}

Returns

GameObject

Inherited from

Component.instantiate


pause()

pause(): void;

Defined in: src/plugins/audio/runtime/AudioSource.ts:192

Returns

void


play()

play(): void;

Defined in: src/plugins/audio/runtime/AudioSource.ts:142

Returns

void


release()

release(): void;

Defined in: src/plugins/audio/runtime/AudioSource.ts:220

Key-off: the playing playlist's held loops, or a looping sample's held loop (ADR 0342, its sidecar's first loop), end by their exit settings. Does nothing for a clip without a held loop.

Returns

void


resume()

resume(): void;

Defined in: src/plugins/audio/runtime/AudioSource.ts:199

Returns

void


setParameter()

setParameter(name, value): void;

Defined in: src/plugins/audio/runtime/AudioSource.ts:207

Set one of the playing playlist's own parameters. Does nothing for a clip.

Parameters

name

string

value

string | number

Returns

void


stop()

stop(): void;

Defined in: src/plugins/audio/runtime/AudioSource.ts:238

Returns

void

Clone this wiki locally