I want to capture all audio which is played by the sound card and save
it in a file. That is to say whenever an application plays a sound /
song and whenever Windows plays an audio alert, the audio data would
be captured and stored in a file. Can DirectShow filters be used for
this purpose, if yes how? Can you please suggest which filters can I
use? Is there any sample code for this ? The AudioCap sample privided
in the DirectX SDK didnt capture any sound from the speakers.
TIA
The audio capture source can capture from any input, including the Stereo
Mix loopback pin (usually Stereo Mix). To change the input source you must
enumerate the audio capture source for it's input pins (these are not
connectable pins). When you find the pin you wish to enable, query for
IAMAudioInputMixer and call put_Enable.
In the AudioCap sample you can probably do the same thing using the
property pages.
--
http://www.chrisnet.net/code.htm
[MS MVP for DirectShow / MediaFoundation]
It seems your hardware isn't a standard sound card, as most have this.
There isn't a DirectShow solution exactly.
The solutions you see on the net on the most part use a Virtual Audio
Device (VAD). This is a device driver that pretends it has a piece of
hardware, but can do anything it wants with the audio stream. In your case
you would need one that just loops it's output back to it's input. You can
then record from the VAD device input anything that was sent to the output.
I'm not sure if anyone has a sample driver out there that does this
already, there are certainly commercial solutions. If you're willing try
it yourself there is a Microsoft sample that provides the framework of the
driver. It's in the Windows DDK (use the server 2003 version) under
\src\wdm\audio\msvad. Be warned, kernel drivers aren't for the faint of
heart.
<Sound Card Audio Capture Source > ====><Wav Dest>=====><File Writer>
I used graphedit to run this with success (I will need to do this
programatically now). This enabled me to capture all audio played by
any application. However this also captures silence, and as a result
the size of the file increases. Is there any way to tell Directshow
not to capture silence and only capture audio - programatically?
The standard filter set doesn't allow this no.
To save space add a compatible compressor before the WAV Dest filter.
You could eliminate the silence recording by writing a silence detection
filter. The filter would not forward samples that contained only silence
or something close to it.
But the capturing of all media which is normally played by the sound card
would be exactly the same!
Could you tell me, how you finally made this work?
Which functions/filters did you use?
Thank you for any help!
Regards,
Jan