Asterisk music on hold
Well after many weeks of frustration, sleepless nights and baldness from tearing my hair out, I have finally figured out how to get a few of the cool features of asterisk that generally work in normal asterisk distros such as trixbox, Asterisk @ Home and various others to work in the LMCE install of asterisk.
It seems a common issue with instalations of asterisk on ubuntu systems (which LMCE is built on) that certain parts don't work the way they should due to path issues. Meaning asterisk may be looking in one spot, but that's not where the bits actually are.
So what's this about?
Great question! I have written this page so that those who like me would like to have custom music on hold and system recordings.
Firstly, music on hold, as you may know, when you phone a business or company and you are placed on hold, generally you will hear either music or a radio station playing. Well you can do the same with your home asterisk PBX system like many businesses that have asterisk as their PBX do.
When you recieve a call and during the call you have to put them on hold, either to transfer them to another phone in the house or even just so you don't burn your mac and cheese sitting on the stove, you can add your own custom music that the caller will hear as they sit on hold patiently waiting for you to come back to them (of course they don't realize your mac and cheese are burning down your kitchen)
There is generic on hold music, but it's a little dull and boring, great for a business, but you want something a little more exciting for home.
So, firstly work out what you would like to use. either great 60s or 70s classics, death metal, hard core techno or perhaps something a little more mellow so you don't frighten your caller, really bad if grandma phones and she hears Ramstein!
Now that you have worked out what you wish to use, your files will most likely be in MP3 format to start with. For the audio files to work in your asterisk system you will need to convert your audio file/s to ".sln" This format is quite common in asterisk systems and the same for ".gsm" .
To do this, you will need to first convert your mp3 files to wav.
Steps
1. Get your self an audio converter which converts mp3 to wav. there are pleanty out there, try and find your self a free one. You can also use a wav editor for any audio gurus out there such as Soundforge, Adobe Audition or even a free one called "Audacity" which is simple and easy to use.
2. Log in to the LMCE admin page and navigate to ->Advanced ->Configuration ->Phones Setup, then navigate to "Music On Hold" You will see there is a Catagory in there titled "default" this is where your default music on hold is stored. You have the option to create your own catagories, such as those mentioned above that will either have your best mate shuffeling to techno or grandma freaking because she hears Ramstein while they wait on hold. If you just want to keep it simple and stick with the default section then skip this. For more than the default catagory, click on "Create New Music Catagory" give it a name and there you go.
3. Now you need to transfer the audio files you converted to .wav to the asterisk system (LMCE CORE). I have found that by uploading through the MOH page in the phones setup section, files won't work. To do this, you need WinSCP. It's an ssh based file transfer client which allows you to transfer files between Windows and Linux systems (I should also mention you will need a root enabled account or the root account it self activated to do this, otherwise it complains saying you don't have permission. I enabled my root account because there are certain things I need to do which require "root" rather than just "sudo" such as remote file transfer or editing some config files. To do this, from a terminal window (you can use putty) type "sudo passwd root" This will ask for a new root password and once you confirm it, you can start using the root account to login. If after this process you want to disable back the root account, just lock the root account by running "sudo passwd -l root"
4. Once logged in to your LMCE core, navigate to "/var/lib/asterisk/mohmp3" you will notice 2 files in there, they are the default music on hold audio files that came with asterisk. If you created custom music on hold catagories, you will notice directories in there also. Next navigate to where you saved your audio files and drag them across to the appropriate directory on the remote system.
5. Now we need to go back to our SSH terminal and type "cd /var/lib/asterisk/mohmp3"
- If you have just one audio file type the following command "the-name-of-your-origional-file.wav -t raw -r 8000 -s -w -c 1 the-name-you-want-to-call-your-converted-file.sln" This command will convert your wav file to the .sln format we need to be recognised by asterisk. If you have multiple files use this command "for a in *.wav; do sox "$a" -t raw -r 8000 -s -w -c 1 `echo $a|sed "s/.wav/.sln/"` resample -ql; done" this will find all the wav files in the directory and convert them. If it sits there looking like it's not doing anything, don't worry. It's just running in the background. Leave it to do its work. After it's finnished it will go back to the prompt. "dcerouter_1:/var/lib/asterisk/mohmp3/#"
OK DONE! Now we have all our music on hold files in our system. I'd suggest getting rid of the wav files as it just looks messy. Go back to WinSCP and refresh the remote directory and delete any wav files that are in there.
6. Now we need to give your asterisk system a quick restart so it knows there are new files there. From your ssh terminal run "/etc/init.d/asterisk restart" and bobs your uncle!
7. Now call a phone in the house, place the call on hold and you should hear your new music! cool huh!
More To come
Ok so there are some other cool things you can do which I recently discovered how to get working in LMCE. I'll come back later and update this with the details. But for now enjoy your custom on hold music.