Repository navigation
API Class AudioSource
Defined in: src/plugins/audio/runtime/AudioSource.ts:55
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).
new AudioSource(): AudioSource;AudioSource
ambisonicYaw: number = 0;Defined in: src/plugins/audio/runtime/AudioSource.ts:86
clip: string = "";Defined in: src/plugins/audio/runtime/AudioSource.ts:61
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: number = 1;Defined in: src/plugins/audio/runtime/AudioSource.ts:83
loop: boolean = false;Defined in: src/plugins/audio/runtime/AudioSource.ts:63
maxDistance: number = 100;Defined in: src/plugins/audio/runtime/AudioSource.ts:72
Spatial: the distance where the falloff stops, in metres.
minDistance: number = 1;Defined in: src/plugins/audio/runtime/AudioSource.ts:70
Spatial: full volume inside this distance, in metres.
occlusion: boolean = true;Defined in: src/plugins/audio/runtime/AudioSource.ts:82
output: string = "";Defined in: src/plugins/audio/runtime/AudioSource.ts:77
The mixer bus this sound plays on (ADR 0097): a bus name from the project's Audio settings. Empty is Master.
pitch: number = 1;Defined in: src/plugins/audio/runtime/AudioSource.ts:66
Playback speed and pitch: 1 is normal, 2 an octave up.
playOnAwake: boolean = true;Defined in: src/plugins/audio/runtime/AudioSource.ts:64
priority: number = 128;Defined in: src/plugins/audio/runtime/AudioSource.ts:79
0..255. Mostly decides who is stolen when a voice limit is hit.
reverbSend: number = 1;Defined in: src/plugins/audio/runtime/AudioSource.ts:84
reverbSendCurve: Curve;Defined in: src/plugins/audio/runtime/AudioSource.ts:85
rolloff: Rolloff = "inverse";Defined in: src/plugins/audio/runtime/AudioSource.ts:74
Spatial: how volume falls between minDistance and maxDistance.
spatial: boolean = false;Defined in: src/plugins/audio/runtime/AudioSource.ts:68
Sound from the node's position instead of flat. On the Babylon fallback, clips that stream play flat.
volume: number = 1;Defined in: src/plugins/audio/runtime/AudioSource.ts:62
get enabled(): boolean;Defined in: src/engine/core/Component.ts:57
boolean
set enabled(value): void;Defined in: src/engine/core/Component.ts:61
boolean
void
get gameObject(): GameObject;Defined in: src/engine/core/Component.ts:37
Unity-style alias for node.
get isActiveAndEnabled(): boolean;Defined in: src/engine/core/Component.ts:68
True when enabled, the node is active in the hierarchy, and the node is in a loaded world.
boolean
get isPlaying(): boolean;Defined in: src/plugins/audio/runtime/AudioSource.ts:130
boolean
get node(): GameObject;Defined in: src/engine/core/Component.ts:32
The node this component is on.
get occlusionGain(): number;Defined in: src/plugins/audio/runtime/AudioSource.ts:119
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).
number
get owner(): GameObject;Defined in: src/engine/core/Component.ts:45
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).
get panner(): AudioPanner | null;Defined in: src/plugins/audio/runtime/AudioSource.ts:125
ADR 0162 §1.2: the panner the playing sound uses, or null when not playing (or on a backend without panners).
AudioPanner | null
get time(): Readonly<TimeState>;Defined in: src/engine/core/Component.ts:93
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).
Readonly<TimeState>
get transform(): Transform;Defined in: src/engine/core/Component.ts:51
The Transform of the node this component is on, if it has one.
get velocity(): Vector3;Defined in: src/plugins/audio/runtime/AudioSource.ts:111
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).
get world(): WorldHandle;Defined in: src/engine/core/Component.ts:82
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.
getParameter(name): string | number | undefined;Defined in: src/plugins/audio/runtime/AudioSource.ts:205
One of the playing playlist's parameters (else a global one); undefined for a clip or when not playing.
string
string | number | undefined
instantiate(prefabPath, options?): GameObject;Defined in: src/engine/core/Component.ts:103
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.
string
InstantiateOptions = {}
pause(): void;Defined in: src/plugins/audio/runtime/AudioSource.ts:185
void
play(): void;Defined in: src/plugins/audio/runtime/AudioSource.ts:135
void
release(): void;Defined in: src/plugins/audio/runtime/AudioSource.ts:213
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.
void
resume(): void;Defined in: src/plugins/audio/runtime/AudioSource.ts:192
void
setParameter(name, value): void;Defined in: src/plugins/audio/runtime/AudioSource.ts:200
Set one of the playing playlist's own parameters. Does nothing for a clip.
string
string | number
void
stop(): void;Defined in: src/plugins/audio/runtime/AudioSource.ts:231
void
This wiki is generated from docs/wiki/ and the myco module's source on every push to master. Change pages there in a pull request: edits made here are not kept.
Basics
Gameplay
Rendering
Audio
- Playing sound
- Why is there no sound?
- Playlists
- Interactive music
- Sound generators
- Spatial audio
- Audio mixer
- Live mixing
- Loudness
- Audio profiler
- Audio takes
Reference