Capture a Microphone Audio Stream Using .NET Framework

前端 未结 2 1971
孤独总比滥情好
孤独总比滥情好 2020-12-15 06:52

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 possibl

相关标签:
2条回答
  • 2020-12-15 07:31

    Maybe not the latest experience, but I remember I was playing with http://nyxtom.vox.com/library/post/recording-audio-in-c.html

    For more professional things you probably need to take a look at DirectSound API.

    Cheers.

    0 讨论(0)
  • 2020-12-15 07:32

    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.

    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.

    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.

    0 讨论(0)
提交回复
热议问题