Reputation: 1
Is it possible to capture 16000 kHz sample rate rather than 48000 kHz? Currently the code below captures 48000 kHz sample rate.
var outputFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "NAudio");
Directory.CreateDirectory(outputFolder);
var outputFilePath = Path.Combine(outputFolder, "recorded.wav");
var capture = new WasapiLoopbackCapture();
var writer = new WaveFileWriter(outputFilePath, capture.WaveFormat);
var sampleRate = capture.WaveFormat.SampleRate; <--- this returns 48000, but I need 16000
capture.DataAvailable += (s, a) =>
{
writer.Write(a.Buffer, 0, a.BytesRecorded);
if (writer.Position > capture.WaveFormat.AverageBytesPerSecond * 20)
{
capture.StopRecording();
}
};
Upvotes: 0
Views: 125
Reputation: 49482
WASAPI will not let you pick 16kHz. You can use WaveInEvent, but you wont be able to do loopback capture. Your only real option with WASAPI is to resample the audio to 16kHz after capturing
Upvotes: 0