refactor: modernize code, improve performance, and clean up various components.
This commit is contained in:
@@ -1,32 +1,24 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
using Toak.Core;
|
||||
using Toak.IO;
|
||||
|
||||
using Toak.Core.Interfaces;
|
||||
|
||||
namespace Toak.Audio;
|
||||
|
||||
public class AudioRecorder : IAudioRecorder
|
||||
public class AudioRecorder(IRecordingStateTracker stateTracker, INotifications notifications) : IAudioRecorder
|
||||
{
|
||||
private readonly string WavPath = Constants.Paths.RecordingWavFile;
|
||||
private readonly IRecordingStateTracker _stateTracker;
|
||||
private readonly INotifications _notifications;
|
||||
private readonly string _wavPath = Constants.Paths.RecordingWavFile;
|
||||
private readonly IRecordingStateTracker _stateTracker = stateTracker;
|
||||
private readonly INotifications _notifications = notifications;
|
||||
|
||||
public AudioRecorder(IRecordingStateTracker stateTracker, INotifications notifications)
|
||||
{
|
||||
_stateTracker = stateTracker;
|
||||
_notifications = notifications;
|
||||
}
|
||||
|
||||
public string GetWavPath() => WavPath;
|
||||
public string GetWavPath() => _wavPath;
|
||||
|
||||
public void StartRecording()
|
||||
{
|
||||
if (File.Exists(WavPath))
|
||||
if (File.Exists(_wavPath))
|
||||
{
|
||||
Logger.LogDebug($"Deleting old audio file: {WavPath}");
|
||||
File.Delete(WavPath);
|
||||
Logger.LogDebug($"Deleting old audio file: {_wavPath}");
|
||||
File.Delete(_wavPath);
|
||||
}
|
||||
|
||||
Logger.LogDebug("Starting pw-record to record audio...");
|
||||
@@ -34,7 +26,7 @@ public class AudioRecorder : IAudioRecorder
|
||||
var pInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = Constants.Commands.AudioRecord,
|
||||
Arguments = $"--rate=16000 --channels=1 --format=s16 \"{WavPath}\"",
|
||||
Arguments = $"--rate=16000 --channels=1 --format=s16 \"{_wavPath}\"",
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardOutput = true,
|
||||
|
||||
Reference in New Issue
Block a user