I have this type of file: 8000Hz, 8 bits per sample, 64 Kbps, stereo, A-law wav file. I need to decode the alaw compression to 16 bit pcm linear encoding.

I used a lookup table for this from this site http://hazelware.luggle.com/tutorials/mulawcompression.html which gives signed decimal numbers from -32768 to 32767 which corespond to 16 bit signed binary number.

So I can convert signed decimal to signed 16 binary number but how to get left and right channel bytes. As a signed bytes or unsigned bytes?

Or should I convert the signed 16 bit number to unsigned and then get the left and right bytes as unsigned?

  • Do you want an audio program that will convert your WAV files for you, or do you want to know how to code up your own converter? If you want to write code, this is a better fit for stackoverflow. – ObscureRobot Nov 14 '11 at 16:56
  • Found the answer. The bytes from encoded a-law sound are left right left right i.e the fisrt is left the second is right etc and they are signed as it should. No need to convert to 16 bit and than divide two bytes. Just decode with the lookup table in the link above – Vlad Nov 15 '11 at 13:01
  • I thought this is not a question for stackoverflow. – Vlad Nov 15 '11 at 13:02
  • 1
    You should answer your own question and close it, hehe =) BTW: I think what @ObscureRobot meant to say is that this seems more like a programming question than audio/video production. – Johnny Bigoode Feb 7 '12 at 13:14

I found what was the problem. Every byte is left/right left/right etc... in that order. So to explain, a-law compression converts 16 bit pcm value to 8 bit value i.e 8 bits with a special alghorithm are cut of. So in a-law it goes 8 bits left, 8 bit right and so on...

So decoding the pcm value from a-law encoded never gives the original sound. But it is very similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.