NAudio
NAudio copied to clipboard
Capture sound per window
Is there anyway to capture sound for a single program? There has to be a way since discord has done it for their screenshare.
The WASAPI Windows APIs unfortunately do not offer this capability, so I'm afraid I don't know how discord achieve this.
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.
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.
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
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.