How to record audio from microphone (Line-In) and playback device (speakers Line-Out) to one MP3 file

假如想象 提交于 2019-12-23 04:30:54

问题


I am trying to record audio from the microphone and speakers to one MP3 file.

How to achieve this in C# with NAudio?

I have already recorded audio from microphone, but I can't figure out how to record from speakers, and then mix to one MP3 file.


回答1:


You'd need to record the microphone and the speakers separately, then mix them, then convert to MP3.

To record the speakers, you should look at WasapiLoopbackCapture. One caveat is that WASAPI Loopback Capture doesn't always return data if nothing is playing, so you can work around this by playing silence while you are recording.

To record the microphone you could use WasapiCapture. Then having captured both as WAV, you can use a MixingSampleProvider followed by a WaveFileWriter to mix them down to WAV, and then maybe use the MediaFoundationEncoder to make MP3, or more use LAME.exe if you don't have a media foundation MP3 encoder installed.



来源:https://stackoverflow.com/questions/23933906/how-to-record-audio-from-microphone-line-in-and-playback-device-speakers-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!