This project has moved. For the latest updates, please go here.

Microphone to mu-law

Aug 6, 2013 at 1:39 PM
Hi,

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?
Coordinator
Aug 6, 2013 at 1: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 2: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?
Coordinator
Aug 6, 2013 at 2:08 PM
the input must be 8kHz, 16 bit, mono. So make sure the input is correct.
Aug 7, 2013 at 7:49 AM
Edited Aug 7, 2013 at 9:01 AM
Thanks, it worked.
Coordinator
Aug 7, 2013 at 8: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.