diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 60a30d7d..7b51dfed 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -231,6 +231,8 @@ namespace Vocaluxe.Base public static int BackgroundMusicVolume = 50; public static EOffOn BackgroundMusic = EOffOn.TR_CONFIG_ON; public static EBackgroundMusicSource BackgroundMusicSource = EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC; + public static int PreviewMusicVolume = 20; + public static int GameMusicVolume = 100; // Game public static List SongFolder = new List(); @@ -358,7 +360,21 @@ namespace Vocaluxe.Base CHelper.TryGetEnumValueFromXML("//root/Sound/BackgroundMusic", navigator, ref BackgroundMusic); CHelper.TryGetIntValueFromXML("//root/Sound/BackgroundMusicVolume", navigator, ref BackgroundMusicVolume); + if (BackgroundMusicVolume < 0) + BackgroundMusicVolume = 0; + if (BackgroundMusicVolume > 100) + BackgroundMusicVolume = 100; CHelper.TryGetEnumValueFromXML("//root/Sound/BackgroundMusicSource", navigator, ref BackgroundMusicSource); + CHelper.TryGetIntValueFromXML("//root/Sound/PreviewMusicVolume", navigator, ref PreviewMusicVolume); + if (PreviewMusicVolume < 0) + PreviewMusicVolume = 0; + if (PreviewMusicVolume > 100) + PreviewMusicVolume = 100; + CHelper.TryGetIntValueFromXML("//root/Sound/GameMusicVolume", navigator, ref GameMusicVolume); + if (GameMusicVolume < 0) + GameMusicVolume = 0; + if (GameMusicVolume > 100) + GameMusicVolume = 100; #endregion Sound #region Game @@ -585,6 +601,12 @@ namespace Vocaluxe.Base writer.WriteComment("Background Music Source"); writer.WriteElementString("BackgroundMusicSource", Enum.GetName(typeof(EBackgroundMusicSource), BackgroundMusicSource)); + writer.WriteComment("Preview Volume from 0 to 100"); + writer.WriteElementString("PreviewMusicVolume", PreviewMusicVolume.ToString()); + + writer.WriteComment("Game Volume from 0 to 100"); + writer.WriteElementString("GameMusicVolume", GameMusicVolume.ToString()); + writer.WriteEndElement(); #endregion Sound diff --git a/Vocaluxe/Menu/CMenu.cs b/Vocaluxe/Menu/CMenu.cs index fd4aed88..4d96610d 100644 --- a/Vocaluxe/Menu/CMenu.cs +++ b/Vocaluxe/Menu/CMenu.cs @@ -912,6 +912,24 @@ namespace Vocaluxe.Menu if (KeyEvent.Key == Keys.Right) NextElement(); } + if (!CBackgroundMusic.Disabled) + { + if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Add || KeyEvent.Key == Keys.PageUp)) + { + CConfig.BackgroundMusicVolume = CConfig.BackgroundMusicVolume + 5; + if (CConfig.BackgroundMusicVolume > 100) + CConfig.BackgroundMusicVolume = 100; + CConfig.SaveConfig(); + } + else if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown)) + { + CConfig.BackgroundMusicVolume = CConfig.BackgroundMusicVolume - 5; + if (CConfig.BackgroundMusicVolume < 0) + CConfig.BackgroundMusicVolume = 0; + CConfig.SaveConfig(); + } + CBackgroundMusic.ApplyVolume(); + } return true; } diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs index 045ec139..1c87fe4f 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs @@ -598,6 +598,11 @@ namespace Vocaluxe.Menu.SongMenu CSongs.Category = -1; } + public void ApplyVolume() + { + CSound.SetStreamVolume(_actsongstream, CConfig.PreviewMusicVolume); + } + protected void SelectSong(int nr) { if (CSongs.Category >= 0 && (CSongs.NumVisibleSongs > 0) && (nr >= 0) && ((_actsong != nr) || (_streams.Count == 0))) @@ -628,7 +633,7 @@ namespace Vocaluxe.Menu.SongMenu CSound.SetPosition(_stream, startposition); CSound.Play(_stream); - CSound.Fade(_stream, 100f, 3f); + CSound.Fade(_stream, CConfig.PreviewMusicVolume, 3f); _streams.Add(_stream); _actsongstream = _stream; diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index c75081c3..cca73a51 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -227,6 +227,30 @@ namespace Vocaluxe.Screens TogglePause(); } break; + + case Keys.Add: + case Keys.PageUp: + if (KeyEvent.ModSHIFT) + { + CConfig.GameMusicVolume = CConfig.GameMusicVolume + 5; + if (CConfig.GameMusicVolume > 100) + CConfig.GameMusicVolume = 100; + CConfig.SaveConfig(); + CSound.SetStreamVolume(_CurrentStream, CConfig.GameMusicVolume); + } + break; + + case Keys.Subtract: + case Keys.PageDown: + if (KeyEvent.ModSHIFT) + { + CConfig.GameMusicVolume = CConfig.GameMusicVolume - 5; + if (CConfig.GameMusicVolume < 0) + CConfig.GameMusicVolume = 0; + CConfig.SaveConfig(); + CSound.SetStreamVolume(_CurrentStream, CConfig.GameMusicVolume); + } + break; } } diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 9a0b0e71..a4008cea 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -311,6 +311,21 @@ namespace Vocaluxe.Screens } } + if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Add || KeyEvent.Key == Keys.PageUp)) + { + CConfig.PreviewMusicVolume = CConfig.PreviewMusicVolume + 5; + if (CConfig.PreviewMusicVolume > 100) + CConfig.PreviewMusicVolume = 100; + CConfig.SaveConfig(); + } + else if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown)) + { + CConfig.PreviewMusicVolume = CConfig.PreviewMusicVolume - 5; + if (CConfig.PreviewMusicVolume < 0) + CConfig.PreviewMusicVolume = 0; + CConfig.SaveConfig(); + } + return true; }