# Audio Manager

Gamepangin has provided a system for your in-game audio needs easily. The following are the features provided:

* Play / Stop / Pause / Resume
* Play clip with full settings : loop, volume, pitch, pan, spatial blend, bypasses, priority, reverb, doppler level, spread, rolloff mode, distance
* 2D & 3D spatial support
* Provided Audio Mixer and Track (Master, Sfx, Music, UI)
* Stop / Pause / Resume all tracks
* Stop / Pause / Resume all audio
* Mute / Set volume each tracks
* Integrated with Object Pooling for maximum performance
* Integrated with Save Load for persistence settings
* and more...

### Audio Clip Settings

Before you can play audio, you must create an AudioClipSettings scriptable object by right clicking on the Project Window > Create > Gamepangin > Audio > Clip

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4z5bYhjCwt02AHS4praa%2Fuploads%2FqC39qf1I21Z39z9AsA1Q%2Fimage.png?alt=media&#x26;token=95d83710-47c0-41e2-b84f-7d2796cbb505" alt=""><figcaption><p>AudioClipSettings Inspector</p></figcaption></figure>

### Audio Manager Singleton

Before calling the API, make sure you have Audio Manager in your scene. To make it you can use the Gamepangin menu > Audio > Audio Manager

### Public API

#### Play Sound

```csharp
// Play sound via unique id
AudioManager.Instance.PlaySound(string id)

// Play sound via AudioClipSettings reference
AudioManager.Instance.PlaySound(AudioClipSettings clip)
```

#### Pause Sound

```csharp
AudioManager.Instance.PauseSound(string id)
```

#### Resume Sound

```csharp
AudioManager.Instance.ResumeSound(string id)
```

#### Stop Sound

```csharp
AudioManager.Instance.StopSound(string id)
```

#### Mute Track

```csharp
AudioManager.Instance.MuteTrack(AudioManagerTracks track)
```

#### Unmute Track

```csharp
AudioManager.Instance.UnmuteTrack(AudioManagerTracks track)
```

#### Pause Track

```csharp
AudioManager.Instance.PauseTrack(AudioManagerTracks track)
```

#### Play Track

```csharp
AudioManager.Instance.PlayTrack(AudioManagerTracks track)
```

#### Stop Track

```csharp
AudioManager.Instance.StopTrack(AudioManagerTracks track)
```

#### Set Track Volume

```csharp
AudioManager.Instance.SetTrackVolume(AudioManagerTracks track, float volume)
```

#### Pause All Sounds

```csharp
AudioManager.Instance.PauseAllSounds()
```

#### Play All Sounds

```csharp
AudioManager.Instance.PlayAllSounds()
```

#### Stop All Sounds

```csharp
AudioManager.Instance.StopAllSounds()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://utoolkit.gamepangin.com/systems/audio-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
