Open forlayo opened 11 months ago
This is a code sample of how to reproduce the issue:
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.
For reference, I posted the issue on stackoveflow as well.
There can be different ways of "muting" speakers. One is to zero out all the samples in the stream. But other ways include turning a volume control that is after the DAC. So it might be that this device has implemented muting differently from your other devices.
Steps
Note: This is not happening in my other computers with Windows 11.
Expected behavior Getting audio from what's being played in the device, as with other devices, even when speakers are muted.
Device's details