# Spatial sound

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

A spatial sound fades and pans with its distance to the listener. The listener is the first enabled, active [Audio Listener 2D](/ref/audio.AudioListener2D.md) in the hierarchy; another active one later in the hierarchy is ignored ([AUD005](/diagnostics.html#AUD005.md)). Without a listener the camera of the main output listens, and [AUD004](/diagnostics.html#AUD004.md) reminds you of it on spatial sources; without a camera, the origin.

`audio.ListenerPosition()` returns the last effective listener position, including the camera fallback, in world space during Play.

A spatial source plays at full volume up to **Min Distance** and is silent from **Max Distance**, both in world units. **Rolloff** is the curve of the volume between them: time 0 is Min Distance, time 1 is Max Distance. **Pan Width**, from 0 to 1, says how far a sound at Max Distance to the side is panned.

Every field is listed on the [Audio Source 2D](/ref/audio.AudioSource2D.md) page.

A keyed Rolloff curve is read as the volume; a preset ease is read as the volume falling away; the default curve drops to a quarter halfway. Pan is the distance to the side divided by Max Distance, times Pan Width.

A sound played from a node follows it; `audio.PlayAt` and `audio.PlayEventAt` stay where they started. Positions are read after the frame's movement, so the sound follows what is drawn.

In Try it, the ball carries the listener and the camera follows it. The box in the middle hums: it is loud and centred when the ball passes it, and fades to the side as the ball rolls away. Change Max Distance or Pan Width of the box in the Inspector and listen to the next pass.
