I am trying to start with a simple audio application under .NET 3.5 (preferably in VB.NET, but I use C # with pleasure). I would like to do the following:
- Record audio continuously from (default) PCM audio input device in Windows with 8 bits to choose from.
- For each N byte captured, do some analysis of the raw sound (some RMS and / or SPL calculations are basically what you need for a beautiful VU histogram graph)
- If a piece of an audio clip is interesting after analysis, save it using a compressed file format (for example, MP3).
The first thing I noticed is that audio support in the main .NET platform practically does not exist. It seems that the sample code has worked a little, mainly using Managed DirectX. However, the lack of MSDN documentation, vintage libraries (2004), and the following threatening MDA exception in VS.NET 2008, convinced me that this was a dead end:
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, is freely translated as "even try to use this material." Am I missing something here, or is DirectX driven really dead? Another StackOverlow question suggests that XNA is a replacement for Managed DirectX, but it lacks the low-level features that I need.
So, which API or third-party library is really useful for developing sound for .NET? Using COM interoperability or P / Invoke is acceptable if there is some decent .NET code example that you can start with ...
mdb
source share