You'll likely have one `AudioManager` with multiple `AudioContext` objects. For example if your game has multiple levels (practice range, online, campaign), you might want a separate `AudioContext` for each.
So the first step is to create a new class that inherits from `AudioContext`:
```cs
public class ExampleAudioContext : AudioContext
{
public ExampleAudioContext(AudioManager manager) : base("example", manager)
{
}
}
```
Then add a new function called `PlaySound`:
```cs
void PlaySound()
{
bool is3D = false;
if (manager.TryCreateSource((int)SoundType.Respawn, is3D, out var source)
{
source.Play();
}
else
{
// Sound still loading :(
}
}
```
This will create a new OpenAL source that uses the audio data from the `Respawn` sound, and then play it.
> Since sounds [load on background threads](<Loading Sounds.md>), they might not be ready to play yet. `TryCreateSource` may also fail if you've reached the maximum amount of sounds, or if you've set [custom throttling limits](<Sound Throttling.md>).
The `is3D` parameter controls whether the sound will be spatialised or not. For example a UI sound like a mouse hover or click sound won't spatialised, but a gunshot will be.
Before you play the sound, you can also set parameters on the [[Source]]:
```cs
source.SetGain(1.0f); // 100% volume
source.SetPitch(1.0f) // Default pitch
```
The [[RaytracedAudioContext]] has helper functions for playing 3D sounds, which perform the raytracing first before calling `source.Play()`. This stops the case where the sound is briefly 100% clear, then becomes muffled when the raytracing completes.
Now we're ready to start [[Raytracing]].