简体   繁体   English

如何将音频流从输出设备发送到输入设备?

[英]How can I send an audio stream from the output device to an input device?

I am working on a project where I am playing a wave file using naudio to someone over the phone through a softphone. 我正在一个项目中,在该项目中,我使用naudio通过软电话通过电话向某人播放波形文件。 The person making the call, wearing a usb headset (which is an external soundcard) would need to be able to speak along with the wave files. 戴着USB耳机(是外部声卡)的通话者需要能够与Wave文件一起讲话。 Right now I'm running a dual 3.5mm audio cable from the output into the input on the back of the computer to make this happen. 现在,我正在使用双3.5mm音频电缆,从输出到计算机背面的输入,以实现此目的。 This is making me have to use the onboard sound card for the wave and the head set for the person to speak which means I have to switch the default input audio device on-demand to allow the person to be heard or the wave to be heard. 这使我不得不使用板载声卡来进行波形显示,并使用头戴式耳机进行语音交流,这意味着我必须按需切换默认的输入音频设备,才能听到该人的声音或听到该波形的声音。 This causes issue with the softphone app depending on how its devices are set. 这会导致软电话应用程序出现问题,具体取决于其设备的设置方式。 I want to cut out the onboard soundcard altogether. 我想完全切掉板载声卡。 I want to send both my wave audio and the person speaking, into the same input device. 我想将Wave音频和说话的人都发送到同一输入设备中。

When I play the audio this is the code I call: 当我播放音频时,这就是我所调用的代码:

WaveStream waveStream = new WaveFileReader(@"C:\Users\Public\Music\tester.wav");

WaveOut waveOut = new WaveOut();

waveOut.DeviceNumber = int.Parse(device1);

WaveOut.Init(waveStream);

WaveOut.Play();

At this point I would love to not only send to the selected output device but also to an input device as well. 在这一点上,我不仅希望发送到所选的输出设备,而且还希望发送到输入设备。 Is there any simple ways I can do this? 有什么简单的方法可以做到这一点吗? Thanks for your help in advance. 感谢您的帮助。

Unfortunately, the various Windows audio APIs provide no way for you to replace the audio received by an actual input device with your own audio, so this isn't something you can achieve out of the box with NAudio. 不幸的是,各种Windows音频API无法为您提供用自己的音频替换实际输入设备接收到的音频的方法,因此,使用NAudio无法做到这一点。 What you need is to create a virtual audio input device. 您需要创建一个虚拟音频输入设备。 This is quite a lot of work, so the simplest solution is to purchase something like Virtual Audio Cable , which will allow you to create virtual sound devices and patch them together. 这是很多工作,因此最简单的解决方案是购买诸如Virtual Audio Cable之类的东西,这将使您能够创建虚拟声音设备并将它们修补在一起。

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

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