mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-05-17 06:35:30 +00:00
Removed NAudio
This commit is contained in:
parent
1396702d9d
commit
84fea654a5
38 changed files with 51 additions and 50 deletions
AutoTrackR2
AutoTrackR2.csprojKillStreakManager.cs
sounds
double_kill.mp3double_kill.wavhells_janitor.mp3hells_janitor.wavinvincible.mp3invincible.wavkillimanjaro.mp3killimanjaro.wavkilling_frenzy.mp3killing_frenzy.wavkilling_spree.mp3killing_spree.wavkillionaire.mp3killionaire.wavkillpocalypse.mp3killpocalypse.wavkilltacular.mp3killtacular.wavkilltastrophe.mp3killtastrophe.wavkilltrocity.mp3killtrocity.wavoverkill.mp3overkill.wavperfection.mp3perfection.wavrampage.mp3rampage.wavrunning_riot.mp3running_riot.wavtriple_kill.mp3triple_kill.wavunstoppable.mp3unstoppable.wavuntouchable.mp3untouchable.wav
|
@ -43,13 +43,9 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="sounds\*.mp3">
|
<None Include="sounds\*.wav">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="NAudio" Version="2.2.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System.Media;
|
using System.Media;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using NAudio.Wave;
|
|
||||||
|
|
||||||
namespace AutoTrackR2;
|
namespace AutoTrackR2;
|
||||||
|
|
||||||
|
@ -13,7 +12,7 @@ public class KillStreakManager : IDisposable
|
||||||
private int _totalKills = 0;
|
private int _totalKills = 0;
|
||||||
private readonly string _soundsPath;
|
private readonly string _soundsPath;
|
||||||
private readonly object _lock = new();
|
private readonly object _lock = new();
|
||||||
private WaveOutEvent? _waveOut;
|
private SoundPlayer? _currentPlayer;
|
||||||
private bool _isPlaying = false;
|
private bool _isPlaying = false;
|
||||||
private bool _disposed = false;
|
private bool _disposed = false;
|
||||||
private Task? _currentPlaybackTask;
|
private Task? _currentPlaybackTask;
|
||||||
|
@ -39,30 +38,30 @@ public class KillStreakManager : IDisposable
|
||||||
// Handle multi-kill announcements
|
// Handle multi-kill announcements
|
||||||
string? multiKillSound = _currentKills switch
|
string? multiKillSound = _currentKills switch
|
||||||
{
|
{
|
||||||
2 => "double_kill.mp3",
|
2 => "double_kill.wav",
|
||||||
3 => "triple_kill.mp3",
|
3 => "triple_kill.wav",
|
||||||
4 => "overkill.mp3",
|
4 => "overkill.wav",
|
||||||
5 => "killtacular.mp3",
|
5 => "killtacular.wav",
|
||||||
6 => "killtrocity.mp3",
|
6 => "killtrocity.wav",
|
||||||
7 => "killimanjaro.mp3",
|
7 => "killimanjaro.wav",
|
||||||
8 => "killtastrophe.mp3",
|
8 => "killtastrophe.wav",
|
||||||
9 => "killpocalypse.mp3",
|
9 => "killpocalypse.wav",
|
||||||
10 => "killionaire.mp3",
|
10 => "killionaire.wav",
|
||||||
_ => null
|
_ => null
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle spree announcements
|
// Handle spree announcements
|
||||||
string? spreeSound = _totalKills switch
|
string? spreeSound = _totalKills switch
|
||||||
{
|
{
|
||||||
5 => "killing_spree.mp3",
|
5 => "killing_spree.wav",
|
||||||
10 => "killing_frenzy.mp3",
|
10 => "killing_frenzy.wav",
|
||||||
15 => "running_riot.mp3",
|
15 => "running_riot.wav",
|
||||||
20 => "rampage.mp3",
|
20 => "rampage.wav",
|
||||||
25 => "untouchable.mp3",
|
25 => "untouchable.wav",
|
||||||
30 => "invincible.mp3",
|
30 => "invincible.wav",
|
||||||
35 => "unstoppable.mp3",
|
35 => "unstoppable.wav",
|
||||||
40 => "hells_janitor.mp3",
|
40 => "hells_janitor.wav",
|
||||||
45 => "perfection.mp3",
|
45 => "perfection.wav",
|
||||||
_ => null
|
_ => null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,45 +145,51 @@ public class KillStreakManager : IDisposable
|
||||||
// Stop any currently playing sound
|
// Stop any currently playing sound
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
_waveOut?.Stop();
|
_currentPlayer?.Stop();
|
||||||
_waveOut?.Dispose();
|
_currentPlayer?.Dispose();
|
||||||
_waveOut = null;
|
_currentPlayer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new WaveOutEvent
|
// Create a new SoundPlayer
|
||||||
var waveOut = new WaveOutEvent();
|
var player = new SoundPlayer(soundPath);
|
||||||
|
player.LoadCompleted += (sender, e) =>
|
||||||
// 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) =>
|
|
||||||
{
|
{
|
||||||
lock (_lock)
|
if (e.Error != null)
|
||||||
{
|
{
|
||||||
if (_disposed) return;
|
Console.WriteLine($"Error loading sound {soundPath}: {e.Error.Message}");
|
||||||
|
lock (_lock)
|
||||||
_isPlaying = false;
|
|
||||||
if (_soundQueue.Count > 0)
|
|
||||||
{
|
{
|
||||||
_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)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
if (_disposed)
|
if (_disposed)
|
||||||
{
|
{
|
||||||
waveOut.Dispose();
|
player.Dispose();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_waveOut = waveOut;
|
_currentPlayer = player;
|
||||||
|
_isPlaying = false;
|
||||||
|
if (_soundQueue.Count > 0)
|
||||||
|
{
|
||||||
|
_currentPlaybackTask = Task.Run(() => PlayNextSound());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
waveOut.Play();
|
|
||||||
|
|
||||||
Console.WriteLine($"Successfully played sound: {soundPath}");
|
Console.WriteLine($"Successfully played sound: {soundPath}");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -218,9 +223,9 @@ public class KillStreakManager : IDisposable
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
_killStreakTimer.Stop();
|
_killStreakTimer.Stop();
|
||||||
_killStreakTimer.Dispose();
|
_killStreakTimer.Dispose();
|
||||||
_waveOut?.Stop();
|
_currentPlayer?.Stop();
|
||||||
_waveOut?.Dispose();
|
_currentPlayer?.Dispose();
|
||||||
_waveOut = null;
|
_currentPlayer = null;
|
||||||
_currentPlaybackTask?.Wait();
|
_currentPlaybackTask?.Wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
BIN
AutoTrackR2/sounds/double_kill.wav
Normal file
BIN
AutoTrackR2/sounds/double_kill.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/hells_janitor.wav
Normal file
BIN
AutoTrackR2/sounds/hells_janitor.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/invincible.wav
Normal file
BIN
AutoTrackR2/sounds/invincible.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/killimanjaro.wav
Normal file
BIN
AutoTrackR2/sounds/killimanjaro.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/killing_frenzy.wav
Normal file
BIN
AutoTrackR2/sounds/killing_frenzy.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/killing_spree.wav
Normal file
BIN
AutoTrackR2/sounds/killing_spree.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/killionaire.wav
Normal file
BIN
AutoTrackR2/sounds/killionaire.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/killpocalypse.wav
Normal file
BIN
AutoTrackR2/sounds/killpocalypse.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/killtacular.wav
Normal file
BIN
AutoTrackR2/sounds/killtacular.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/killtastrophe.wav
Normal file
BIN
AutoTrackR2/sounds/killtastrophe.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/killtrocity.wav
Normal file
BIN
AutoTrackR2/sounds/killtrocity.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/overkill.wav
Normal file
BIN
AutoTrackR2/sounds/overkill.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/perfection.wav
Normal file
BIN
AutoTrackR2/sounds/perfection.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/rampage.wav
Normal file
BIN
AutoTrackR2/sounds/rampage.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/running_riot.wav
Normal file
BIN
AutoTrackR2/sounds/running_riot.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/triple_kill.wav
Normal file
BIN
AutoTrackR2/sounds/triple_kill.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/unstoppable.wav
Normal file
BIN
AutoTrackR2/sounds/unstoppable.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
AutoTrackR2/sounds/untouchable.wav
Normal file
BIN
AutoTrackR2/sounds/untouchable.wav
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue