Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Audio Capture using DirectShow

1 view
Skip to first unread message

Shashank

unread,
Apr 10, 2007, 3:10:41 AM4/10/07
to
Hi All,

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

Chris P.

unread,
Apr 10, 2007, 8:28:35 AM4/10/07
to

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]

Shashank

unread,
Apr 11, 2007, 8:13:34 AM4/11/07
to
Thanks Chris for helping me out. I enumerated the audio capture
source for the input pins and see only Line In, External Mic and
Internal Mic. I dont see the stereo mixer as an input pin. These are
also the only recording options available for my recording source
(Mixer device/Recording). The WaveOut can be seen as an output pin.
Is there any loopback way to route all output audio to some input
pin :-) . Is there any way to do this with Directshow? I can see a lot
of programs on the net doing this, they mention directshow in their
documentation, how do they do it?

Chris P.

unread,
Apr 11, 2007, 9:01:00 AM4/11/07
to

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.

Shashank

unread,
Apr 12, 2007, 6:37:23 AM4/12/07
to
Chris, there was a driver problem with my soundcard (SigmaTel), I
downloaded the drivers and now have StereoMix as an input pin. I
tested out the following graph:

<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?

Chris P.

unread,
Apr 12, 2007, 8:31:00 AM4/12/07
to

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.

JanQ

unread,
Apr 25, 2007, 11:44:02 AM4/25/07
to
I read this thread with high interest, because I would like to do something
very similar.
I would like to capture all audio which is normally played by the sound card
and route it to an external sound device via Bluetooth. Actually I would like
to route it to the Bluetooth Audio Device which routes it to my external
sound device.

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

0 new messages