====== Music on Hold ======
**Recording**: https://obviate.io/2012/02/21/recording-high-quality-voice-prompts-for-asterisk/
===== Asterisk Default Class =====
:!: Rename files in ''/var/lib/asterisk/moh/'' to change the order of play.
:!: Default class won't play randomly. If you want random play, create a new class. The default class plays songs in file name order.
===== Legalities =====
http://www.musiconhold.com/musiconhold/legal_issues_with_music_on_hold.php
===== Free Music =====
**Some Free Songs**: http://sonoracomm.com/free_songs/
http://en.wikipedia.org/wiki/Wikipedia:Sound/list
http://www.opsound.org/
===== Performance =====
In order to save significant CPU cycles that might be spent on transcoding MP3 MOH files, it's best to save the MOH files in the native formats you are using.
===== Asterisk =====
http://astrecipes.net/index.php?from=153&q=astrecipes/music-on-hold+without+mpg123
[root@pbx ~]# ll /var/lib/asterisk/moh/Blues
total 20184
-rw-rw-r-- 1 asterisk asterisk 4208640 Jul 1 2008 driftin_blues.mp3
-rw-rw-r-- 1 asterisk asterisk 2379776 Jul 1 2008 kind_hearted_woman_blues.mp3
-rw-rw-r-- 1 asterisk asterisk 6223872 Jul 1 2008 mr._blues_man.mp3
-rw-rw-r-- 1 asterisk asterisk 7819264 Jul 1 2008 still_got_the_blues.mp3
In ''/etc/asterisk/musiconhold.conf'':
[Blues]
random=yes
mode=files
directory=/var/lib/asterisk/moh/Blues
description=Blues Tunes
From Asterisk Console:
moh show classes
moh show files
help file convert
===== ffmpeg to Convert MP3 Files to Native Formats =====
http://www.voip-info.org/wiki/view/Using+ffmpeg+to+convert+Music+On+Hold+files
for f in `ls *.mp3` ; do FILE=$(basename $f .mp3) ; ffmpeg -i $FILE.mp3 -ar 8000 -ac 1 -ab 64 $FILE.wav -ar 8000 -ac 1 -ab 64 -f mulaw $FILE.pcm -map 0:0 -map 0:0 ; done
===== Script to Convert MP3 Files to Native Formats =====
Doesn't work with Karmic sox.
FROMDIR="/root/mp3s"
TODIR="/root/transcodes"
for i in $FROMDIR/*.mp3
do
BASEFILE=$(basename $i .mp3)
echo Converting $BASEFILE
mpg123 -s --rate 44100 --mono $FROMDIR/$BASEFILE.mp3 > $TODIR/$BASEFILE.raw
sox -r 44100 -w -s -c 1 $TODIR/$BASEFILE.raw -r 8000 -c 1 $TODIR/$BASEFILE.wav
sox $TODIR/$BASEFILE.wav -t gsm -r 8000 -b -c 1 $TODIR/$BASEFILE.gsm
sox $TODIR/$BASEFILE.wav -t ul -r 8000 -b -c 1 $TODIR/$BASEFILE.pcm
rm -f $TODIR/$BASEFILE.raw
done