Microsoft.Xna.Framework.Audio.SoundEffectInstance

Introduction

The SoundEffectInstance is a copy of a SoundEffect which can be played on its own. Each SoundEffectInstance can only be played once at a time. Therefore if two sounds must overlap, then two SoundEffectInstances are needed. By contrast, calling SoundEffect.Play multiple times will result in overlapping sounds.

Although the SoundEffectInstance requires multiple instances for simultaneous plays, it provides the number of benefits:

  • It can be stopped at any time
  • It provides parameters for modifying how the sound effect is played (such as pitch)
  • It can be stopped prior to switching screens, which prevents sounds from spilling over to the next screen. This is also important for Windows RT apps as outlined in the SoundEffect page.

For information on using SoundEffectInstances in Glue, see the Glue SoundEffectInstance page.

For a more detail on the SoundEffectInstance class, see Microsoft XNA’s SoundEffectInstance reference.

SoundEffectInstance errors on iOS

If you are running the iOS simulator on a Mac then you may experience an error at runtime. A work-around for this error has not yet been discovered but it is occurs in MonoGame and not FlatRedBall. More information on the issue can be found here:

http://community.monogame.net/t/error-while-playing-soundeffect/1605.