# SoundEffect

### Introduction

The SoundEffect class represents a sound effect that can be played at any time. The FlatRedBall Editor supports the automatic creation of SoundEffect objects by adding a WAV file to a Screen, Entity, or Global Content. For reference on the SoundEffect object, see the [MonoGame SoundEffect page](https://docs.monogame.net/api/Microsoft.Xna.Framework.Audio.SoundEffect.html). For more information on using SoundEffect through the FlatRedBall Editor, see [the tutorial page on playing sounds](/flatredball/tutorials/glue-tutorials/glue-how-to-play-sounds.md).

### Code Example

The following example assumes that you have "mySound.wav" added to your content project. If not using Glue, you will need to pass the .WAV file through the MonoGame content pipeline. Glue will automatically process .WAV files added to Screens, Entities, and Global Content Files.

```csharp
// SoundEffects load through the content pipeline, so there is no extension
SoundEffect soundEffect = FlatRedBallServices.Load<SoundEffect>(@"Content\mySound");
// to play the sound, just call Play:
soundEffect.Play();
```

You can adjust parameters on the Play call as shown in the following code snippet:

```csharp
SoundEffectFile.Play(volume: 1, pitch: 0, pan: 0);
```


---

# 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://docs.flatredball.com/flatredball/api/microsoft-xna-framework/audio/soundeffect.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.
