forked from Mercury/2dxAutoClip
Cleanup
This commit is contained in:
parent
82bb8145ae
commit
e5db5216e6
|
@ -11,7 +11,7 @@ class Program
|
|||
private static readonly string WebsocketAddress = "localhost";
|
||||
private static readonly int WebsocketPort = 10573;
|
||||
private static Process? _ffmpegProcess;
|
||||
private static string _ffmpegFolderPath = GetFolderPath(); // Output folder path
|
||||
private static string _ffmpegFolderPath = GetFolderPath();
|
||||
private static WasapiCapture? _waveSource;
|
||||
private static WaveFileWriter _writer = null!;
|
||||
private static string _audioFilePath = null!;
|
||||
|
@ -139,8 +139,7 @@ private static async Task ConnectWebSocket()
|
|||
shouldCheckForMusicSelect = false;
|
||||
}
|
||||
else if (message.EndsWith("CLEAR!") || message.EndsWith("FAILED.."))
|
||||
{
|
||||
// Set the flag to check the next message for "MUSIC SELECT!!"
|
||||
{
|
||||
shouldCheckForMusicSelect = true;
|
||||
}
|
||||
}
|
||||
|
@ -166,22 +165,14 @@ private static async Task ConnectWebSocket()
|
|||
{
|
||||
var date = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
||||
_audioFilePath = $"{_ffmpegFolderPath}\\{songName}_{date}.wav";
|
||||
|
||||
// Ensure the output folder exists
|
||||
var outputFolder = Path.GetDirectoryName(_audioFilePath)!;
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
// Set up the WasapiLoopbackCapture
|
||||
_waveSource = new WasapiLoopbackCapture();
|
||||
_writer = new WaveFileWriter(_audioFilePath, _waveSource.WaveFormat);
|
||||
|
||||
// Handle the DataAvailable event
|
||||
_waveSource.DataAvailable += (sender, args) =>
|
||||
{
|
||||
_writer.Write(args.Buffer, 0, args.BytesRecorded);
|
||||
};
|
||||
|
||||
// Handle the RecordingStopped event
|
||||
_waveSource.RecordingStopped += (sender, args) =>
|
||||
{
|
||||
_writer.Dispose();
|
||||
|
@ -190,7 +181,6 @@ private static async Task ConnectWebSocket()
|
|||
_waveSource = null;
|
||||
};
|
||||
|
||||
// Start recording
|
||||
_waveSource.StartRecording();
|
||||
Console.WriteLine("WASAPI Audio recording started.");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue