mirror of
https://github.com/tuxdotrs/highminded.git
synced 2025-08-22 23:51:03 +05:30
30 lines
794 B
C#
30 lines
794 B
C#
using System;
|
|
using System.IO;
|
|
using SoundFlow.Backends.MiniAudio;
|
|
using SoundFlow.Components;
|
|
using SoundFlow.Enums;
|
|
|
|
namespace highminded.utils;
|
|
|
|
public class AudioCapture
|
|
{
|
|
private readonly MiniAudioEngine _audioEngine =
|
|
new(48000, OperatingSystem.IsWindows() ? Capability.Loopback : Capability.Mixed);
|
|
|
|
private Stream? _fileStream;
|
|
private Recorder? _recorder;
|
|
|
|
public void StartRecording(string filePath)
|
|
{
|
|
_fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None);
|
|
_recorder = new Recorder(_fileStream, sampleRate: 48000);
|
|
_recorder.StartRecording();
|
|
}
|
|
|
|
public void StopRecording()
|
|
{
|
|
_recorder?.StopRecording();
|
|
_recorder?.Dispose();
|
|
_fileStream?.Dispose();
|
|
}
|
|
} |