简体   繁体   English

在C#中捕获声音输出

[英]Capture Sound Output In C#

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). 我正在尝试用C#构建一个程序,它允许我通过网络将音频和视频从一台计算机传输到另一台计算机,该计算机连接到一堆视频/音频设备(投影仪,扬声器等) 。 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. 总而言之,我正在寻找某种C#接口,它允许我在Windows机器上捕获声音输出,就好像我已经将东西插入耳机插孔。

Thanks in advance for any help. 在此先感谢您的帮助。

In Windows, the audio card manufacturers could choose to supply a "what you hear" input stream in order for you to capture the output. 在Windows中,声卡制造商可以选择提供“你听到的”输入流,以便捕获输出。 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. 在Windows 7中,有一项新功能允许您直接侦听/捕获任何输入流。

If you already have the Video side figured out; 如果你已经找到了视频方面; NAudio is a good way to handle the Audio component. NAudio是处理音频组件的好方法。

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 录音: http//opensebj.blogspot.com/2009/04/naudio-tutorial-5-recording-audio.html

The receiving and playing: Play audio from a stream using C# 接收和播放: 使用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. 只需确保您的缓冲区足够大,以便始终在接收计算机上播放数据。

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 http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=19102

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM