From 88364ce64bb4631bc04a9cf24e8320810738bf7c Mon Sep 17 00:00:00 2001 From: Flamefire Date: Fri, 14 Mar 2014 00:27:42 +0100 Subject: [PATCH] Fix PlaySound (Length not gotten if prescan off) Add fade option to PlaySound --- Vocaluxe/Base/CSound.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Vocaluxe/Base/CSound.cs b/Vocaluxe/Base/CSound.cs index f849afe7..7dfe5840 100644 --- a/Vocaluxe/Base/CSound.cs +++ b/Vocaluxe/Base/CSound.cs @@ -181,7 +181,7 @@ namespace Vocaluxe.Base #endregion Playback #region Sounds - public static int PlaySound(ESounds sound) + public static int PlaySound(ESounds sound, bool fade = true) { string file = Path.Combine(Environment.CurrentDirectory, CSettings.FolderSounds); switch (sound) @@ -189,15 +189,18 @@ namespace Vocaluxe.Base case ESounds.T440: file = Path.Combine(file, CSettings.SoundT440); break; + default: + return -1; } - if (file == "") + if (!File.Exists(file)) return -1; - int stream = Load(file); + int stream = Load(file, true); float length = GetLength(stream); Play(stream); - FadeAndClose(stream, 100f, length); + if (fade) + FadeAndClose(stream, 100f, length); return stream; } #endregion Sounds