NAudio icon indicating copy to clipboard operation
NAudio copied to clipboard

Capture sound per window

Open SupertigerDev opened this issue 6 years ago • 5 comments

Is there anyway to capture sound for a single program? There has to be a way since discord has done it for their screenshare.

SupertigerDev avatar May 14 '19 14:05 SupertigerDev

The WASAPI Windows APIs unfortunately do not offer this capability, so I'm afraid I don't know how discord achieve this.

markheath avatar May 17 '19 18:05 markheath

This has changed recently: https://github.com/microsoft/Windows-classic-samples/blob/main/Samples/ApplicationLoopback/cpp/LoopbackCapture.cpp

The necessary APIs are available since Windows 10 Build 20348.

lostmsu avatar Jun 23 '23 22:06 lostmsu

Yes, I attempted to implement this a while back but it unfortunately didn't work because I think you also have to switch over to ActivateAudioInterfaceAsync which is a fairly disruptive change. Maybe will give it another go at some point, or happy to work with someone on getting a PR in.

markheath avatar Jun 24 '23 09:06 markheath

Don't know if they use the same thing, but this obs plugin allows to capture per app audio. Maybe it will help: https://github.com/bozbez/win-capture-audio

SupertigerDev avatar Jun 24 '23 09:06 SupertigerDev

Yes, looks like the same approach. I've also seen some C# code doing the same thing, so I know its possible. Just awkward to rework the existing WASAPI code to activate the device in a different way.

markheath avatar Jun 24 '23 15:06 markheath