I'm trying to write some code to capture both the microphone and stereo mix with DirectShow filters. First I'm trying to set up the filters using GraphEdit from Windows SDK. I set the capture devices to Microphone and Stereo Mix then connect the Capture pins from both of them to the Input 01 and Input 02 of an AVI Mux and then connect the AVI Out pin to the in pin of the File Writer. When I run the graph I get
This graph can't play. Unspecified error (Return code : 0x80004005)
I've searched this error quite a bit and I can't seem to find an answer.
If I try to connect them separately to a WAV Dest filter for each of them, I get the same error. For some reason I can't understand, it won't let me capture both. Is StereoMix emulating the Microphone when I capture from it?
If I try to capture from them one at a time it works, but I need to capture from both at the same time. If I set the Microphone to output to speakers, then I can record both of them, but that doesn't really help me because the user can hear himself in the speakers which can really be distracting.
I've also tried and succeeded to record the loopback with WASAPI, but I need some backwards compatibility since recording the loopback with WASAPI only works for Vista or Windows 7.
I've looked into PortAudio
and FFmpeg
but I can't afford to complicate the program more than it already is. What should I do?
I've done some further research. Apparently this is a really icky situation. I didn't find the answer regarding the DirectShow filters.
Some computers don't have sound cards that support StereoMix. The only solution that will work also on Windows XP is to create a virtual audio driver using the Windows DDK, setting that as default device, passing the buffer to the real audio device (to not hinder the audio output) and to my application.
At the same time I can use a DirectShow filter to capture audio from the microphone.
Here is the documentation from Microsoft on audio drivers : http://msdn.microsoft.com/en-us/library/windows/hardware/ff537871%28v=vs.85%29.aspx
I'm not very versed in these matters. I hope this helps anyone who is the same situation. If anyone has any other suggestion please let me know.