简体   繁体   English

在.NET应用程序中使用音频的推荐方法?

[英]Recommended way to work with audio in .NET applications?

I'm trying to get started with a simple audio application under .NET 3.5 (preferably in VB.NET, but will happily use C#). 我正在尝试使用.NET 3.5下的简单音频应用程序(最好是在VB.NET中,但很乐意使用C#)。 What I'd like to do is: 我想做的是:

  • Continuously record audio from (the default) Windows audio input device in 8-bits-per-sample PCM format 从(默认)Windows音频输入设备以8位每采样PCM格式连续录制音频
  • For every N bytes captured, do some analysis on the raw audio (some RMS and/or SPL calculations -- basically what you'd need for a pretty VU bar graph thingy) 对于捕获的每N个字节,对原始音频进行一些分析(一些RMS和/或SPL计算 - 基本上你需要一个漂亮的VU条形图东西)
  • If the audio fragment is found interesting after analysis, save it using a compressed file format (eg MP3) 如果在分析后发现音频片段很有趣,请使用压缩文件格式(例如MP3)保存

First thing I noticed is that audio support in the basic .NET Framework is pretty much nonexistent. 我注意到的第一件事是基本.NET Framework中的音频支持几乎不存在。 Googling around a bit found some sample code, mostly using Managed DirectX. 谷歌搜索了一些示例代码,主要是使用Managed DirectX。 However, the lack of MSDN documentation, vintage of the libraries (2004) and the following menacing MDA exception in VS.NET 2008, convinced me this is a dead end: 然而,缺乏MSDN文档,库的复古(2004)以及VS.NET 2008中的以下威胁性MDA异常使我确信这是一个死胡同:

Message: DLL 'Microsoft.DirectX.dll' is attempting managed execution inside 
OS Loader lock. Do not attempt to run managed code inside a DllMain or image
initialization function since doing so can cause the application to hang.

...which I think loosely translates as "don't even try to use this stuff." ...我认为松散地翻译为“甚至不尝试使用这些东西。” Am I missing something here, or is Managed DirectX really dead? 我在这里遗漏了什么,或者Managed DirectX真的死了吗? Another StackOverlow question suggests that XNA is a replacement for Managed DirectX, but it lacks the kind of low-level functionality I need. 另一个StackOverlow问题表明XNA是Managed DirectX的替代品,但它缺乏我需要的那种低级功能。

So, which API or third-party library is actually useful for audio development under .NET? 那么,哪个API或第三方库对.NET下的音频开发实际上有用呢? Using COM interop or P/Invoke is acceptable, as long as there's some decent .NET example code available to get started with... 使用COM互操作或P / Invoke是可以接受的,只要有一些不错的.NET示例代码可用于开始...

Have you looked into NAudio on CodePlex ? 你有没有在CodePlex上看过NAudio It looks like it has the features you need. 看起来它具有您需要的功能。

我一直是拥有.NET API的BASS库的粉丝。

If you want to try a DirectX based sound solution you can use SlimDX . 如果您想尝试基于DirectX的声音解决方案,可以使用SlimDX It supports DirectSound and XAudio interfaces. 它支持DirectSound和XAudio接口。

另一个是FMOD

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 控制台应用程序相互通信的推荐方式是什么? - What's the recommended way for console applications to talk with each other? 官方推荐的创建ASP.NET Webforms应用程序的技术是什么? - What is the officially recommended technology to create ASP.NET Webforms applications? 混合.NET和文件上下文菜单的推荐方法 - Recommended way of mixing .NET and file context menus web 应用程序在 .NET 中处理这种情况的推荐方法 - recommended way to handle this case in .NET for web application 在MVVM应用程序中不推荐使用MessageBox? - MessageBox is not recommended in MVVM applications? SetUnhandledExceptionFilter如何在.NET WinForms应用程序中工作? - How does SetUnhandledExceptionFilter work in .NET WinForms applications? 在.NET中使用固定大小的线程池的推荐方法是什么? - What is recommended way to use fixed size thread pool in .NET? Lucene.NET:索引和搜索DateTime和TimeSpan字段的推荐方法 - Lucene.NET: Recommended way to index and search for DateTime and TimeSpan fields 在 ASP.NET Core 3.0 中配置 Autofac 的推荐方法 - Recommended way to configure Autofac in ASP.NET Core 3.0 将 .NET Core 应用程序部署到 Heroku 的推荐方法是什么? - What is the recommended way to deploy a .NET Core app into Heroku?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM