Capture a Microphone Audio Stream Using .NET Framework(使用 .NET Framework 捕获麦克风音频流)
问题描述
我需要从我的应用程序中的麦克风捕获输入流,该应用程序是用 VB.NET 编写的.我需要能够将此数据流式传输到文件或通过 HTTP 并可能使用 LAME MP3 对其进行编码.有人可以帮我开始吗?
I need to capture the input stream from a microphone in my application, which is written in VB.NET. I need to be able to stream this data to a file or over HTTP and possibly encode it using LAME MP3. Can anybody help me get started with this?
谢谢!
推荐答案
如果你想要一个 .NET 解决方案,你可以查看 NAudio 这是一个开源音频库.查看WaveInStream 类(或最新代码中的WaveIn).这将让您打开麦克风,并接收包含最新捕获字节的事件.这将很容易传递给流.
If you want a .NET solution, you can check out NAudio which is an open source audio library. Look at the WaveInStream class (or WaveIn in the latest code). This will let you open a microphone, and receive events containing the latest captured bytes. This would be quite easy then to pass on to a stream.
至于使用 LAME 编码 MP3,我见过的一种方法是通过 stdin 将音频传递给 lame.exe,然后从 stdout 读取 mp3.我认为这比获取 LAME DLL 并为其编写互操作包装更容易.
As for encoding MP3 using LAME, one approach I have seen used is to pass the audio to lame.exe via stdin and read the mp3 from stdout. This is I think easier than getting hold of a LAME DLL and writing interop wrappers for it.
更新:我创建了一个示例项目,该项目使用 NAudio 从麦克风录音,并在 http://voicerecorder.codeplex.com.请参阅我在 Coding4Fun 上的文章此处.
Update: I have created an example project that uses NAudio to record from the microphone, and LAME to save as MP3 at http://voicerecorder.codeplex.com. See my article at Coding4Fun here.
这篇关于使用 .NET Framework 捕获麦克风音频流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 .NET Framework 捕获麦克风音频流
基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
