如何将麦克风(Line-In)和播放设备(Speakers Line-Out)的音频录制到一个MP3文件中 [英] How to record audio from microphone (Line-In) and playback device (speakers Line-Out) to one MP3 file

查看:505
本文介绍了如何将麦克风(Line-In)和播放设备(Speakers Line-Out)的音频录制到一个MP3文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将麦克风和扬声器的音频录制到一个MP3文件中.

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

如何使用NAudio在C#中实现此目标?

How to achieve this in C# with NAudio?

我已经录制了来自麦克风的音频,但是我不知道如何从扬声器录制,然后混音到一个MP3文件中.

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.

推荐答案

您需要分别录制麦克风和扬声器,然后将它们混合,然后转换为MP3.

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

要录制扬声器,您应该查看WasapiLoopbackCapture.一个警告是,WASAPI Loopback Capture在播放任何内容时都不会始终返回数据,因此您可以在录制时通过保持静音来解决此问题.

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.

要录制麦克风,可以使用WasapiCapture.然后将两者捕获为WAV,可以使用MixingSampleProvider,然后使用WaveFileWriter将其混合成WAV,然后可以使用MediaFoundationEncoder制作MP3,或者如果不使用,则可以使用LAME.exe.安装了Media Foundation MP3编码器.

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.

这篇关于如何将麦克风(Line-In)和播放设备(Speakers Line-Out)的音频录制到一个MP3文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆