Ara
Download

Search or run a command

Jump to a section or open an Ara link.

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

string
Mixer bus name resolved by the presentation bridge.
default "master"

gain

f32
Linear source amplitude.
default 10 – 16

pitch

f32
Playback pitch multiplier before Doppler.
default 10.125 – 8

looping

bool
Whether the clip repeats.
default false

spatial

bool
Whether position affects the sound.
default true

priority

u8
Voice budget priority; larger values are retained first.
default 128

referenceDistance

f32
Full-volume radius.
default 1m0.01 – 100000

maxDistance

f32
Silent beyond this distance; must exceed referenceDistance.
default 100m0.02 – 1000000

attenuation

Attenuation
Shape of the distance attenuation curve.
default "inverse"

One ofinverselinearinverseSquare

position

vec3
Source position, supplied from the ECS world transform by the bridge.
default [0,0,0]m

velocity

vec3
Source velocity in meters per second for Doppler.
default [0,0,0]

forward

vec3
Source forward axis; normalized during spatial evaluation.
default [0,0,-1]

coneInner

f32
Full angle of the unattenuated source cone.
default 360deg0 – 360

coneOuter

f32
Full angle at which the source reaches coneOuterGain.
default 360deg0 – 360

coneOuterGain

f32
Linear 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.