TUTORIAL - Using sound card for music on hold and paging / Intercom

crees
Posts: 293
Member Since:
2006-08-09

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



Astawerks
Posts: 44
Member Since:
2007-02-25
Re: TUTORIAL - Using sound card for music on hold and paging / I

cool here is on more from the wiki. I use this all the time when setting up paging on a sound card.
http://www.voip-info.org/wiki/view/Setting+up+paging+with+a+sound...

JB
www.astawerks.com
Hardware sales and support

--

*********************
Astawerks
www.astawerks.com
We have all the New Digium cards in stock
Authorized AASTRA Reseller
Authorized Rhino Dealer
***********************



cooperbran16
Posts: 20
Member Since:
2007-08-13
THANK YOU SOOOO MUCH!!!!!

I have been completely dumbfounded by this problem for days now! Good thing I found this post!



friesen
Posts: 22
Member Since:
2007-09-04
paging

i am currently using the paging set up from http://www.voip-info.org/wiki/view/Setting+up+paging+with+a+sound... as is suggested in the reply to this post. i have read elsewhere in other posts that the MOH through the line in and paging can have trouble working together. i dont want my paging to stop if i use part one of this MOH through the line in set up. can anyone tell me if they will work together ok?



friesen
Posts: 22
Member Since:
2007-09-04
working

ok i got the music on hold working by following the instructions above and this caused a problem with my paging like i had read could happen. i hear the MOH when i dial *51, i was using the method from
http://www.voip-info.org/wiki/view/Setting+up+paging+with+a+sound....
so i set up the method for paging outlined above in part 2. it all works now except it's not real time paging like the first method i used was. it records, then plays when i hang up. this might be acceptable, but is not what we're used to and im wondering if there is a way to get real time again.



mustardman
Posts: 1289
Member Since:
2006-06-18
I kind of like the idea of

I kind of like the idea of record then page. Can that be setup for paging to extensions?



friesen
Posts: 22
Member Since:
2007-09-04
paging speakers and sound card

i wish i could page the speakers and a paging group at the same time, either recorded or real time. anyone know how to set that up?



friesen
Posts: 22
Member Since:
2007-09-04
disappears

i dont know what's happening but the info that i have to add to the extensions_additional.conf disappears after a little while. the paging does work, then it stops and then this info is gone

[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)

include => app-tbpage

exten => 111,1,Answer
exten => 111,n,Wait(1)
exten => 111,n,Goto(tbpage,s,1)



jmullinix
Posts: 837
Member Since:
2006-06-04
Add it to

Add it to extensions_custom.conf instead. Extensions_additional.conf gets re-written every time you click the red (orange) bar in FreePBX.

--

John

In search of Dundi Peers in Lake Wales, FL and Baltimore, MD.
http://www.cohutta.com
1-706-632-3343 - E164 friendly (Use your friendly ENUM trunk today.)
Dial Plan helper http://www.cohutta.com/npanxx.php



friesen
Posts: 22
Member Since:
2007-09-04
extensions_custom.conf

thanks that worked. now if only i could get my other question answered



jades
Posts: 2340
Member Since:
2006-11-26
Anyone had success with this

Anyone had success with this using trixbox 2.4? I cannot get this working at all in 2.4
Thanks

--

Joseph Ades
josephades1_at_gmail_dot_com
(212) 937-4299



kosiara
Posts: 27
Member Since:
2006-07-06
Same here

I followed instructions in Wiki
but I get stuck at step 7 - I don't see those lines in my extensions_custom.conf
Maybe I'm doing something wrong, could someone point me in the right direction?
I'm gonna be in trouble if I don't get this to work.
Thanks



jades
Posts: 2340
Member Since:
2006-11-26
alsamixer isn't a file. you

alsamixer isn't a file. you type it in SSH and you can adjust the sound levels

--

Joseph Ades
josephades1_at_gmail_dot_com
(212) 937-4299



swamarama
Posts: 64
Member Since:
2007-05-11
Dumb question

What advantages do you gain by using a sound card?



SkykingOH
Posts: 9678
Member Since:
2007-12-17
Quote: alsamixer isn't a
Quote:
alsamixer isn't a file. you type it in SSH

It's a program, you can run it from the console or from an SSH session - it is actually a file, just an executable one.

Quote:
What advantages do you gain by using a sound card?

The ability to use an external analog source for MOH.

Scott

--

Scott

aka "Skyking"



jades
Posts: 2340
Member Since:
2006-11-26
I have instructions on my

I have instructions on my website if you want to use the sound card only for music on hold (and not paging)

--

Joseph Ades
josephades1_at_gmail_dot_com
(212) 937-4299



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.