Class SoundEffectInfo
A sound effect info is a wrapper around Microsoft.Xna.Framework.Audio.SoundEffect that additionally stores Volume, Pitch and Pan information. Additionally, a RandomPitchModifier can be applied, a Microsoft.Xna.Framework.Audio.SoundEffectInstance can be created using CreateInstance(bool), and more.
public class SoundEffectInfo
- Inheritance
-
SoundEffectInfo
- Inherited Members
- Extension Methods
Constructors
SoundEffectInfo(SoundEffect, float, float, float)
Creates a new sound effect info with the given values.
public SoundEffectInfo(SoundEffect sound, float volume = 1, float pitch = 0, float pan = 0)
Parameters
sound
SoundEffectThe sound to play
volume
floatThe volume to play the sound with
pitch
floatThe pitch to play the sound with
pan
floatThe pan to play the sound with
Fields
Pan
Pan value ranging from -1.0 (left speaker) to 0.0 (centered), 1.0 (right speaker).
public float Pan
Field Value
Pitch
Pitch adjustment, ranging from -1.0 (down an octave) to 0.0 (no change) to 1.0 (up an octave). To incorporate RandomPitchModifier, you can use GetRandomPitch().
public float Pitch
Field Value
RandomPitchModifier
A value that allows randomly modifying Pitch every time Play() or CreateInstance(bool) are used. The random modifier that is added onto Pitch will be between -RandomPitchModifier and RandomPitchModifier.
public float RandomPitchModifier
Field Value
Sound
The Microsoft.Xna.Framework.Audio.SoundEffect that is played by this info.
public readonly SoundEffect Sound
Field Value
- SoundEffect
Volume
Volume, ranging from 0.0 (silence) to 1.0 (full volume). Volume during playback is scaled by SoundEffect.MasterVolume.
public float Volume
Field Value
Methods
CreateInstance(bool)
Creates a new Microsoft.Xna.Framework.Audio.SoundEffectInstance with this sound effect info's data.
public SoundEffectInstance CreateInstance(bool isLooped = false)
Parameters
isLooped
boolThe value to set the returned instance's Microsoft.Xna.Framework.Audio.SoundEffectInstance.IsLooped to. Defaults to false.
Returns
- SoundEffectInstance
A new sound effect instance, with this info's data applied
GetRandomPitch()
Returns a random pitch for this sound effect info that is between Pitch - RandomPitchModifier and Pitch + RandomPitchModifier. If RandomPitchModifier is 0, this method always returns Pitch.
public float GetRandomPitch()
Returns
- float
A random pitch to use to play this sound effect
Play()
Plays this info's Sound once.
public bool Play()
Returns
- bool
False if more sounds are currently playing than the platform allows