This is an old revision of the document!
External Music on Hold Source
The default Music on Hold (MoH) sound files included with the Asterisk project are adequate for many situations. Custom MoH sound files may be easily added as well.
Alternatively, this topic describes how an external analog audio source may be used as a MoH source for any number of listeners.
Note -> Be certain any external audio source may be freely, legally “re-broadcast” to music on hold listeners.
Required Hardware
USB Sound Adapter (driverless) which provides a “Microphone” input, typically in the $20-40 (USD) range.
Tested USB Sound Adapter's data via “lsusb
”:
ID 077d:07af Griffin Technology iMic (Old original iMic) ID 077d:0420 Griffin Technology (Old original iMic) ID 10f5:0211 Turtle Beach (Turtle Beach Audio Advantage Amigo II) ID 0d8c:0102 C-Media Electronics, Inc. CM106 Like Sound Device (Sabrent USB-SND8)
Edit the “/etc/rc.modules
” file and add the following lines to the end:
snd-usb-audio snd-pcm-oss
The device /dev/dsp
should automatically appear when the USB Sound Adapter is plugged in and the above kernel modules are loaded.
Question -> If my board supports Audio Line-In, can (should) I use it ? Short answer, No. Long answer…
- AstLinux does not include the ALSA sound libraries and utilities required to unmute the Line-In input.
- Typically, onboard audio contains added noise from the nearby digital circuits.
Asterisk MoH Configuration
Create file: /mnt/kd/bin/ast-playlinein
#!/bin/sh # Set VOLUME variable to linearly multiply the volume by a number. # Only define VOLUME if the external audio source's volume cannot be adjusted. #VOLUME="2.0" # Source Sample Rate: 48000, 44100, 16000 SRATE="16000" # OSS sound device CAPTURE_DEV="/dev/dsp" if sox --version >/dev/null 2>&1; then # SoX v14.4.1 or later FOPTS="-b 16" else FOPTS="-w" fi if [ -n "$VOLUME" ]; then FOPTS="-v $VOLUME $FOPTS" fi while [ ! -e $CAPTURE_DEV ]; do sleep 1 done sox -t ossdsp $FOPTS -r $SRATE -c 1 $CAPTURE_DEV -t raw -r 8000 -
Make the “/mnt/kd/bin/ast-playlinein
” file executable:
chmod 755 /mnt/kd/bin/ast-playlinein
Edit the Asterisk configuration file “/etc/asterisk/musiconhold.conf
” and add this context:
[stream] mode=custom application=/mnt/kd/bin/ast-playlinein
Reload the Asterisk MoH module:
asterisk -rx "module unload res_musiconhold.so" asterisk -rx "module load res_musiconhold.so"
Tip -> Never edit the ast-playlinein
script without first unload'ing res_musiconhold.so .
Note -> One “sox” process will always be running, regardless if there are 0, 1 or many users on hold.
Stream music over the internet for MOH
You can also stream music over the internet/LAN for MOH:
musiconhold.conf:
[internet-stream] mode=custom application=/bin/bash /mnt/kd/bin/stream-mp3.sh http://wnycfm.streamguys.com:80/
/mnt/kd/bin/stream-mp3.sh:
#!/bin/bash wget -q -O - ${1} | sox -t mp3 - -t raw -r 8000 -c 1 -