4

I am using NAudio library and recording "what you hear" using its WasapiLoopbackCapture in a very simplistic way:

        var outputFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "NAudio");
        Directory.CreateDirectory(outputFolder);
        var outputFilePath = Path.Combine(outputFolder, "recorded.pcm");

        var loopback = new WasapiLoopbackCapture();
        var fileWriter = new WaveFileWriter(outputFilePath, loopback.WaveFormat);
        loopback.RecordingStopped += (s, a) => { fileWriter.Dispose(); };
        loopback.DataAvailable += (object? sender, WaveInEventArgs args) =>
        {
            fileWriter.Write(args.Buffer, 0, args.BytesRecorded);
        };

Then I play a video on youtube and mute speakers.

On most devices, this works well and file produced has the audio that's being played on the device no matter if speakers are muted or not.

But there are some devices in which when speakers are muted the audio received and hence the file content is just silence.

I am not sure on what's happening or how to solve it, I tried updating drivers and playing creating my own version of WasapiLoopbackCapture to change audio devices and so on but nothing works at the minute.

Anyone knows what's happening here and how can I achieve this on all devices?

Here's a sample of device in which the bad behaviour is happening:

ACER Aspire 3 A315-23-R8T0
Windows 10 Pro 22H2 Build 19045.3208
Realtek(R) Audio
Driver Provider: Microsoft
Driver Version: 10.0.19041.1

For reference, I posted the issue on NAudio as well.

forlayo
  • 1,371
  • 2
  • 13
  • 23

0 Answers0