SoundEffect Class

Provides a loaded sound resource. You can play multiple instances of the SoundEffect by calling Play.

Namespace: Microsoft.Xna.Framework.Audio
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)


public sealed class SoundEffect : IDisposable


A SoundEffect contains the audio data and metadata (such as wave data and loop information) loaded from a sound file. You can create multiple SoundEffectInstance objects, and play them from a single SoundEffect. These objects share the resources of that SoundEffect.

You can create a SoundEffect by calling ContentManager.Load. When you make that call, use the type SoundEffect and the asset name of an audio file. The audio file must be part of the Content project. Be sure to use the SoundEffect - XNA Framework content processor.

The only limit to the number of loaded SoundEffect objects is memory. A loaded SoundEffect will continue to hold its memory resources throughout its lifetime. All SoundEffectInstance objects created from a SoundEffect share memory resources. When a SoundEffect object is destroyed, all SoundEffectInstance objects previously created by that SoundEffect will stop playing and become invalid.

See Also


Playing a Sound
Looping a Sound
Adjusting Pitch and Volume
Applying a 3D Positional Effect to a Sound


SoundEffectInstance Class
ContentManager.Load Generic Method
SoundEffect Members
Microsoft.Xna.Framework.Audio Namespace


Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone