# Audio Source 2D

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

```
component audio.AudioSource2D
```

Plays a clip or an audio event from its node.

## Fields

| Name | Script name | Type | Default | Description |
|---|---|---|---|---|
| Clip | `Clip` | `Clip` | `none` | Sound to play; ignored when Event is set. |
| Event | `Event` | `AssetRef<data>` | `none` | Audio event to play instead of Clip; its settings replace the fields below. |
| Volume | `Volume` | `float` | `1` | Volume before the bus: 0 is silent, 1 is the clip as recorded. |
| Pitch | `Pitch` | `float` | `1` | Playback speed and pitch together: 1 is normal, 2 an octave higher and twice as fast. |
| Pan | `Pan` | `float` | `0` | Left -1 to right 1, for a sound that is not spatial. |
| Bus | `Bus` | `enum` | `sfx` | Mixer bus. |
| Loop | `Loop` | `bool` | `false` | Loops until stopped. |
| Play On Start | `PlayOnStart` | `bool` | `false` | Plays when Play starts. |
| Spatial | `Spatial` | `bool` | `false` | Fades and pans with the distance to the listener. |
| Min Distance | `MinDistance` | `float` | `1` | Full volume up to this distance, in world units. |
| Max Distance | `MaxDistance` | `float` | `10` | Silent from this distance, in world units. |
| Rolloff | `Rolloff` | `Curve` | `curve` | Volume from Min Distance (time 0) to Max Distance (time 1). |
| Pan Width | `PanWidth` | `float` | `0.8` | How far a spatial sound pans when it is at Max Distance to the side: 0 stays centred, 1 is fully left or right. |
| Pause With | `PauseWith` | `enum` | `game` | game pauses with the world, never keeps playing. |
| Playing | `Playing` | `bool` | `false` | Runtime state. True while a sound of this source plays. |
| Position | `Position` | `float` | `0` | Runtime state. Seconds into the sound. |

## IsPlaying

```
func (AudioSource2D) IsPlaying() bool
```

Reports whether the source plays a sound.

## Play

```
func (AudioSource2D) Play()
```

Starts the source from the beginning, stopping a sound it already plays.

## Stop

```
func (AudioSource2D) Stop()
```

Ends the sound of the source with a short fade.

## StopFade

```
func (AudioSource2D) StopFade(seconds float)
```

Fades the sound of the source out over seconds.

## Finished

```
signal Finished(finished bool)
```

Runs when the sound of the source ends; finished is false after Stop or when it was cut off.

## Started

```
signal Started()
```

Runs when the source starts a sound.
