Share via


SoundEffect Class

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

Syntax

'Declaration
Public NotInheritable Class SoundEffect
         Implements IDisposable
public sealed class SoundEffect : IDisposable
public ref class SoundEffect sealed : IDisposable

Remarks

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.

Requirements

Namespace: Microsoft.Xna.Framework.Audio

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

See Also

Tasks

Playing a Sound
Looping a Sound
Adjusting Pitch and Volume

Reference

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

Platforms

Windows Phone