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 捕获麦克风音频流
基础教程推荐
- Page.OnAppearing 中的 Xamarin.Forms Page.DisplayAlert 2022-01-01
- 如何使用OpenXML SDK将Excel转换为CSV? 2022-01-01
- 从 VB6 迁移到 .NET/.NET Core 的最佳策略或工具 2022-01-01
- 当键值未知时反序列化 JSON 2022-01-01
- 我什么时候应该使用 GC.SuppressFinalize()? 2022-01-01
- 使用 SED 在 XML 标签之间提取值 2022-01-01
- C# - 如何列出发布到 ASPX 页面的变量名称和值 2022-01-01
- 创建属性设置器委托 2022-01-01
- 覆盖 Json.Net 中的默认原始类型处理 2022-01-01
- C# - 将浮点数转换为整数...并根据余数更改整数 2022-01-01