tags:

views:

221

answers:

4

Is there a way to get the sound that the sound card is playing directly from the hardware?

A: 

some sound cars can select the output sound as mic, if that is acceptable then you could just google how to use the microphone...

Petoj
A: 

I presume that this is Windows since you are using C#. Ignore this if you are using mono.

There is no officially supported way to do this in Windows. Some sound cards have a setting in the mixer that will set the wave record input to 'what you hear'. So on those cards, you could just set that setting and then record audio.

edit:

I should add that if your driver doesn't have built in support for recording what it's outputing, then you will need to write or purchase a driver that does. I've heard that TotalRecorder can do this.

John Knoeller
That's an option but i don't want having the user to manually change settings the program should handle everything.
slayerIQ
It's possible to programatically manipulate the mixer, although you may have to write unmanaged code to do it. And the mixer api is a pain to work with.
John Knoeller
And what if my program is playing the sound itself ?
slayerIQ
Then save the data before you play it, of course. That would be much easier.
John Knoeller
The thing i want to do is play a youtube clip inside my program and the sound capture the sound of the movie. It should also work with sounds from other sources, but youtube is what i want to start with.
slayerIQ
Total Recorder is the easiest general purpose way I know of to do this. This is a hard problem unless you write drivers for a living.
John Knoeller
If you're really only trying to strip the sound from a YouTube video, you have a completely different (almost certainly easier) problem than trying to record from the sound card.
dnord
A: 

The most general way is Total Recorder which has a COM interface.

jspcal
+1  A: 

NAudio is a nice API for sound programming in C#. I'm only discovered it myself, but it might be able to record the output, though probably not...

http://www.codeplex.com/naudio

Kurru
Just tried out a NAudio sample code and i can confirm it does record speaker output. well, with my crappy inbuilt sound card anyway
Kurru
Thank you trying it out right away
slayerIQ