<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Music on Hold</title><link rel="stylesheet" href="styles.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /><link rel="start" href="index.html" title="Asterisk™: The Future of Telephony" /><link rel="up" href="asterisk-CHP-13.html" title="Chapter 13. Managing Your Asterisk System" /><link rel="prev" href="asterisk-CHP-13-SECT-5.html" title="Customizing System Prompts" /><link rel="next" href="asterisk-CHP-13-SECT-7.html" title="Conclusion" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Music on Hold</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="asterisk-CHP-13-SECT-5.html">Prev</a> </td><th width="60%" align="center">Chapter 13. Managing Your Asterisk System</th><td width="20%" align="right"> <a accesskey="n" href="asterisk-CHP-13-SECT-7.html">Next</a></td></tr></table><hr /></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="asterisk-CHP-13-SECT-6"></a>Music on Hold</h2></div></div></div><p>Any popular <a id="ch12_musiconhold" class="indexterm"></a>PBX system offers the ability to supply a source of music to be played for callers while on hold. Asterisk allows for a lot of creativity in this regard.</p><p>Nowadays, everyone is familiar with the<a id="I_indexterm13_tt1662" class="indexterm"></a> MP3 music format, and there is a lot of interest in using MP3s as a music-on-hold source. The concept sure seems like a good idea, but there are a few things that we think should be given some consideration:</p><div class="itemizedlist"><ul type="disc"><li><p>MP3 files are extremely complex, and require a substantial amount of CPU to decode. If you have a lot of channels pulling music from the system (for example, people sometimes like to listen to music through their phone, or a call center may have several callers on hold), the load on the CPU caused by all of the transcoding of the stored MP3 files could place too much demand on a machine that is otherwise suitable to the performance needs of the system.</p></li><li><p>Current-generation hard drives hold a lot of data, so there may not be any reason to worry about cutting down hard drive use. Compressed audio makes sense from a distribution standpoint (an MP3 is a much smaller download than the equivalent in .wav format), but once on your system, do we really care how much space they take up?</p></li><li><p>MP3 files don’t usually come with the right sort of licensing. ;-)</p></li></ul></div><p>Taking all of this into consideration, we recommend that you convert your music sources into the native format of the various codecs you may be supporting. For example, if you support μlaw for your internal phones, and G.729 on your VoIP circuits, you will want to store your music in both formats so that Asterisk will not have to perform transcoding to play music to calls on those channels.</p><div class="sidebar"><a id="I_sidebar13_tt1663"></a><p class="title"><b>Free Music</b></p><p>A lot of people do not realize that playing music on hold requires a special license.<a id="I_indexterm13_tt1664" class="indexterm"></a> This is true even if you play music from CDs that you own, or from the radio. To ensure that there is no ambiguity, we recommend avoiding the whole matter and using only music that does not come encumbered with the kind of licenses that the music industry seems to prefer.</p><p>There are many web sites where you can go to get music that is licensed in a manner that is suitable for music on hold. Two that we have found are <a href="http://en.wikipedia.org/wiki/Wikipedia:Sound/list" target="_top">http://en.wikipedia.org/wiki/Wikipedia:Sound/list</a> and <a href="http://www.opsound.org/" target="_top">http://www.opsound.org/</a>.</p><p>Both offer a sizeable collection of music that can be easily downloaded. Note that this may not all be of professional quality, so listen to all of it before you commit it to your music-on-hold collection.<sup>[<a id="id4159252" href="#ftn.id4159252">145</a>]</sup></p></div><p>We often use public domain music<a id="I_indexterm13_tt1665" class="indexterm"></a> (or <a id="I_indexterm13_tt1666" class="indexterm"></a>Creative Commons licensed music) on our systems. Creative Commons music often comes in ogg-Vorbis format <a id="I_indexterm13_tt1667" class="indexterm"></a>(which is conceptually similar to MP3, but not compatible). In order to play <span class="emphasis"><em>.ogg</em></span> or <span class="emphasis"><em>.mp3</em></span> files on our Asterisk system, we are going to convert them to a format that Asterisk can easily handle. This requires the following steps:</p><div class="orderedlist"><ol type="1"><li><p>We need to make sure that SoX, the <a id="I_indexterm13_tt1668" class="indexterm"></a>Sound eXchange utility, is installed. If not, run the following command to install it:</p><a id="I_programlisting13_tt1669"></a><pre class="programlisting">$ <strong class="userinput"><code>yum install sox</code></strong></pre></li><li><p>Download the music that you have chosen to a working folder on your system (<code class="filename">/tmp</code> is probably a suitable location). As an example, the following command downloaded some nice piano music by Pachelbel for us:</p><a id="I_programlisting13_tt1670"></a><pre class="programlisting">$ <strong class="userinput"><code>wget http://upload.wikimedia.org/wikipedia/commons/6/62/Pachelbel%27s_Canon.ogg</code></strong></pre></li><li><p>Now we have to convert the song from ogg-Vorbis format to a format more suitable to Asterisk:</p><a id="I_programlisting13_tt1671"></a><pre class="programlisting">$ <strong class="userinput"><code>sox Pachelbel\'s_Canon.ogg -r 8000 -c 1 -s -w moh1.wav resample -ql</code></strong></pre><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>You may also need to adjust the amplitude with the <code class="literal">-v</code> option.</p></div><p>We’ve now taken our source file, converted it to a .wav file suitable to Asterisk,<sup>[<a id="id4159410" href="#ftn.id4159410">146</a>]</sup> and saved the resulting file as <span class="emphasis"><em>moh1.wav</em></span>.</p></li><li><p>Almost done now. We just need to create a folder for the permanent home of the new files (<code class="filename">/tmp</code> is certainly no place for them):</p><a id="I_programlisting13_tt1672"></a><pre class="programlisting">$ <strong class="userinput"><code>mkdir /var/lib/asterisk/mohwav</code></strong></pre><p>and then move them there:</p><a id="I_programlisting13_tt1673"></a><pre class="programlisting">$ <strong class="userinput"><code>mv *.wav /var/lib/asterisk/mohwav</code></strong></pre></li><li><p>Since we have placed our music files in a different folder from that where Asterisk installs its sample music, we will need to change the configuration file to reflect this. Edit your <code class="filename">/etc/asterisk/musiconhold.conf</code> file with one that contains the <span class="keep-together">following</span>:</p><a id="I_programlisting13_tt1674"></a><pre class="programlisting">[default] mode=files directory=/var/lib/asterisk/mohwav random=yes</pre></li></ol></div><p>As for what to play, that will depend on what image you want to project to your callers. Regardless of your choice, you should keep some things in mind:</p><div class="itemizedlist"><ul type="disc"><li><p>People don’t actually want to be on hold, so they are not usually planning to be there for long. This means that there is not much point in providing them with a mind-expanding musical experience. If things go as they hope, they won’t be there long enough to get into it.</p></li><li><p>The fidelity on a phone system does not allow for accurate reproduction of tones. Heavy bass generally sounds terrible, and high frequencies will typically just end up as noise. Keep the music simple, and it is more likely to sound good.</p></li><li><p>Musical tastes are as varied as people, and while it might be nice to try and cover a wide range of styles, music that is too eclectic is more likely to annoy than enlighten.</p></li></ul></div><p>Classical music addresses all of the above criteria, and it is easy to obtain. It also sounds classy (go figure!), so it is a pretty safe choice, although we’ll admit it doesn’t usually score any points in the hipness department.</p><p>Asterisk includes three songs with the source code download that are licensed for use with Asterisk. These songs are intended as samples. Since there are only three of them, people who call you regularly will quickly tire of them. We have a recurring nightmare in which the worldwide success of Asterisk means that the human race is forced to listen to the same three songs as music on hold.<a id="I_indexterm13_tt1675" class="indexterm"></a> That is why we wrote this section for you.</p><div class="sidebar"><a id="I_sidebar13_tt1676"></a><p class="title"><b>Randomizing Music on Hold</b></p><p>In a traditional PBX, music on hold usually comes from a single source. Everyone that is hearing music is hearing the exact same thing at the exact same time, and even when no one is on hold, the music is still playing. On Asterisk, the music is not playing until a need for it arises, and each caller gets her own music source. If Asterisk were to simply start playing songs in the order it found them, each call placed on hold would always hear the same song starting from the beginning. In order to simulate traditional music on hold, Asterisk can (and normally should) be set to play the music in a random fashion. This means that it will select which file to play at random. If you have enough different songs in your music-on-hold directory, you will minimize the chance that someone who calls frequently will have to listen to the same songs all of the time.</p></div><div class="footnotes"><br /><hr width="100" align="left" /><div class="footnote"><p><sup>[<a id="ftn.id4159252" href="#id4159252">145</a>] </sup>Seed a search with the term “Creative Commons music” to find more freely usable music.</p></div><div class="footnote"><p><sup>[<a id="ftn.id4159410" href="#id4159410">146</a>] </sup>Note that we could have used any format that was compatible with Asterisk; we’ve just chosen .wav for this example because it is easy for the CPU to transcode into μlaw/alaw/slin on the fly, yet remains easy to work with in other environments.</p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="asterisk-CHP-13-SECT-5.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="asterisk-CHP-13.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="asterisk-CHP-13-SECT-7.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Customizing System Prompts </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Conclusion</td></tr></table></div><div xmlns="" id="svn-footer"><hr /><p>You are reading <em>Asterisk: The Future of Telephony</em> (2nd Edition for Asterisk 1.4), by Jim van Meggelen, Jared Smith, and Leif Madsen.<br /> This work is licensed under the <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative Commons Attribution-Noncommercial-No Derivative Works License v3.0</a>.<br /> To submit comments, corrections, or other contributions to the text, please visit <a href="http://oreilly.com/catalog/9780596510480/">http://www.oreilly.com/</a>.</p></div></body></html>