SoundEffect Class

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
Public method SoundEffect(array<Byte[], Int32, AudioChannels) Initializes a new instance of SoundEffect based on an audio buffer, sample rate, and number of audio channels.
Public method 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
Public property Duration Gets the length of time of the SoundEffect.
Public property IsDisposed Gets a value that indicates whether the object is disposed.
Public propertyStatic member MasterVolume Gets or sets the master volume that affects all SoundEffectInstance sounds.

Top

Methods

  Name Description
Public method CreateInstance Creates a new SoundEffectInstance for this SoundEffect.
Public method Dispose Releases the resources used by the SoundEffect.
Public methodStatic member FromStream Creates a SoundEffect object based on the specified data stream.
Public methodStatic member GetSampleDuration Returns the sample duration based on the specified sample size and sample rate.
Public methodStatic member GetSampleSizeInBytes Returns the size of the audio sample based on duration, sample rate, and audio channels.
Public method Play() Plays a sound.
Public method 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.