SoundEffect Class
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Provides a loaded sound resource. You can play multiple instances of the SoundEffect by calling Play.
Inheritance Hierarchy
System.Object
Microsoft.Xna.Framework.Audio.SoundEffect
Namespace: Microsoft.Xna.Framework.Audio
Assembly: Microsoft.Xna.Framework (in Microsoft.Xna.Framework.dll)
Syntax
'Declaration
Public NotInheritable Class SoundEffect
public sealed class SoundEffect
The SoundEffect type exposes the following members.
Constructors
Name | Description | |
---|---|---|
SoundEffect(array<Byte[], Int32, AudioChannels) | Initializes a new instance of SoundEffect based on an audio buffer, sample rate, and number of audio channels. | |
SoundEffect(array<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. |
Top
Properties
Name | Description | |
---|---|---|
Duration | Gets the length of time of the SoundEffect. | |
IsDisposed | Gets a value that indicates whether the object is disposed. | |
MasterVolume | Gets or sets the master volume that affects all SoundEffectInstance sounds. |
Top
Methods
Name | Description | |
---|---|---|
CreateInstance | Creates a new SoundEffectInstance for this SoundEffect. | |
Dispose | Releases the resources used by the SoundEffect. | |
FromStream | Creates a SoundEffect object based on the specified data stream. | |
GetSampleDuration | Returns the sample duration based on the specified sample size and sample rate. | |
GetSampleSizeInBytes | Returns the size of the audio sample based on duration, sample rate, and audio channels. | |
Play() | Plays a sound. | |
Play(Single, Single, Single) | Plays a sound based on specified volume, pitch, and panning. |
Top
Version Information
Silverlight
Supported in: 5
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.