Convert audio files to ulaw for use with a VoIP PBX
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:
- Save as type: Raw (*.snd)
- Click either the Attributes link (old versions) or the Set Attributes and Custom buttons (new versions).
- Encoding: μ-law
Sampling rate: 8000
- If you wish, save these attributes as a preset so that you may easily use it again later.
- 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