First off, you'll need some form of computer. I decided on an SBC since this is the only job it will be doing and for the small form factor+price+low power. The Raspberry Pi is the obvious choice since it's so ubiquitous and well supported with the kernel and applications. Second, a USB audio input. I used this one from Amazon: https://amzn.com/B00IRVQ0F8
More specific for my client was the fact that they used this audio system for overhead music as well, which required me to get a left/right component cable splitter, that then necked down with another adapter to the 3.5mm for the input into the Pi. This enabled both the amp/overhead speakers and the phone system to pull the same stream of audio.
The rest was done in software.
More specific for my client was the fact that they used this audio system for overhead music as well, which required me to get a left/right component cable splitter, that then necked down with another adapter to the 3.5mm for the input into the Pi. This enabled both the amp/overhead speakers and the phone system to pull the same stream of audio.
The rest was done in software.
To start install Icecast:
sudo apt install icecast2
Go through the install prompts. Make sure whatever password you use for the "source" is what you put in the darkice.cfg file below. Default is "hackme"
Next install Darkice:
sudo apt install darkice
sudo apt install icecast2
Go through the install prompts. Make sure whatever password you use for the "source" is what you put in the darkice.cfg file below. Default is "hackme"
Next install Darkice:
sudo apt install darkice
Create/etc/darkice.cfg in your home dir and add:
[general]
duration = 0 # encoding duration, 0 = forever
bufferSecs = 5
reconnect = yes
[input]
device = plughw:1,0 # USB audio adapter
sampleRate = 44100
bitsPerSample = 16
channel = 2 # 1 = mono, 2 = stereo
[icecast2-0]
bitrateMode = abr # average bit rate
format = mp3
bitrate = 128
server = localhost
port = 8000
password = hackme
mountPoint = mic
public = yes
To start Darkice on boot:
Couple things to mention:
To test, go to the Icecast local page and you should see your mountpoint and stream stats (if a blank page, something's not configured correctly so go back and troubleshoot):
http://<ip address of raspi>:8000
To play, you can click the link to the stream, or open VLC and add a network stream:
http://<ip address of raspi>:8000/mic
Last step is to tell FreePBX how to find the audio stream. Go the "Music on Hold" module, and put the following in the application field:
/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 1024 http://<ip address of raspi>:8000/mic
That's it! A fully functional, auto starting, cost effective, and simple way to convert analog audio into a network stream for your PBX.
- crontab -e
- @reboot sleep 30 && sudo darkice -c darkice.cfg
Couple things to mention:
- The USB sound adapter I used worked the first time with no issues. YMMV. You can find articles troubleshooting this if you have issues. As a hint to see if it's a Darkice issue or the USB adapter issue, try:
- arecord -D plughw:1,0 temp.wav ----> for 5 seconds, then:
- aplay temp.wav
- If the file plays back your sound/music, you know the USB adapter is working fine.
- To find out which USB adapter you need to specify in the darkice.cfg, enter the command
- lsusb
- You might need to play with the microphone gain depending on the source signal strength/volume. Use:
- alsamixer
To test, go to the Icecast local page and you should see your mountpoint and stream stats (if a blank page, something's not configured correctly so go back and troubleshoot):
http://<ip address of raspi>:8000
To play, you can click the link to the stream, or open VLC and add a network stream:
http://<ip address of raspi>:8000/mic
Last step is to tell FreePBX how to find the audio stream. Go the "Music on Hold" module, and put the following in the application field:
/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 1024 http://<ip address of raspi>:8000/mic
That's it! A fully functional, auto starting, cost effective, and simple way to convert analog audio into a network stream for your PBX.
No comments:
Post a Comment