Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
If you plan on selling Asterisk-based telephone systems and you do not change the default music on hold that ships with Asterisk, you are sending the message, loud and clear, that you don’t really know what you are doing.[56]
[56] Note that Leif uses the default music, but his excuse is that he’s lazy and wants to go and play Forza on his Xbox. The cobbler’s kids have no shoes.
Part of the problem with music on hold is that while in the past it was common to just plug a radio or CD player into the phone system, the legal reality is that most music licenses do not actually allow you to do this. That’s right: if you want to play music on hold, somebody, somewhere, typically wants you to pay them for the privilege.
So how to deal with this? There are two legal ways: 1) pay for a music on hold license from the copyright holder, or 2) find a source of music that is released under a license suitable for Asterisk.
We’re not here to give you legal advice; you are responsible for understanding what is required of you in order to use a particular piece of music as your music on hold source. What we will do, however, is show you how to take the music you have and make it work with Asterisk.
Getting Free MusicThere are several websites that offer music that has been released under Creative Commons or other licenses. Lately, we’ve been enjoying music from Jamendo. Each song may have its own licensing requirements, and just because you can download a song for free does not mean you have permission to use it as music on hold. Be aware of the licensing terms for the music you are planning to use for your music on hold. |
It’s quite common to have music in MP3 format these days. While Asterisk can use MP3s as a music source, this method is not at all ideal. MP3s are heavily compressed, and in order to play them the CPU has to do some serious work to decompress them in real time. This is fine when you are only playing one song and want to save space on your iPod, but for music on hold, the proper thing to do is convert the MP3 to a format that is easier on the CPU.
CentOS PrerequisiteSince CentOS does not have MP3 capability installed with sox, you will have to install mpg123 before you can convert MP3 files for use with Asterisk. First you will need to install the rpmforge repository. To find out which version you need, open your web browser and go to http://dag.wieers.com/rpm/FAQ.php#B. Select the text for the version/architecture you want to install and paste it into your shell: $ rpm -Uhv http://apt.sw.be/redhat ... You need to make sure this new repository is used correctly, so run the following: $ yum install yum-priorities (If you want to know more about yum priorities, see this site: http://wiki.centos.org/PackageManagement/Yum/Priorities.) Once the repository has been added, you can proceed to get mpg123: $ yum install mpg123 Once that’s done, your CentOS system is ready to convert MP3 files for use with Asterisk. |
If you are familiar with the file formats and have some experience working with audio engineering software such as Audacity, you can convert the files on your PC and upload them to Asterisk. We find it is simpler to upload the source MP3 files to the Asterisk server (say, to the /tmp folder), and then convert them from the command line.
To convert your MP3 files to a format that Asterisk understands, you need to run the commands outlined here (in this example we are using a file named SilentCity.mp3).
First, convert the MP3 file to a WAV file:
$ mpg123 -w SilentCity.wav SilentCity.mp3
Then, downsample the resulting WAV file to a sampling rate that Asterisk understands:
$ sox SilentCity.wav -t raw -r 8000 -s -w -c 1 SilentCity.sln
If you have not done so already, install sox, and the libsox-fmt-all package:
# sudo apt-get install sox libsox-fmt-all
Then, convert your MP3 file directly to the uncompressed SLN format:
$ sox SilentCity.mp3 -t raw -r 8000 -s -w -c 1 SilentCity.sln
Note:
In newer versions of sox (e.g., version 14.3.0, which shipped with Ubuntu 10.10), the -w option has changed to -2.
The resulting file will exist in the /tmp folder (or wherever you uploaded to) and needs to be copied to the /var/lib/asterisk/moh folder:
$ cp *.sln /var/lib/asterisk/moh
You now need to reload musiconhold in Asterisk in order to have it recognize your new files:
$ asterisk -rx "module unload res_musiconhold.so" $ asterisk -rx "module load res_musiconhold.so"
To test that your music is working correctly, add the following to the [UserServices] context in your dialplan:
exten => 664,1,NoOp()
same => n,Progress()
same => n,MusicOnHold()