MOH File formats

Hi All,

I’m trying to convert some MP3s to something that my 1.4 Asterisk can play.
I’ve started by converting the MP3s to wav and normalising using MediaMonkey.

Then using SOX, I can create the basic 8khz, mono .sln/.gsm files, but, most of my internal devices are HD audio capable (eg Yealink T22). So I’d prefer to create formats/qualities appropriate to them as well. I’ve tried using sox for creating-t ul and -t al (ulaw/alaw) formats, but I think its the bitrate I’m messing up.

If I do a show channel command on a call, it tells me that the MBR for most of my calls is 384kbps.

If I try using something like -r 64k instead of -r 8k it just gets put to 50% speed.

So I’m scratching my head on how to create files that internally would sound quite good, but externally would be 8khz.

Any ideas ?

G.711 at 384kps has a sample rate of 48kHz, not 64kHz. (I’m not sure if it is actually G.711 at anything but 8kHz.)

To get the best audio at 48kHz, you will need to do the A/D conversion at 48kHz, rather than trying to resample from some other rate.

Also note that if Asterisk has to resample, it’s really hard, computationally, on the CPU.

…except for moving between G.722 and G.711, there’s a direct path for that.

Am I right in thinking as well that 1.4 can’t do 16kbps ??

I keep seeing references to running a convert from sln16 to g722, but, Asterisk complains about the RIFF header missing in my wav file that I present it after sox is used.

Then I saw a post saying that 1.6 onwards (or 1.4 patched) could support 16,32,64.

My idea was to load up .sln, .ulaw, .alaw, and now .g722 files so that it had a wide choice. Now I’m understanding that .sln, .ulaw/alaw seems to be 8bit/8kbps only - is that right ?

1.4 doesn’t transcode G.722. IIRC it’ll pass-through, but that’s it.

Support for slin greater than slin16 is in Asterisk 10 and newer only.

ulaw and alaw are 8kHz. slin is 8kHz.

slin16 is 16kHz.

Here’s some more info: … io+Formats

G.711 (A- and Mu-Law) is fundamentally 8 bits (14 bits of dynamic range piecewise linear logarithmically companded to 8 bits). I don’t have access to the ITU documents, but it would have been designed for 64kbits/s use, to encode analogue carrier quality audio (300Hz to 3.4kHz).


I’m starting off with WAV files that are 44.1KHz, mono, but up at around 700Kbps out of Mediamonkey.

I’m then trying various formats, eg:

sln: sox -t raw -r 8000 -e signed-integer -b 16 -c 1
wav8: sox -r 8000 -e signed-integer -c 1
gsm: sox -r 8000 -c 1

All of which of course sound bad because they’re at 8kbps.

Is there anything I can do to improve them on Asterisk 1.4 ?

None of those are 8kbps. The nearest is GSM, at about 13.6, but that is vocoder based and unsuitable for normal music. I don’t think Asterisk understands wav8, as it is lower quality than the PSTN, but that would be 64kbps. The SLN is 128kbps and exceeds PSTN quality. It is 16kBps. Sampling at anything other than 8kHz gives no advantage when the PSTN is involved.

To get beyond PSTN quality, you need a codec that is supported by both the phone and Asterisk. I can no longer remember what is supported by Asterisk 1.4, which is obsolete, but I think it supports at least -r 16000 -w -s, although I don’t think that is supported by the SIP interface.

slin is supported by some phones, e.g. Digium phones, but it’s not a good idea for a codec, since it consumes 128kbp/s of bandwidth. slin16 doubles that to 256kbit/s, so it’s even more heinous - and it doesn’t sound perceptibly different from G.722.

Another note…most codecs were designed for carrying human speech, not music. So, MoH over G.729 is particularly icky.