windowsgm
windowsgm

Reputation: 1616

Audio Streaming from Microphone

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.

Upvotes: 2

Views: 8799

Answers (1)

Mark Heath
Mark Heath

Reputation: 49522

  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.

Upvotes: 5

Related Questions