While surfing on wikipedia, I found a nice article
about the georgia anthem "Georgia on my mind". There is also an OGG file included of the Georgia chorus sung by the Air National Guard Band of the Southwest.
As I will use this file as a fine example and in fact it is licensed with a Creative Commons License, Attribution 2.5. I state: "This was performed as an exhibition by the Air National Guard
Band of the Southwest, at the Moorpark College
Jazz Festival on May 12
. The vocals are sung by a woman."
For the fastest: Dial 1-678-954-8235 and you'll hear that chorus.
Back to Asterisk.
As I like the state of Georgia I tried to put that chorus on my asterisk server so I could ring it to hear it (ok I won't do it too often but I wanted to have some kind of reason to tell my fiancée that I am sitting again in front of that terminal...).
In the United States, digital voice communications in telephone systems are normally done with the ulaw format using 8000 samples per seconds, 8-bit wide each. It includes a dynamic compression, originally each sample is 16 bits wide. The ulaw algorithm makes a 8 bit sample out of it. Sampling accuracy is high at nearly silent tones and mediocre for louder sounds.
In Europe a similar technique is used, but we call it alaw here, in fact it does the same, it compresses 16 bits to 8. It is very simple to convert ulaw digital data to alaw and vice versa, just use a 255-value-table of compound alaw/ulaw sample pairs.
The first thing to do is to convert the ogg sound file to ulaw (and alaw). I'll use the swiss army knife of sound converters, sox.
sox ANGB_Georgia.ogg -r 8000 -U -c 1 -t raw georgia.ulaw resample -ql
sox ANGB_Georgia.ogg -r 8000 -A -c 1 -t raw georgia.alaw resample -ql
The "-c 1" downmixes the stereo output samples of the ogg file to mono (stereo on a phone system wouldn't really not make any sense), "-r 8000" tells sox to create a 8000 samples/sec output file. "-U" is the selector for ulaw, "-A" for alaw.
After copying these files to /var/lib/asterisk/sounds/pascal, I have been able to define this:
exten => 16789548235,1,Answer(1000)
exten => 16789548235,n,Playback(pascal/georgia)
exten => 16789548235,n,Hangup
So whenever a call comes in to 1-678-954-8235
, you will hear the chorus, as Asterisk answers the phone first, then plays back the file and then hang up the line.
As you can see, Playback uses files relative to /var/lib/asterisk/sounds, (if you installed Asterisk in its standard locations). The file extension ".ulaw" is added automatically. Asterisk uses the ulaw file because it is an american phone line.
To have a usage for my alaw file, I just put it on one of my numbers of my ISDN line in Germany, using alaw. In that asterisk box, I had to define that:
exten => 3614219,1,Answer(1000)
exten => 3614219,n,Playback(pascal/georgia)
exten => 3614219,n,Hangup
Not really exciting, is it? The sole difference between the above US example and this one is the fact it will use the alaw file - German ISDN's voice transmissions are in alaw format.
So for the next days, you will be able to hear that chorus on
1-678-954-8235 (USA) and
(011)-49-7531-3614219 (German ISDN)