UPDATED 3-3-07
For those who want to use the sound card for both Music on Hold and Paging /Intercom I have put together a promising solution.
This first part is to establish MOH on the sound card
PART 1 Get MOH hold to work by using your mic in or line in
1. use your favorite editor, or config edit and open up the musiconhold.conf
You will mostlikley already have a [default] cateogry. You have a couple of ways of doing this:
A. You can Rename the already [default] category to [default2]
then Add the following into musiconhold.conf:
[default]
mode=custom
directory=/var/lib/asterisk/mohmp3
application=/var/lib/tb-playlinein
B. Or If you would rather this be an option in a dropdown menu Bubbapcguy suggested this, Simply leave the orginal [default] as it was and add this to the conf file
[plyalinein]
mode=custom
directory=/var/lib/asterisk/mohmp3
application=/var/lib/tb-playlinein
this way you can keep your default MOH as it is but then have the option to use the play line in on your Queues etc.
2. Check and make sure In /var/lib/asterisk/mohmp3 there should be at least one mp3 file. (by default there should be songs here unless they have been removed manually) :
cd /var/lib/asterisk/mohmp3
ls
Check and make sure there are at least one music file
3. Now we need to create a simple script for MOH to run when called. Create a script file /var/lib/tb-playlinein by using nano:
nano -w /var/lib/tb-playlinein
copy following 2 lines of code and paste it in nano:
#!/bin/bash
/usr/bin/arecord -q -c 1 -r 8000 --buffer-size=2048 -f S16_LE -t raw
now save your changes (control x) confirm by pushing y and enter to save and quit.
now set ownsship and make it executable but make sure you are in the appropriate directory:
cd /var/lib
chown asterisk:asterisk tb-playlinein
chmod 777 tb-playlinein
4. now we need to allow asterisk to have access to the sound device/files. We will need to create a group called audio and give root and asterisk access to it.
groupadd -g 525 audio
usermod -G audio root
usermod -G audio asterisk
5. In order for asterisk to use the card we will need to add a couple of lines in the amportal startup script. When your TB boots up it will set the appropriate permissions allowing MOH to access the card and play the line in souce. Use nano and add 2 lines of code to accomplish this:
nano -w /usr/sbin/amportal
Depending on your version of TB and settings look for the following line "chown asterisk /dev/tty9" (mine was on line 51) Add the following two lines after but make sure NOT to delete any existing commands above or below:
chown -R root:audio /dev/snd
chmod -R a+rwX /dev/snd
Your finished result should look simular to this plus code on top and bottom :
chown asterisk /dev/tty9
chown -R root:audio /dev/snd
chmod -R a+rwX /dev/snd
now save your changes (control x) , confirm by pushing y, and enter to save and quit.
6. just for the heck of it reboot your pc. This will load the startup script and set the right permissions to access your sound card for the MOH line-in
7. You can then plug into the line-in port or the mic port of your FM-tuner or external audio player (for those of you wanting to use the paging intercom option I prefer to use the mic input). Then you need to configure your mixer to turn on any line in and capturing or any mic or mic capture. to do this launch the following command:
alsamixer
Play with the adjustments to find the appropriate level. Push the M key to unmute any mic line line-in and capture channels and space key to activate your capture channel or mic channel (depending if you are using the mix capture, mic capture or line int capture). Now dial and try MOH and you should start hearing music. BEWARE if your volume adjustments are high you get a blast of loud music!!! so be carefull and dont place the phone inside your ear.
PART 2 Getting Paging to work
First make sure you can get your music to play over your speakers using alsamixer command. Plug your music source (radio cd player, ipod etc) to your mic input (move the fader all the way up). Also Mute your mic gain by pushing m (the mic boost is not needed and will end up blasting your sound if you have it on) after setting this up, If you don't get music playback then you will need to stop here and fix it before you move on or this tutorial will of course not work. to help those who are not familiar with alsa mixer here is a screen shot of it and the levels I have set for it to work to my taste.
UPDATE IMPORTANT you must enable the capture channel (pressing space key) on your alsamixer the screen shot below does not show it, just press the right arrow key untill you see it. ALSO YOU MUST PRESS Esc key to save your changes.
[img]http://www.squarecase.com/images/alsamixer.jpg[/img]
Notice the PCM(your page volume and any other programs that use the soundcard for playback)
Notice in the alsamixer: mic is unmuted and has capture selcted (does not have MM above it) and the mic boot is muted. Also make sure that if you have the option for mic1 and mic2 that you have it selected to mic1(use up or down arrow to change) To select your capture device use the space key. this will allow you to provide only mic source as your music on hold(so your peopel on hold dont here paging :-)
If everything is working continue reading on
1. We need to make another simple script file called tb-page
nano -w /var/lib/tb-page
add these following lines in the file
#!/bin/bash
amixer set "Mic" 80 unmute
sleep 0.25
amixer set "Mic" 60 unmute
sleep 0.25
amixer set "Mic" 50 unmute
sleep 0.25
amixer set "Mic" 40 unmute
sleep 0.25
amixer set "Mic" 20 unmute
sleep 0.25
amixer set "Mic" 10 unmute
aplay /var/lib/asterisk/sounds/page.wav
sleep 0.25
amixer set "Mic" 20 unmute
sleep 0.25
amixer set "Mic" 30 unmute
sleep 0.25
amixer set "Mic" 40 unmute
sleep 0.25
amixer set "Mic" 70 unmute
sleep 0.25
amixer set "Mic" 80 unmute
sleep 0.25
amixer set "Mic" 100 unmute
now save your changes (control x) confirm by pushing y and enter to save and quit.
now set ownsship and make it executable but make sure you are in the appropriate directory:
cd /var/lib
chown asterisk:asterisk tb-page
chmod 777 tb-page
Ok now we are ready to modify the dial plan.
This method will allow you to dial a number (in this case 111 which you can change to whatever you want) and then it will do a beep. You then say the mesage, hang up and then it will play back the page via the alsamixer (PCM channel) through the sound card speaker output. However you will need to use the mic-input for your music source for it to work effectivly (and also have your mixer settings set right) This setup will also allow your MOH to work without your callers hearing the page.
First open up extensions_additional.conf in the configedit program on your TB web management. Go to the bottom and add these lines
[tbpage]
exten => s,1,Record(page:wav)
exten => h,s,System(/var/lib/tb-page)
[app-tbpage]
include => app-tbpage-custom
exten => 111,1,Answer
exten => 111,n,Wait(1)
exten => 111,n,Goto(tbpage,s,1)
Now you must add one line to the [from-internal-additional] (located at the end of the conf file). You must add the line before the "exten => h,1,Hangup" statment. The following line will load the extentnion into asterisk.
include => app-tbpage
Find the [app-speakingclock] context and add the following lines after the "exten => *60,n,Hangup" but before ";end of [app-speakingclock]"
exten => 111,1,Answer
exten => 111,n,Wait(1)
exten => 111,n,Goto(tbpage,s,1)
make sure that in alsamixer you have the channels unmuted like the PCM channel and adjust it to the right level (the page volume). Also set any master volume levels etc.(just like you would on a windows volume mixer)
OK you should be all set to go. plug the source music into your mic-in, plug your speakers or paging amp into the speaker output. Push play and start hearing your music over your Speakers (what? dont want music over the speakers? Simple, Just turn down your mic volume to 0. Since its being captured it will still alow music to pass to your recording tb-playlinein app for MOH.) now dial 111 or whatever you set your ext number for paging to be and test. you should hear the music fade then page then the music volume will come back.
ENJOY!
MORE INFO
Some other things you can do is supply the tb-page with arguments and pass them as varaibles for volume levels or even lenth of timing.
If you use this in a high usage area you may wish to add to your paging ext the ability to ring busy if someone is already paging. Basically this will prevent problems with simultaneous page.
Hope this helps - any questions? post here or email me at crees (at) bearrivernet (dot) net

Member Since:
2006-08-09