Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture Sound Output In C#

Tags:

c#

audio

I'm trying to build a program in C# that will allow me to stream audio and video from one computer, over the network, to another computer, which is hooked up to a bunch of video/audio equipment (projector, speakers, etc). Ideally, I'd like to be able to capture this data directly from the "presenter" computer without it having to plug into anything.

The video, streaming, and re-displaying on the "output" computer is all working well, but I can't seem to find a good way to capture audio output without the need for a cable plugged in to the headphone jack and wired to the other computer. The whole point of this program is to allow this to be done wirelessly, so this is kind of a problem. To sum up, I'm looking for some sort of C# interface that will allow me to capture the sound output on a windows machine, as though I had plugged something into the headphone jack.

Thanks in advance for any help.

like image 836
Sean James Avatar asked Aug 18 '09 06:08

Sean James


3 Answers

In Windows, the audio card manufacturers could choose to supply a "what you hear" input stream in order for you to capture the output. If your sound card/driver doesn't have this feature, you could try to use the Virtual Audio Cable to perform the same thing.

In Windows 7, there's a new functionality that allows you to listen to / capture any input stream directly.

like image 85
Magnus Johansson Avatar answered Oct 19 '22 17:10

Magnus Johansson


If you already have the Video side figured out; NAudio is a good way to handle the Audio component.

Assuming we break the task in to the recording and then the receiving and playing components then the following should help you with each side;

The recording: http://opensebj.blogspot.com/2009/04/naudio-tutorial-5-recording-audio.html

The receiving and playing: Play audio from a stream using C#

The method of transport in between is up to you but if you already have a way of sending a stream between two computers you should be able to reuse that. Just make sure your buffer is big enough that there is always data to play back on the receiving computer.

like image 27
Sebastian Gray Avatar answered Oct 19 '22 16:10

Sebastian Gray


Have a look at the code in this article , it needs to be modified quite a bit to be able to stream the output over the network , but that should not be hard enough. http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=19102

like image 36
RC1140 Avatar answered Oct 19 '22 18:10

RC1140