This project has moved and is read-only. For the latest updates, please go here.

Microphone to mu-law

Aug 6, 2013 at 2:39 PM

i'm trying to make an application which sends audio to an Ip Phone. My main problem is that i manage to get audio feed from the microphone (which is in PCM format) and convert it to the ip phone's format which is mu-law.

I've read somewhere that I might need to use a converter (WaveFormatConversionStream), however that works with WaveStreams and all I have is a byte[] which I get as parameter in the OnDataAvailable function. How can I do this to work?
Aug 6, 2013 at 2:41 PM
have a look at the code in the NAudioDemo network chat example. It does exactly this, and goes one layer below WaveFormatConversionStream to use the Acm classes directly, which is probably simpler than trying to create a WaveStream
Aug 6, 2013 at 3:05 PM
Thanks for the fast reply.

I used the Encode function from the MuLawChatCodec.cs which is simpler to use, and I can hear the actual speech but there is a lot of static also. Any ideas?
Aug 6, 2013 at 3:08 PM
the input must be 8kHz, 16 bit, mono. So make sure the input is correct.
Aug 7, 2013 at 8:49 AM
Edited Aug 7, 2013 at 10:01 AM
Thanks, it worked.
Aug 7, 2013 at 9:23 AM
best way to trouble-shoot your problem is to make 2 WAV files
first WAV file just write the audio you record straight to WAV. check that sounds OK
second WAV write the mu-law audio to WAV (with a MU-law wave header). check that sounds OK.