Click here to Skip to main content
13,290,735 members (77,185 online)
Click here to Skip to main content
Add your own
alternative version


333 bookmarked
Posted 3 Aug 2007

Sending and playing microphone audio over network

, 3 Aug 2007
Rate this:
Please Sign up or sign in to vote.
Sending and playing microphone audio over network

Screenshot - view.jpg


This example shows you how to receive data from a microphone and stream it over UDP to another computer. The example application can act like a direct phone, if both endpoints listen for data and send microphone data to each other. One would probably suspect that no source code exists for that, but of course it does. I hate those who will do commercial advertising. There is also a second related project what will contain a UDP server that we need to send/receive audio and compress it with g711 codec.Though only UDP is not the best way to transport audio data, RTP is the right way to go. RTP adds quality of service to transported audio, you can see how many packets are lost and can even arrange disordered packets. I will try to add an RTP example soon, so be calm, it's under way. There are some similar example applications, but most of them aren't well commented and missing some parts, so I will try to fill this part.

The package contains:

  • LumiSoft.Media - Audio related API (Included in example app)
  • LumiSoft.Net - UDP server, G711 codec
  • Example Application

Using the code

  • WaveIn - class provides a simple way to receive audio from a microphone.
    Actually all what you need to do is:
    WavIn.Devices - returns all available input devices from where we can get data.
    /// <summary>
    /// Application main class.
    /// </summary>
    public class Test
        private WavIn m_pSoundReceiver = null;
        /// <summary>
        /// Default constructor.
        /// </summary>
        public Test()
            // G711 needs 8KHZ 16 bit 1 channel audio, 
            // 400kb buffer gives us 25ms audio frame.
            m_pSoundReceiver = new WavIn(WavIn.Devices[0],8000,16,1,400);
            m_pSoundReceiver.BufferFull += new BufferFullHandler 
        /// <summary>
        /// This method is called when recording buffer is full 
        /// and we need to process it.
        /// </summary>
        /// <param name="buffer">Recorded data.</param>
        private void m_pSoundReceiver_BufferFull(byte[] buffer)
            // Just store audio data or stream it over the network ... 

  • WaveOut - class provides methods for playing out streaming data.
    The only thing you need to do is just call waveoutInstance.Play method.
    In my opinion, the whole example application has been coded well enough, so dig into the code.

    Note: Sound quality depends on network delay jittering, if there will be too big a variance in delays, voice will have holes in it. In addition, UDP packet loss and disordered packets will affect it too.


  • 03.08.2006 - Initial release



This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Ivar Lumi
Estonia Estonia
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
Amir Mohammad Nasrollahi10-Aug-13 22:36
professionalAmir Mohammad Nasrollahi10-Aug-13 22:36 
QuestionMemory leaks Pin
allen3311-May-12 18:51
memberallen3311-May-12 18:51 
AnswerRe: Memory leaks Pin
Ivar Lumi1-May-12 19:49
memberIvar Lumi1-May-12 19:49 
GeneralRe: Memory leaks Pin
Member 77299501-Aug-12 2:15
memberMember 77299501-Aug-12 2:15 
QuestionExample Panasonic TDA100D PBX and I want to get the calls records Pin
medop8214-Dec-11 1:18
membermedop8214-Dec-11 1:18 
QuestionPlease help me? About get CDR from PBX? Pin
medop8214-Dec-11 1:13
membermedop8214-Dec-11 1:13 
QuestionStream to two clients Pin
allen33129-Nov-11 18:37
memberallen33129-Nov-11 18:37 
AnswerRe: Stream to two clients Pin
Ivar Lumi29-Nov-11 20:58
memberIvar Lumi29-Nov-11 20:58 
>Is it possible using your library to stream to multiple clients.
Yes you can steream to multiple endpoints.

also you can receive audio from multiple endpoints, but audio mixing is not implemented.
Questionnewbie question Pin
Member 79558493-Sep-11 20:43
memberMember 79558493-Sep-11 20:43 
AnswerRe: newbie question Pin
Ivar Lumi3-Sep-11 20:45
memberIvar Lumi3-Sep-11 20:45 
GeneralRe: newbie question Pin
Member 79558494-Sep-11 7:09
memberMember 79558494-Sep-11 7:09 
GeneralRe: newbie question Pin
Ivar Lumi4-Sep-11 19:57
memberIvar Lumi4-Sep-11 19:57 
GeneralRe: newbie question Pin
Member 79558494-Sep-11 20:20
memberMember 79558494-Sep-11 20:20 
GeneralRe: newbie question Pin
Ivar Lumi4-Sep-11 20:21
memberIvar Lumi4-Sep-11 20:21 
GeneralRe: newbie question Pin
Member 79558494-Sep-11 20:28
memberMember 79558494-Sep-11 20:28 
GeneralRe: newbie question Pin
Ivar Lumi4-Sep-11 20:37
memberIvar Lumi4-Sep-11 20:37 
GeneralRe: newbie question Pin
Member 795584916-Sep-11 2:24
memberMember 795584916-Sep-11 2:24 
GeneralRe: newbie question Pin
Ivar Lumi16-Sep-11 2:29
memberIvar Lumi16-Sep-11 2:29 
GeneralRe: newbie question Pin
Member 795584916-Sep-11 2:38
memberMember 795584916-Sep-11 2:38 
GeneralRe: newbie question Pin
Ivar Lumi16-Sep-11 2:40
memberIvar Lumi16-Sep-11 2:40 
GeneralRe: newbie question Pin
Member 795584916-Sep-11 5:24
memberMember 795584916-Sep-11 5:24 
GeneralDelay in Audio Pin
allen33117-Apr-11 19:04
memberallen33117-Apr-11 19:04 
GeneralRe: Delay in Audio Pin
Ivar Lumi17-Apr-11 20:01
memberIvar Lumi17-Apr-11 20:01 
GeneralRe: Delay in Audio Pin
Zypper22-Jan-12 4:30
memberZypper22-Jan-12 4:30 
GeneralRe: Delay in Audio Pin
Ivar Lumi22-Jan-12 7:14
memberIvar Lumi22-Jan-12 7:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 3 Aug 2007
Article Copyright 2007 by Ivar Lumi
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid