Component · audio
AudioSource
Declarative sound intent. Playback cursors and decoder state are presentation only.
Fields
clip
option<asset<audio>>Cooked clip reference in
@path#id form; absent means no clip.default null
bus
stringMixer bus name resolved by the presentation bridge.
default "master"
gain
f32Linear source amplitude.
default 10 – 16
pitch
f32Playback pitch multiplier before Doppler.
default 10.125 – 8
looping
boolWhether the clip repeats.
default false
spatial
boolWhether position affects the sound.
default true
priority
u8Voice budget priority; larger values are retained first.
default 128
referenceDistance
f32Full-volume radius.
default 1m0.01 – 100000
maxDistance
f32Silent beyond this distance; must exceed referenceDistance.
default 100m0.02 – 1000000
attenuation
AttenuationShape of the distance attenuation curve.
default "inverse"
One ofinverselinearinverseSquare
position
vec3Source position, supplied from the ECS world transform by the bridge.
default [0,0,0]m
velocity
vec3Source velocity in meters per second for Doppler.
default [0,0,0]
forward
vec3Source forward axis; normalized during spatial evaluation.
default [0,0,-1]
coneInner
f32Full angle of the unattenuated source cone.
default 360deg0 – 360
coneOuter
f32Full angle at which the source reaches coneOuterGain.
default 360deg0 – 360
coneOuterGain
f32Linear amplitude outside the source cone.
default 10 – 1
Usage
Every edit is an undoable command: from the CLI as below, or the same JSON from an agent over MCP. See component.add and property.set.
Add it
ara do component.add -p entity=name:Crate -p component=AudioSource --why "Add AudioSource"Set a field
ara do property.set -p entity=name:Crate -p path=AudioSource.clip -p value=null --why "Tune AudioSource"In a scene document
{
"AudioSource": {
"clip": null
}
}From C#
/// <summary>Play an alarm through an AudioSource; the presentation layer adopts the clip.</summary>
public static void UseAudioSource(Entity entity, in Tick tick)
{
ref var component = ref World.Get<AudioSource>(entity);
component.Clip = "@audio/alarm.wav#as_alarm";
component.Gain = 0.4f;
}From C#
Scripts read and write it with Get<AudioSource>(); see the AudioSource struct.