/// <summary> /// Stops playing sound /// </summary> /// <param name="immediate"></param> public void StopSound ( bool immediate ) { if (soundInstance!=null) { soundInstance.Stop( immediate ); soundInstance = null; } }
/// <summary> /// Starts playing sound /// </summary> /// <param name="soundEffect"></param> /// <param name="options"></param> /// <param name="volume"></param> /// <param name="pitch"></param> public void PlaySound ( SoundEffect soundEffect, PlayOptions options = PlayOptions.None ) { soundInstance = soundEffect.CreateInstance(); soundInstance.IsLooped = options.HasFlag(PlayOptions.Looped); soundInstance.Play(); }
/// <summary> /// /// </summary> /// <returns></returns> internal SoundEffectInstance CreateInstance() { SourceVoice voice = null; if (device.Device != null) { voice = new SourceVoice(device.Device, _format, VoiceFlags.UseFilter, XAudio2.MaximumFrequencyRatio); } var instance = new SoundEffectInstance(device, this, voice); return instance; }