简体   繁体   English

麦克风实时音频播放。 C#

[英]Real time audio playback from mic. c#

I am looking to create an application that will allow me to record from my mic and playback the recording through other pc's. 我正在寻求创建一个应用程序,该应用程序允许我从自己的麦克风录音并通过其他PC播放录音。 At this point however I would just like it to play back on my own computer so I can get it working. 但是在这一点上,我希望它可以在我自己的计算机上播放,以便可以正常工作。

I have been looking at NAudio for the past few hours and it seems like it may be able to help me achieve this goal. 在过去的几个小时中,我一直在研究NAudio,它似乎可以帮助我实现这一目标。

I am just wondering if anyone else has had any experience with this and if it is at all possible? 我只是想知道是否有人对此有任何经验,是否有可能?

Thanks, Stuart 谢谢,斯图尔特

There is an example project on codeproject doing this: 在codeproject上有一个示例项目正在执行此操作:
http://www.codeproject.com/KB/cs/Streaming_wave_audio.aspx http://www.codeproject.com/KB/cs/Streaming_wave_audio.aspx
I don't know how low the latency is. 我不知道延迟有多低。

As a codec I'd recommend Speex(at least for speech). 作为编解码器,我建议使用Speex(至少用于语音)。 It's free, open source and offers low latency and low bandwidth. 它是免费的开放源代码,并提供低延迟和低带宽。

低音音频库是另一个值得研究的可靠选择。

It is possible to do, but you are unlikely to get low latency with WaveIn/WaveOut (possibly better results with WASAPI). 可以这样做,但是WaveIn / WaveOut不太可能获得低延迟(WASAPI可能会带来更好的结果)。 You could use the BufferedWaveProvider (in the latest source code) to store up the audio being recorded from the microphone and supplying the output to soundcard. 您可以使用BufferedWaveProvider (在最新的源代码中)存储从麦克风录制的音频并将输出提供给声卡。

NAudio is great as a starting point for audio capture and playback but as Mark pointed out the latency might be an issue. NAudio非常适合作为音频捕获和播放的起点,但正如Mark指出的那样,延迟可能是一个问题。

If you take the next step and want to sent the audio data across the network you will need a codec to compress the data as PCM or WAV are uncompressed and for voice you only need a small part of the bandwidth needed for WAV. 如果您要进行下一步,并且想通过网络发送音频数据,则由于PCM或WAV未压缩,您将需要一个编解码器来压缩数据;对于语音,您只需要WAV所需带宽的一小部分。 As you are working with C# there is a C# port of Speex available, called NSpeex , which might be worth having a look at.. 在使用C#时,有一个Speex的C#端口可用,称为NSpeex ,可能值得一看。

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

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