2
votes

I'm creating an video chat application but I'm having issues streaming microphone audio. I have video streams working already but I was hoping to find out the best method of capturing a laptop's built in microphone and stream it. At the moment I'm using a NetworkStream for sending the video. I have limited experience with NAudio (http://naudio.codeplex.com/) but every example of microphone capture doesn't seem to include a New Audio Frame event (which is my method for sending video frames).

I've been looking at http://voicerecorder.codeplex.com/ but it seems to be more than I need and doesn't cover streaming.

How do I capture microphone audio and stream it, if possible without the overhead of saving the audio to a file? I'd appreciate a simple example.

1
What is your specific question? - Robert Harvey
Rephrase your question to avoid the word "best." We don't know what's "best" for you because we don't know what your specific requirements are. - Robert Harvey

1 Answers

4
votes
  1. Create a new WaveIn object
  2. call StartRecording
  3. in the DataAvailable event handler, transmit args.BytesRecorded bytes from args.Buffer across the network.

Note that this will mean you are transmitting PCM, which is not very efficient. Normally for network streaming you would use a codec. In the NAudioDemo source code there is a Network Chat demo showing this in action.