.NET audio recording with specific requirements

There are a ton of tutorials and blogs out there about recording audio from .NET. I've read and understood fundamentally different options, but I'm not sure which approach would be the simplest, still satisfying my requirements:

Minimum

  • .NET program-controlled start and stop recording.
  • Default microphone recording to file
  • Minimize the requirements for the end user computer (i.e. ideally no requirement for the latest version of DirectX)
  • Save to any common, compressed file Format

Perfectly

  • Remove quiet recording areas
  • Start / stop triggering for the presence of sound input (recording only when there is something recording)
  • Ability to resume recording, adding to a previously saved file

I can sort out the implementation details and am just looking for advice on the best way to start given my set of requirements.

+2


source to share


1 answer


I prefer to record audio using the waveIn * API functions (waveInOpen, etc.). While this API is old (over 15 years old) and a little harder to work with than you might like, it can do everything you mentioned above (except one), doesn't require DirectX at all, and works on every version of Windows back to Windows 95 (though. NET didn't work before anything until Windows 98), even including Windows Mobile (this last fact exploded when I discovered it).

The only thing it can't handle is save to any common compressed file format (but I don't think writing with DirectSound - another important option - handles that either). However, there are a number of .NET compatible libraries that can handle this requirement for you (NAudio is recommended, although I never used it). One of the advantages of recording with waveIn * (same advantage as DirectSound) is that you write to memory (as opposed to writing directly to a file), so it's easy for you to do whatever you want with sound (e.g. save it to file, cut out quiet parts, filter it with FFT, change format, etc.). Many of the .Net compatible libraries are written to handle in-memory buffers instead of or in addition to files,therefore, having your audio always in memory is a big advantage.

Triggering start and stop recording can be done, although not in the way you might think. With the waveIn * API, you basically start recording from the default audio source, and the API starts filling the memory buffers with the recorded audio. You are notified as each buffer fills up, and then you can do whatever you want with each buffer. To actually write to a file, you can simply scan each buffer as it enters, and if the buffer is empty (does not contain a beep), you simply discard it without writing the contents to the file.



Here is some sample code that shows how to use the waveIn * and waveOut * APIs:

http://www.codeproject.com/KB/audio-video/cswavrec.aspx?msg=2137882

I've actually worked with this project before in C # and it works pretty well.

+4


source







All Articles