Table of Contents

Class SoundEffectInstance

Namespace
Microsoft.Xna.Framework.Audio
Assembly
MonoGame.Framework.dll

Represents a single instance of a playing, paused, or stopped sound.

public class SoundEffectInstance : IDisposable
Inheritance
SoundEffectInstance
Implements
Derived
Inherited Members

Remarks

SoundEffectInstances are created through SoundEffect.CreateInstance() and used internally by SoundEffect.Play()

Properties

IsDisposed

Indicates whether the object is disposed.

public bool IsDisposed { get; }

Property Value

bool

IsLooped

Enables or Disables whether the SoundEffectInstance should repeat after playback.

public virtual bool IsLooped { get; set; }

Property Value

bool

Remarks

This value has no effect on an already playing sound.

Pan

Gets or sets the pan, or speaker balance..

public float Pan { get; set; }

Property Value

float

Pan value ranging from -1.0 (left speaker) to 0.0 (centered), 1.0 (right speaker). Values outside of this range will throw an exception.

Pitch

Gets or sets the pitch adjustment.

public float Pitch { get; set; }

Property Value

float

Pitch adjustment, ranging from -1.0 (down an octave) to 0.0 (no change) to 1.0 (up an octave). Values outside of this range will throw an Exception.

State

Gets the SoundEffectInstance's current playback state.

public virtual SoundState State { get; }

Property Value

SoundState

Volume

Gets or sets the volume of the SoundEffectInstance.

public float Volume { get; set; }

Property Value

float

Volume, ranging from 0.0 (silence) to 1.0 (full volume). Volume during playback is scaled by SoundEffect.MasterVolume.

Remarks

This is the volume relative to SoundEffect.MasterVolume. Before playback, this Volume property is multiplied by SoundEffect.MasterVolume when determining the final mix volume.

Methods

Apply3D(AudioListener, AudioEmitter)

Applies 3D positioning to the SoundEffectInstance using a single listener.

public void Apply3D(AudioListener listener, AudioEmitter emitter)

Parameters

listener AudioListener

Data about the listener.

emitter AudioEmitter

Data about the source of emission.

Apply3D(AudioListener[], AudioEmitter)

Applies 3D positioning to the SoundEffectInstance using multiple listeners.

public void Apply3D(AudioListener[] listeners, AudioEmitter emitter)

Parameters

listeners AudioListener[]

Data about each listener.

emitter AudioEmitter

Data about the source of emission.

Dispose()

Releases the resources held by this SoundEffectInstance.

public void Dispose()

Dispose(bool)

Releases the resources held by this SoundEffectInstance.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

If set to true, Dispose was called explicitly.

Remarks

If the disposing parameter is true, the Dispose method was called explicitly. This means that managed objects referenced by this instance should be disposed or released as required. If the disposing parameter is false, Dispose was called by the finalizer and no managed objects should be touched because we do not know if they are still valid or not at that time. Unmanaged resources should always be released.

~SoundEffectInstance()

Releases unmanaged resources and performs other cleanup operations before the SoundEffectInstance is reclaimed by garbage collection.

protected ~SoundEffectInstance()

Pause()

Pauses playback of a SoundEffectInstance.

public virtual void Pause()

Remarks

Paused instances can be resumed with SoundEffectInstance.Play() or SoundEffectInstance.Resume().

Play()

Plays or resumes a SoundEffectInstance.

public virtual void Play()

Remarks

Throws an exception if more sounds are playing than the platform allows.

Resume()

Resumes playback for a SoundEffectInstance.

public virtual void Resume()

Remarks

Only has effect on a SoundEffectInstance in a paused state.

Stop()

Immediately stops playing a SoundEffectInstance.

public virtual void Stop()

Stop(bool)

Stops playing a SoundEffectInstance, either immediately or as authored.

public virtual void Stop(bool immediate)

Parameters

immediate bool

Determined whether the sound stops immediately, or after playing its release phase and/or transitions.

Remarks

Stopping a sound with the immediate argument set to false will allow it to play any release phases, such as fade, before coming to a stop.