Engines/FlatRedBallXNA/FlatRedBall/Audio/AudioManager.cs
/// <summary>
/// Plays the argument sound effect.
/// </summary>
/// <param name="soundEffect">The sound effect to play</param>
/// <param name="volume">Volume, ranging from 0.0f (silence) to 1.0f (full volume). 1.0f is full volume</param>
/// <param name="pitch">Pitch, ranging from -1.0f (one octave down) to 1.0f (one octave up). 0.0f means no change </param>
/// <param name="pan">Volume, ranging from -1.0f (full left) to 1.0f (full right). 0.0f is centered </param>
Plays the argument sound effect.
Plays the argument sound effect .
public static void Play(SoundEffect soundEffect, float volume, float pitch = 0, float pan = 0)
        {
#if DEBUG && !MONOGAME
            if (soundEffect.IsDisposed)
            {
                throw new ArgumentException("Argument SoundEffect is disposed");
            }
#endif
            if (AreSoundEffectsEnabled)
            {
                bool shouldPlay = SoundEffectPlayingBehavior == Audio.SoundEffectPlayingBehavior.PlayAlways ||
                    mSoundsPlayedThisFrame.Contains(soundEffect.Name) == false;
                if (shouldPlay)
                {
#if MONODROID
                    _lastPlay = DateTime.Now;
#endif
#if ANDROID && !DEBUG
					try
					{
						if (volume < 1 || pitch != 0.0f || pan != 0.0f)
					    {
						    soundEffect.Play(volume, pitch, pan);
					    }
						else
						{
							soundEffect.Play();
						}
					}
					catch
					{
					}
#else
                    if (volume < 1 || pitch != 0.0f || pan != 0.0f)
					{
						soundEffect.Play(volume, pitch, pan);
					}
					else
					{
						soundEffect.Play();
					}
					#endif
#if DEBUG
                    NumberOfSoundEffectPlays++;
#endif
                    if (SoundEffectPlayingBehavior == Audio.SoundEffectPlayingBehavior.OncePerFrame)
                    {
                        mSoundsPlayedThisFrame.Add(soundEffect.Name);
                    }
                    SoundEffectPlayInfo sepi = new SoundEffectPlayInfo();
                    sepi.LastPlayTime = TimeManager.CurrentTime;
                    sepi.SoundEffect = soundEffect;
                    mSoundEffectPlayInfos.Add(sepi);
                }
            }
        }
public static void Play ( SoundEffect soundEffect , float volume , float pitch = 0 , float pan = 0 ) { if DEBUG && ! MONOGAME if ( soundEffect . IsDisposed ) { throw new ArgumentException ( " " ) ; } endif if ( AreSoundEffectsEnabled ) { bool shouldPlay = SoundEffectPlayingBehavior == Audio . SoundEffectPlayingBehavior . PlayAlways || mSoundsPlayedThisFrame . Contains ( soundEffect . Name ) == false ; if ( shouldPlay ) { if MONODROID _lastPlay = DateTime . Now ; endif if ANDROID && ! DEBUG try { if ( volume < 1 || pitch != 0.0f || pan != 0.0f ) { soundEffect . Play ( volume , pitch , pan ) ; } else { soundEffect . Play ( ) ; } } catch { } else if ( volume < 1 || pitch != 0.0f || pan != 0.0f ) { soundEffect . Play ( volume , pitch , pan ) ; } else { soundEffect . Play ( ) ; } endif if DEBUG NumberOfSoundEffectPlays ++ ; endif if ( SoundEffectPlayingBehavior == Audio . SoundEffectPlayingBehavior . OncePerFrame ) { mSoundsPlayedThisFrame . Add ( soundEffect . Name ) ; } SoundEffectPlayInfo sepi = new SoundEffectPlayInfo ( ) ; sepi . LastPlayTime = TimeManager . CurrentTime ; sepi . SoundEffect = soundEffect ; mSoundEffectPlayInfos . Add ( sepi ) ; } } }
Plays the argument sound effect.
Plays the argument sound effect .
// Sept 28, 2015 // Monogame 3.4 (and probably 3.5) does not support  // playing Sounds on ARM 64 devices. It crashes. We will // catch it in release in case someone releases a FRB game // and doesn't test it on these devices - better to be quiet // than to crash. In debug it will crash like normal (see below)
soundEffect
SoundEffect
The sound effect to play
The sound effect to play
volume
float
Volume, ranging from 0.0f (silence) to 1.0f (full volume). 1.0f is full volume
Volume ranging from 0 . 0f ( silence ) to 1 . 0f ( full volume ) . 1 . 0f is full volume
pitch
float
Pitch, ranging from -1.0f (one octave down) to 1.0f (one octave up). 0.0f means no change
Pitch ranging from - 1 . 0f ( one octave down ) to 1 . 0f ( one octave up ) . 0 . 0f means no change
pan
float
Volume, ranging from -1.0f (full left) to 1.0f (full right). 0.0f is centered
Volume ranging from - 1 . 0f ( full left ) to 1 . 0f ( full right ) . 0 . 0f is centered