VoIPowering Your Office with Asterisk: Soothing the Savages with Hold Music

Ever hated what you had to listen to on hold? Here's your chance to be the
on-hold disk jockey.

One of the more fun aspects of running an Asterisk server is choosing your own hold music. Hopefully your callers are not sitting on hold for long periods of time, but as long as they are it's nice to give them something pleasant to listen to. It can be music, inspirational speeches, comedy routineseven Internet radio.

Linux comes with all the tools you need to record sound files and convert
them to the Asterisk-friendly .gsm format. Audacity
is an excellent sound recorder and editor that runs on Linux, Macintosh, and
Windows. As fun as it is, we're not getting into sound recording today, though,
just managing existing sound files.

Asterisk versions 1.2 and later includes their own music player, so you can
ignore all the documentation that tells you how to add one. Asterisk can handle
several different sound file formats on its own, but decoding and encoding sound
files eats up CPU cycles, so it's more efficient to convert them yourself.

Converting sound files with lame sox
Using both sox and lame gives you the ability to convert just
about any sound file format. sox does not directly support .gsm
or .mp3, two common formats used in Asterisk. If you do not have these
already installed, install them with this command on CentOS or Fedora Linux:

Different sounds for different occasions
You may create a variety of directories containing sound files for different occasions. This is called creating music classes. Create a new sound files directory, then edit /etc/asterisk/musiconhold.conf to add the new class:

Sound files can go into any directory, as long as you enter the correct directory in the class definition.

Using streaming audio
If you have a reliable MP3 streaming audio source, such as Internet radio, you
can pipe it into your Asterisk hold music. First create an empty directory,
which in this example is /var/lib/asterisk/mohmp3/streaming. Then create
the class this way, using the IP address of the stream:

[streaming]
/var/lib/asterisk/mohmp3/streaming,http://12.34.56.78/

Of course it's never quite this simple, unless you have your own streaming audio server, because the source IP address can be long and complex. See this Nerdvittles article to learn more about hooking up Internet radio to your Asterisk server.