diff --git a/Output/Sounds/ApplauseHigh.mp3 b/Output/Sounds/ApplauseHigh.mp3 new file mode 100644 index 00000000..feef5379 Binary files /dev/null and b/Output/Sounds/ApplauseHigh.mp3 differ diff --git a/Output/Sounds/ApplauseLow.mp3 b/Output/Sounds/ApplauseLow.mp3 new file mode 100644 index 00000000..b5a2ec9a Binary files /dev/null and b/Output/Sounds/ApplauseLow.mp3 differ diff --git a/Output/Sounds/ApplauseMid.mp3 b/Output/Sounds/ApplauseMid.mp3 new file mode 100644 index 00000000..0b40903a Binary files /dev/null and b/Output/Sounds/ApplauseMid.mp3 differ diff --git a/Output/Sounds/Highscore.mp3 b/Output/Sounds/Highscore.mp3 new file mode 100644 index 00000000..20991525 Binary files /dev/null and b/Output/Sounds/Highscore.mp3 differ diff --git a/Output/Sounds/Pixabay Content License Summary.url b/Output/Sounds/Pixabay Content License Summary.url new file mode 100644 index 00000000..ca0ecbfc --- /dev/null +++ b/Output/Sounds/Pixabay Content License Summary.url @@ -0,0 +1,5 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,11 +[InternetShortcut] +IDList= +URL=https://www.pixabay.com/service/license-summary/ diff --git a/Output/Sounds/Pixabay Terms Of Service.url b/Output/Sounds/Pixabay Terms Of Service.url new file mode 100644 index 00000000..76751ad9 --- /dev/null +++ b/Output/Sounds/Pixabay Terms Of Service.url @@ -0,0 +1,5 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,11 +[InternetShortcut] +IDList= +URL=https://www.pixabay.com/service/terms/ diff --git a/Output/Sounds/_readme.txt b/Output/Sounds/_readme.txt new file mode 100644 index 00000000..4037afd9 --- /dev/null +++ b/Output/Sounds/_readme.txt @@ -0,0 +1,12 @@ +----- +APPLAUSE SOUNDS +HIGHSCORE SOUND +----- +for free without attribution (check pixabay content license) +enjoy + + +https://pixabay.com/de/sound-effects/small-applause-6695/ +https://pixabay.com/de/sound-effects/short-crowd-cheer-6713/ +https://pixabay.com/de/sound-effects/cheering-and-clapping-crowd-1-5995/ +https://pixabay.com/de/sound-effects/achive-sound-132273/ diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index cc9ea6dd..e222f071 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -120,6 +120,10 @@ namespace Vocaluxe.Base public const string FileNameRequiredSkinElements = "RequiredSkinElements.xml"; public const string FileNameSoundT440 = "440Hz.mp3"; + public const string FileNameSoundApplauseLow = "ApplauseLow.mp3"; + public const string FileNameSoundApplauseMid = "ApplauseMid.mp3"; + public const string FileNameSoundApplauseHigh = "ApplauseHigh.mp3"; + public const string FileNameSoundHighscore = "Highscore.mp3"; public const string FolderNameSongs = "Songs"; public const string FolderNameProfiles = "Profiles"; diff --git a/Vocaluxe/Base/CSound.cs b/Vocaluxe/Base/CSound.cs index 5acbd7c9..de503060 100644 --- a/Vocaluxe/Base/CSound.cs +++ b/Vocaluxe/Base/CSound.cs @@ -28,7 +28,11 @@ namespace Vocaluxe.Base { enum ESounds { - T440 + T440, + ApplauseLow, + ApplauseMid, + ApplauseHigh, + Highscore } static class CSound @@ -186,6 +190,18 @@ namespace Vocaluxe.Base case ESounds.T440: file = Path.Combine(file, CSettings.FileNameSoundT440); break; + case ESounds.ApplauseLow: + file = Path.Combine(file, CSettings.FileNameSoundApplauseLow); + break; + case ESounds.ApplauseMid: + file = Path.Combine(file, CSettings.FileNameSoundApplauseMid); + break; + case ESounds.ApplauseHigh: + file = Path.Combine(file, CSettings.FileNameSoundApplauseHigh); + break; + case ESounds.Highscore: + file = Path.Combine(file, CSettings.FileNameSoundHighscore); + break; default: return -1; } @@ -217,4 +233,4 @@ namespace Vocaluxe.Base } #endregion Sounds } -} \ No newline at end of file +} diff --git a/Vocaluxe/Screens/CScreenHighscore.cs b/Vocaluxe/Screens/CScreenHighscore.cs index 19769991..1ff08446 100644 --- a/Vocaluxe/Screens/CScreenHighscore.cs +++ b/Vocaluxe/Screens/CScreenHighscore.cs @@ -1,4 +1,4 @@ -#region license +#region license // This file is part of Vocaluxe. // // Vocaluxe is free software: you can redistribute it and/or modify @@ -24,6 +24,7 @@ using VocaluxeLib; using VocaluxeLib.Game; using VocaluxeLib.Menu; using VocaluxeLib.Songs; +using Vocaluxe.Lib.Sound; namespace Vocaluxe.Screens { @@ -56,6 +57,17 @@ namespace Vocaluxe.Screens get { return EMusicType.BackgroundPreview; } } + private int _HighscoreStream = -1; + private bool _HasPlayedSound = false; + + private static int PlaySound(ESounds sound, int volume) + { + int streamId = CSound.PlaySound(sound, false); + CSound.SetStreamVolume(streamId, volume); + + return streamId; + } + public override void Init() { base.Init(); @@ -184,7 +196,13 @@ namespace Vocaluxe.Screens _Texts[_TextDate[p]].Text = _Scores[_Round][_Pos + p].Date; _ParticleEffects[_ParticleEffectNew[p]].Visible = _IsNewEntry(_Scores[_Round][_Pos + p].ID); - } + + if (_ParticleEffects[_ParticleEffectNew[p]].Visible && !_HasPlayedSound) + { + _HighscoreStream = CScreenHighscore.PlaySound(ESounds.Highscore, CConfig.GameMusicVolume); + _HasPlayedSound = true; + } + } else { _Texts[_TextNumber[p]].Visible = false; @@ -200,6 +218,7 @@ namespace Vocaluxe.Screens public override void OnShow() { base.OnShow(); + _HasPlayedSound = false; _Round = 0; _Pos = 0; _NewEntryIDs.Clear(); @@ -347,7 +366,13 @@ namespace Vocaluxe.Screens } private void _LeaveScreen() - { + { + if (_HighscoreStream != -1) + { + CSound.Close(_HighscoreStream); + _HighscoreStream = -1; + } + CParty.LeavingHighscore(); } } diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index c9b77e4d..a66d644d 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -1,4 +1,4 @@ -#region license +#region license // This file is part of Vocaluxe. // // Vocaluxe is free software: you can redistribute it and/or modify @@ -19,12 +19,15 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Windows.Forms; +using System.Linq; +using System.Threading.Tasks; using Vocaluxe.Base; using Vocaluxe.Base.Server; using VocaluxeLib; using VocaluxeLib.Game; using VocaluxeLib.Menu; using VocaluxeLib.Songs; +using Vocaluxe.Lib.Sound; namespace Vocaluxe.Screens { @@ -250,6 +253,33 @@ namespace Vocaluxe.Screens } } + private int _ApplauseStream = -1; + + private void _PlayApplauseSound(int maxPoints) + { + // Play the appropriate applause sound based on maxPoints + if (maxPoints >= 8000) + { + _ApplauseStream = PlaySound(ESounds.ApplauseHigh, CConfig.GameMusicVolume); + } + else if (maxPoints >= 5000) + { + _ApplauseStream = PlaySound(ESounds.ApplauseMid, CConfig.GameMusicVolume); + } + else if (maxPoints >= 2000) + { + _ApplauseStream = PlaySound(ESounds.ApplauseLow, CConfig.GameMusicVolume); + } + } + + private static int PlaySound(ESounds sound, int volume) + { + int streamId = CSound.PlaySound(sound, false); + CSound.SetStreamVolume(streamId, volume); + + return streamId; + } + private void _UpdateRatings() { CSong song = null; @@ -264,6 +294,9 @@ namespace Vocaluxe.Screens if (_Points.NumRounds > 1) _Texts[_TextSong].Text += " (" + (_Round + 1) + "/" + _Points.NumRounds + ")"; players = _Points.GetPlayer(_Round, CGame.NumPlayers); + + int maxPoints = (int)Math.Round(players.Max(player => player.Points)); + _PlayApplauseSound(maxPoints); } else { @@ -280,6 +313,9 @@ namespace Vocaluxe.Screens } for (int p = 0; p < players.Length; p++) players[p].Points = (int)Math.Round(players[p].Points / CGame.NumRounds); + + int maxPoints = (int)Math.Round(players.Max(player => player.Points)); + _PlayApplauseSound(maxPoints); } for (int p = 0; p < players.Length; p++) @@ -379,7 +415,13 @@ namespace Vocaluxe.Screens private void _LeaveScreen() { + if (_ApplauseStream != -1) + { + CSound.Close(_ApplauseStream); + _ApplauseStream = -1; + } + CParty.LeavingScore(); } } -} \ No newline at end of file +}