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)
You can inspect if a SoundEffectInstance is playing
For information on using SoundEffectInstances in the FlatRedBall Editor, see the FlatRedBall Editor's SoundEffectInstance page. For a more detail on the SoundEffectInstance class, see MonoGame's SoundEffectInstance reference.
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.
The SoundEffect class represents a sound effect that can be played at any time. The FlatRedBall Editor supports the automatic creation of SoundEffect objects by adding a WAV file to a Screen, Entity, or Global Content. For reference on the SoundEffect object, see the MonoGame SoundEffect page. For more information on using SoundEffect through the FlatRedBall Editor, see the tutorial page on playing sounds.
The following example assumes that you have "mySound.wav" added to your content project. If not using Glue, you will need to pass the .WAV file through the MonoGame content pipeline. Glue will automatically process .WAV files added to Screens, Entities, and Global Content Files.
You can adjust parameters on the Play call as shown in the following code snippet: