Convert audio files to ulaw for use with a VoIP PBX

January 21st, 2015 Leave a comment Go to comments

Converting high quality audio files to ulaw is easy, but making them sound good takes some effort.  Keep reading for the technique we use.

engineercarl on DSLReports provides some excellent advice for preparing audio for conversion to ulaw so that as much quality as possible is maintained.  The tl;dr is thus:

  • Filter out all audio below 300 Hz and above 3000 Hz.
  • Volume levels should reach no more than -12 dB.

These points are relatively easy to satisfy with most audio editors.  If your audio editor of choice cannot save directly to ulaw, or does not do a good job of it, save your project as a high quality uncompressed file and convert it to ulaw.

We experienced a wide range of results converting ulaw files with various pieces of audio manipulation software - ranging from very poor to excellent.  (We do not have a copy of Adobe Audition to experiment with, as Carl uses.) We've used sox and ffmpeg in the past, but discovered today that GoldWave produces better audio quality.  Open your high quality uncompressed file with GoldWave, and save it with the following configuration:

  1. Save as type: Raw (*.snd)
  2. Click either the Attributes link (old versions) or the Set Attributes and Custom buttons (new versions).
  3. Encoding: μ-law
    Channels: 1
    Sampling rate: 8000
  4. If you wish, save these attributes as a preset so that you may easily use it again later.
  5. Save the file, then rename the extension from *.snd to *.ulaw.

The files are now ready for use with Asterisk or any other VoIP PBX.  If you have a great deal of files to do, you may use GoldWave's Batch Processing feature.  From a Windows command prompt, you may batch rename files using rename *.snd *.ulaw

In case anyone wants to use sox or ffmepg to convert audio files to ulaw, the commands are as follows:

ffmpeg -i input.wav -ar 8000 -ac 1 -ab 64k -f mulaw output.ulaw
sox input.wav -r 8000 -c 1 -t ul output.ulaw

  1. Adam W
    July 18th, 2011 at 09:36 | #1

    Life.  Saver.  🙂

  2. Ivan
    April 10th, 2012 at 11:18 | #2

    Couldn't help to stop by to say thanks. I had some gsm files that I wanted to convert to ulaw, and the second line worked for me.

If you would like a reply to your comment, you must leave your email address! We receive dozens of questions every month from people who don't leave us with any way to contact them, so we have no choice but to ignore the question. We try to reply to as many questions as we can, if we know the email address of the person who asked the question. Thanks in advance for writing in :)

Allowed HTML: <b>, <i>, <em>, <strong>. All other < and > will be replaced with &lt; and &gt;.