NA从耳机录音

发布于 2024-12-08 19:27:25 字数 712 浏览 0 评论 0原文

我一直在使用 http://opensebj 中的代码。 blogspot.com/2009/04/naudio-tutorial-5-recording-audio.html 录制音频。基本上这段代码:

WaveIn waveInStream;
WaveFileWriter writer;

waveInStream = new WaveIn(44100,2);
writer = new WaveFileWriter(outputFilename, waveInStream.WaveFormat);

waveInStream.DataAvailable += new EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);
waveInStream.StartRecording();

它工作完美并记录系统上的每个声音。当我插入耳机(不是 USB,而是直接插入笔记本电脑内置声卡上的耳机插孔)时,就会出现问题。这会导致我在耳机中听到的任何声音都不会被录制。 我认为这与我录制的设备有关,但我不太明白。

我正在尝试录制对话,这意味着我想同时录制来自麦克风的声音和我在耳机中听到的声音。

有人能指出我正确的方向吗?谢谢。

I have been using the code in http://opensebj.blogspot.com/2009/04/naudio-tutorial-5-recording-audio.html to record audio. Basically this code:

WaveIn waveInStream;
WaveFileWriter writer;

waveInStream = new WaveIn(44100,2);
writer = new WaveFileWriter(outputFilename, waveInStream.WaveFormat);

waveInStream.DataAvailable += new EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);
waveInStream.StartRecording();

It works perfectly and record every sound on the system. The problem arises when I pluck in a headset (not usb, just directly into the headset jack on the built in soundcard on my laptop). This has the effect that any sound I can hear in the headset is not recorded.
I think it has something to do with which device i am recording from, but I can't quite figure it out.

I am trying to record a conversation, which means I would like to record the sound that comes from the mic and the sound I can hear in the headset at the same time.

Can someone point me in the right direction for this? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似最初 2024-12-15 19:27:25
// Get default capturer
waveInStream = new WaveIn(44100,2);

现在,如果您插入耳机麦克风/扬声器,Windows 将检测到它,但您的程序仍在使用旧的“默认”端点。不是最后添加的设备。这需要更新。

解决方案之一是轮询端点并查看是否已将任何新(默认)设备添加到系统中,然后使用新设备停止/启动记录。

waveInStream.StopRecording();
// assign the default recording device if not already done
//waveInStream.DeviceNumber = 0;
waveInStream.StartRecording();

如果我的解释不太清楚,请告诉我。

// Get default capturer
waveInStream = new WaveIn(44100,2);

Now if you plug in your headset microphone/speaker then Windows will detect it but your program is still using the old 'default' endpoint. Not the lastly added device. This needs to be updated.

One of the solution would be to poll the endpoints and see if any new (default) device has been added to the system and then stop-start the recording with the new device.

waveInStream.StopRecording();
// assign the default recording device if not already done
//waveInStream.DeviceNumber = 0;
waveInStream.StartRecording();

Let me know if I was not very clear in the explanation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文