using Microsoft.Xna.Framework.Audio;
using MLEM.Extensions;
namespace MLEM.Sound {
///
/// A sound effect info is a wrapper around that additionally stores , and information.
/// Additionally, a can be created using .
///
public class SoundEffectInfo {
///
/// The that is played by this info.
///
public readonly SoundEffect Sound;
///
/// Volume, ranging from 0.0 (silence) to 1.0 (full volume). Volume during playback is scaled by SoundEffect.MasterVolume.
///
public float Volume;
///
/// Pitch adjustment, ranging from -1.0 (down an octave) to 0.0 (no change) to 1.0 (up an octave).
///
public float Pitch;
///
/// Pan value ranging from -1.0 (left speaker) to 0.0 (centered), 1.0 (right speaker).
///
public float Pan;
///
/// Creates a new sound effect info with the given values.
///
/// The sound to play
/// The volume to play the sound with
/// The pitch to play the sound with
/// The pan to play the sound with
public SoundEffectInfo(SoundEffect sound, float volume = 1, float pitch = 0, float pan = 0) {
this.Sound = sound;
this.Volume = volume;
this.Pitch = pitch;
this.Pan = pan;
}
///
/// Plays this info's once.
///
/// False if more sounds are currently playing than the platform allows
public bool Play() {
return this.Sound.Play(this.Volume, this.Pitch, this.Pan);
}
///
/// Creates a new with this sound effect info's data.
///
/// The value to set the returned instance's to. Defaults to false.
/// A new sound effect instance, with this info's data applied
public SoundEffectInstance CreateInstance(bool isLooped = false) {
return this.Sound.CreateInstance(this.Volume, this.Pitch, this.Pan, isLooped);
}
}
}