diff --git a/AutoTrackR2/AutoTrackR2.csproj b/AutoTrackR2/AutoTrackR2.csproj index ac8984c..8ead1aa 100644 --- a/AutoTrackR2/AutoTrackR2.csproj +++ b/AutoTrackR2/AutoTrackR2.csproj @@ -43,13 +43,9 @@ </ItemGroup> <ItemGroup> - <None Include="sounds\*.mp3"> + <None Include="sounds\*.wav"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None> </ItemGroup> - <ItemGroup> - <PackageReference Include="NAudio" Version="2.2.1" /> - </ItemGroup> - </Project> diff --git a/AutoTrackR2/KillStreakManager.cs b/AutoTrackR2/KillStreakManager.cs index d85e6ce..1c8bc8a 100644 --- a/AutoTrackR2/KillStreakManager.cs +++ b/AutoTrackR2/KillStreakManager.cs @@ -1,7 +1,6 @@ using System.Media; using System.Timers; using System.IO; -using NAudio.Wave; namespace AutoTrackR2; @@ -13,7 +12,7 @@ public class KillStreakManager : IDisposable private int _totalKills = 0; private readonly string _soundsPath; private readonly object _lock = new(); - private WaveOutEvent? _waveOut; + private SoundPlayer? _currentPlayer; private bool _isPlaying = false; private bool _disposed = false; private Task? _currentPlaybackTask; @@ -39,30 +38,30 @@ public class KillStreakManager : IDisposable // Handle multi-kill announcements string? multiKillSound = _currentKills switch { - 2 => "double_kill.mp3", - 3 => "triple_kill.mp3", - 4 => "overkill.mp3", - 5 => "killtacular.mp3", - 6 => "killtrocity.mp3", - 7 => "killimanjaro.mp3", - 8 => "killtastrophe.mp3", - 9 => "killpocalypse.mp3", - 10 => "killionaire.mp3", + 2 => "double_kill.wav", + 3 => "triple_kill.wav", + 4 => "overkill.wav", + 5 => "killtacular.wav", + 6 => "killtrocity.wav", + 7 => "killimanjaro.wav", + 8 => "killtastrophe.wav", + 9 => "killpocalypse.wav", + 10 => "killionaire.wav", _ => null }; // Handle spree announcements string? spreeSound = _totalKills switch { - 5 => "killing_spree.mp3", - 10 => "killing_frenzy.mp3", - 15 => "running_riot.mp3", - 20 => "rampage.mp3", - 25 => "untouchable.mp3", - 30 => "invincible.mp3", - 35 => "unstoppable.mp3", - 40 => "hells_janitor.mp3", - 45 => "perfection.mp3", + 5 => "killing_spree.wav", + 10 => "killing_frenzy.wav", + 15 => "running_riot.wav", + 20 => "rampage.wav", + 25 => "untouchable.wav", + 30 => "invincible.wav", + 35 => "unstoppable.wav", + 40 => "hells_janitor.wav", + 45 => "perfection.wav", _ => null }; @@ -146,45 +145,51 @@ public class KillStreakManager : IDisposable // Stop any currently playing sound lock (_lock) { - _waveOut?.Stop(); - _waveOut?.Dispose(); - _waveOut = null; + _currentPlayer?.Stop(); + _currentPlayer?.Dispose(); + _currentPlayer = null; } - // Create a new WaveOutEvent - var waveOut = new WaveOutEvent(); - - // Create a new AudioFileReader for the MP3 file - using var audioFile = new AudioFileReader(soundPath); - waveOut.Init(audioFile); - - // Set up event handler for when playback finishes - waveOut.PlaybackStopped += (sender, e) => + // Create a new SoundPlayer + var player = new SoundPlayer(soundPath); + player.LoadCompleted += (sender, e) => { - lock (_lock) + if (e.Error != null) { - if (_disposed) return; - - _isPlaying = false; - if (_soundQueue.Count > 0) + Console.WriteLine($"Error loading sound {soundPath}: {e.Error.Message}"); + lock (_lock) { - _currentPlaybackTask = Task.Run(() => PlayNextSound()); + _isPlaying = false; + if (_soundQueue.Count > 0) + { + _currentPlaybackTask = Task.Run(() => PlayNextSound()); + } } } }; + player.SoundLocationChanged += (sender, e) => + { + Console.WriteLine($"Sound location changed: {soundPath}"); + }; + + player.PlaySync(); + lock (_lock) { if (_disposed) { - waveOut.Dispose(); + player.Dispose(); return; } - _waveOut = waveOut; + _currentPlayer = player; + _isPlaying = false; + if (_soundQueue.Count > 0) + { + _currentPlaybackTask = Task.Run(() => PlayNextSound()); + } } - waveOut.Play(); - Console.WriteLine($"Successfully played sound: {soundPath}"); } catch (Exception ex) @@ -218,9 +223,9 @@ public class KillStreakManager : IDisposable _disposed = true; _killStreakTimer.Stop(); _killStreakTimer.Dispose(); - _waveOut?.Stop(); - _waveOut?.Dispose(); - _waveOut = null; + _currentPlayer?.Stop(); + _currentPlayer?.Dispose(); + _currentPlayer = null; _currentPlaybackTask?.Wait(); } } diff --git a/AutoTrackR2/sounds/double_kill.mp3 b/AutoTrackR2/sounds/double_kill.mp3 deleted file mode 100644 index bf4a0c3..0000000 Binary files a/AutoTrackR2/sounds/double_kill.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/double_kill.wav b/AutoTrackR2/sounds/double_kill.wav new file mode 100644 index 0000000..4137c3a Binary files /dev/null and b/AutoTrackR2/sounds/double_kill.wav differ diff --git a/AutoTrackR2/sounds/hells_janitor.mp3 b/AutoTrackR2/sounds/hells_janitor.mp3 deleted file mode 100644 index 30d0c04..0000000 Binary files a/AutoTrackR2/sounds/hells_janitor.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/hells_janitor.wav b/AutoTrackR2/sounds/hells_janitor.wav new file mode 100644 index 0000000..3609a4c Binary files /dev/null and b/AutoTrackR2/sounds/hells_janitor.wav differ diff --git a/AutoTrackR2/sounds/invincible.mp3 b/AutoTrackR2/sounds/invincible.mp3 deleted file mode 100644 index 7acbf3e..0000000 Binary files a/AutoTrackR2/sounds/invincible.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/invincible.wav b/AutoTrackR2/sounds/invincible.wav new file mode 100644 index 0000000..3055968 Binary files /dev/null and b/AutoTrackR2/sounds/invincible.wav differ diff --git a/AutoTrackR2/sounds/killimanjaro.mp3 b/AutoTrackR2/sounds/killimanjaro.mp3 deleted file mode 100644 index edbb2a6..0000000 Binary files a/AutoTrackR2/sounds/killimanjaro.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/killimanjaro.wav b/AutoTrackR2/sounds/killimanjaro.wav new file mode 100644 index 0000000..a56e117 Binary files /dev/null and b/AutoTrackR2/sounds/killimanjaro.wav differ diff --git a/AutoTrackR2/sounds/killing_frenzy.mp3 b/AutoTrackR2/sounds/killing_frenzy.mp3 deleted file mode 100644 index 6d64adf..0000000 Binary files a/AutoTrackR2/sounds/killing_frenzy.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/killing_frenzy.wav b/AutoTrackR2/sounds/killing_frenzy.wav new file mode 100644 index 0000000..37ff587 Binary files /dev/null and b/AutoTrackR2/sounds/killing_frenzy.wav differ diff --git a/AutoTrackR2/sounds/killing_spree.mp3 b/AutoTrackR2/sounds/killing_spree.mp3 deleted file mode 100644 index 5f2504a..0000000 Binary files a/AutoTrackR2/sounds/killing_spree.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/killing_spree.wav b/AutoTrackR2/sounds/killing_spree.wav new file mode 100644 index 0000000..e871fcb Binary files /dev/null and b/AutoTrackR2/sounds/killing_spree.wav differ diff --git a/AutoTrackR2/sounds/killionaire.mp3 b/AutoTrackR2/sounds/killionaire.mp3 deleted file mode 100644 index 0224b43..0000000 Binary files a/AutoTrackR2/sounds/killionaire.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/killionaire.wav b/AutoTrackR2/sounds/killionaire.wav new file mode 100644 index 0000000..6068885 Binary files /dev/null and b/AutoTrackR2/sounds/killionaire.wav differ diff --git a/AutoTrackR2/sounds/killpocalypse.mp3 b/AutoTrackR2/sounds/killpocalypse.mp3 deleted file mode 100644 index c1ce534..0000000 Binary files a/AutoTrackR2/sounds/killpocalypse.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/killpocalypse.wav b/AutoTrackR2/sounds/killpocalypse.wav new file mode 100644 index 0000000..8212e65 Binary files /dev/null and b/AutoTrackR2/sounds/killpocalypse.wav differ diff --git a/AutoTrackR2/sounds/killtacular.mp3 b/AutoTrackR2/sounds/killtacular.mp3 deleted file mode 100644 index b0cc69a..0000000 Binary files a/AutoTrackR2/sounds/killtacular.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/killtacular.wav b/AutoTrackR2/sounds/killtacular.wav new file mode 100644 index 0000000..13c4cf7 Binary files /dev/null and b/AutoTrackR2/sounds/killtacular.wav differ diff --git a/AutoTrackR2/sounds/killtastrophe.mp3 b/AutoTrackR2/sounds/killtastrophe.mp3 deleted file mode 100644 index e4267cb..0000000 Binary files a/AutoTrackR2/sounds/killtastrophe.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/killtastrophe.wav b/AutoTrackR2/sounds/killtastrophe.wav new file mode 100644 index 0000000..ec386ed Binary files /dev/null and b/AutoTrackR2/sounds/killtastrophe.wav differ diff --git a/AutoTrackR2/sounds/killtrocity.mp3 b/AutoTrackR2/sounds/killtrocity.mp3 deleted file mode 100644 index 5bd5f33..0000000 Binary files a/AutoTrackR2/sounds/killtrocity.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/killtrocity.wav b/AutoTrackR2/sounds/killtrocity.wav new file mode 100644 index 0000000..c1dc1c8 Binary files /dev/null and b/AutoTrackR2/sounds/killtrocity.wav differ diff --git a/AutoTrackR2/sounds/overkill.mp3 b/AutoTrackR2/sounds/overkill.mp3 deleted file mode 100644 index 83fb2bb..0000000 Binary files a/AutoTrackR2/sounds/overkill.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/overkill.wav b/AutoTrackR2/sounds/overkill.wav new file mode 100644 index 0000000..cfb190c Binary files /dev/null and b/AutoTrackR2/sounds/overkill.wav differ diff --git a/AutoTrackR2/sounds/perfection.mp3 b/AutoTrackR2/sounds/perfection.mp3 deleted file mode 100644 index c0b7f74..0000000 Binary files a/AutoTrackR2/sounds/perfection.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/perfection.wav b/AutoTrackR2/sounds/perfection.wav new file mode 100644 index 0000000..b3fb954 Binary files /dev/null and b/AutoTrackR2/sounds/perfection.wav differ diff --git a/AutoTrackR2/sounds/rampage.mp3 b/AutoTrackR2/sounds/rampage.mp3 deleted file mode 100644 index 37d9bc9..0000000 Binary files a/AutoTrackR2/sounds/rampage.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/rampage.wav b/AutoTrackR2/sounds/rampage.wav new file mode 100644 index 0000000..095642f Binary files /dev/null and b/AutoTrackR2/sounds/rampage.wav differ diff --git a/AutoTrackR2/sounds/running_riot.mp3 b/AutoTrackR2/sounds/running_riot.mp3 deleted file mode 100644 index 5eec17b..0000000 Binary files a/AutoTrackR2/sounds/running_riot.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/running_riot.wav b/AutoTrackR2/sounds/running_riot.wav new file mode 100644 index 0000000..1ab92ba Binary files /dev/null and b/AutoTrackR2/sounds/running_riot.wav differ diff --git a/AutoTrackR2/sounds/triple_kill.mp3 b/AutoTrackR2/sounds/triple_kill.mp3 deleted file mode 100644 index b489151..0000000 Binary files a/AutoTrackR2/sounds/triple_kill.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/triple_kill.wav b/AutoTrackR2/sounds/triple_kill.wav new file mode 100644 index 0000000..6146140 Binary files /dev/null and b/AutoTrackR2/sounds/triple_kill.wav differ diff --git a/AutoTrackR2/sounds/unstoppable.mp3 b/AutoTrackR2/sounds/unstoppable.mp3 deleted file mode 100644 index 7c8a342..0000000 Binary files a/AutoTrackR2/sounds/unstoppable.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/unstoppable.wav b/AutoTrackR2/sounds/unstoppable.wav new file mode 100644 index 0000000..1294f4d Binary files /dev/null and b/AutoTrackR2/sounds/unstoppable.wav differ diff --git a/AutoTrackR2/sounds/untouchable.mp3 b/AutoTrackR2/sounds/untouchable.mp3 deleted file mode 100644 index 4763213..0000000 Binary files a/AutoTrackR2/sounds/untouchable.mp3 and /dev/null differ diff --git a/AutoTrackR2/sounds/untouchable.wav b/AutoTrackR2/sounds/untouchable.wav new file mode 100644 index 0000000..42d7b7a Binary files /dev/null and b/AutoTrackR2/sounds/untouchable.wav differ