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

The SoundEffect type exposes the following members.

Public methodSoundEffect(Byte[], Int32, AudioChannels)Initializes a new instance of SoundEffect based on an audio buffer, sample rate, and number of audio channels.
Public methodSoundEffect(Byte[], Int32, Int32, Int32, AudioChannels, Int32, Int32)Initializes a new instance of SoundEffect with specified parameters such as audio sample rate, channels, looping criteria, and a buffer to hold the audio.

Public propertyDurationGets the length of time of the SoundEffect.
Public propertyIsDisposedGets a value that indicates whether the object is disposed.
Public propertyStatic memberMasterVolumeGets or sets the master volume that affects all SoundEffectInstance sounds.

Public methodCreateInstanceCreates a new SoundEffectInstance for this SoundEffect.
Public methodDisposeReleases the resources used by the SoundEffect.
Public methodStatic memberFromStreamCreates a SoundEffect object based on the specified data stream.
Public methodStatic memberGetSampleDurationReturns the sample duration based on the specified sample size and sample rate.
Public methodStatic memberGetSampleSizeInBytesReturns the size of the audio sample based on duration, sample rate, and audio channels.
Public methodPlay()Plays a sound.
Public methodPlay(Single, Single, Single)Plays a sound based on specified volume, pitch, and panning.


Supported in: 5

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions