Using a Raspberry Pi Micro-Computer for a Broadcastify Feed

This guide outlines the steps I went through to set up a $35 Raspberry Pi (RasPi) computer and “darkice” software to stream scanner audio to A companion guide covers recording and archiving the audio which can be done independently from the darkice streaming.

One benefit of doing this is the power savings. The RasPi uses about 5 watts. In contrast, the old laptop I was using to feed scanner audio used almost ten times the energy and put out a lot of heat. It also had a loud fan. I was paying $42 (US) a year in electric just to run the laptop 24/7. One year of running the silent and cool running RasPi will cost me about $4.40.

The Debian based Linux operating system that is used here is very stable. If you use an Uninterruptable Power Supply and if you have a good internet connection then your feed should have a very solid up-time.

What you need

Raspberry Pi Model B with Raspbian OS, a USB sound card/stick connected to an audio source such as a public safety scanning radio and network connection with a second system for both setup and playback of audio. The USB Sound stick that I am using was only a couple of dollars on ebay:

The script and configuration file that make up this project can be added to your system by copying the text from the referenced web pages and pasting into a text editor on your RasPi. If using Windows then I suggest the “PuTTY” ssh client (right click to paste text in a PuTTY terminal window). 
You can also download them from the File Cabinet page and copy them to the RasPi.  In this guide I assume you are using PuTTY from a Windows system (Win 7 in my case) to establish terminal sessions with the RasPi.

Setup procedure

I used a NOOBs image (v1.3.4). Select, install and configure the Raspbian operating system. From here on you can use SSH to access the RasPi from another computer.

Audio set-up

With your USB sound stick installed, in a terminal on the RasPi run the command 
arecord –l
and note the output. You should see something like this:

**** List of CAPTURE Hardware Devices ****
card 1: Device [Generic USB Audio Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

This indicates that the capture (recording) device is card one. The numbering starts at zero and the on-board audio on the RasPi is card 0 (but it does not have a capture device). In ALSA configuration it is referred to by device and sub-device thusly: “hw:1,0”.

Next connect speakers to the audio jack on the RasPi (not the USB output) and a microphone or other audio input to the USB sound stick. A scanner tuned to NOAA weather with continuous output works well. Adjust the volume to mid level if using a scanner, etc. Then enter:
arecord -D plughw:1,0 temp.wav 
In this case we use the plug-in called "plug" to handle format conversion. Otherwise you could use “arecord –D hw:1,0 somefile.wav but you would need to explicitly set the format to match your sound stick. Using “plughw:1,0” makes life easier.

If using a microphone, speak into it for about ten seconds. Then type “ctl-c” to stop recording. If you hear the audio when you enter the command “aplay temp.wav” then recording on the RasPi and USB device is working. If you don’t hear anything using “aplay temp.wav”, or if it is too soft or is distorted, try using the command “sudo alsamixer” (along with the volume control on the radio) to balance the recording level. After entering “alsamixer” press “F-6” and select the sound card (maybe called generic USB device), then “F-5” to display all controls for that device. Using one scanner I had to turn the scanner up quite loud, then using alsamixer turn on Auto Gain (arrow over to auto gain and press “m” until “00” is displayed). Using a different scanner I had to keep it rather low and turn auto gain off (mute) while keeping the capture level at + 9 dB. It’s fair to say “your mileage may vary.” If despite all this you cannot get decent quality audio then you should suspect a problem with the attached audio hardware, audio cable, etc. Once you have a feed running with good audio level you can save the alsamixer settings between reboots by issuing command, “sudo alsactl store”.

Compile Darkice

The software we will use to “broadcast” the audio to the is “darkice”.

Broadcastify wants a feed in MP3 format but there is no support for MP3 format in the default darkice package for Raspbian, therefore we need to compile it with MP3 support ourselves. Follow the steps described by Steffen Müller in this post to recompile darkice.  A
n easy way to enter the commands is by copying his commands from the web site in Windows and pasting into a terminal on the RasPi.   Be sure to copy the entire lines as many of them scroll off the screen. Feel free to use nano instead of vi for file editing.

When you get to “Change the compile configuration to match Raspbian environment” I suggest that you use the download link for the “rules” file to avoid a common problem with tab feeds preventing the build. The easiest way to do this (instead of doing “vi debian/rules”) is the following. Rename the original:
mv debian/rules debian/rules.orginal
Then copy the link to the rules file from the web page on your Windows system (right click on the link and select “copy link address”). Then in the PuTTY terminal on the RasPi enter the command:
wget –P ./debian
followed by a space and a right click to past the link to the “rules” file (and enter). The required file (called “files”) will download and you can then “cat debian/rules” to verify it has the same text as in the instructions.

For debchange, enter the command 
debchange -v 1.0-999~mp3+1
and then after the editor opens move your cursor to the right of the “*” then type in these words, “New Build with MP3 support.” That should be all you need to before exiting the editor. Your new entry will be on top and you should see that it matches the format of those below it. When it all looks right exit the editor.

Follow Steffen Müller’s directions up to “Now you have installed DarkIce with mp3 support.” Instead of configuring darkice as he has done you can use this configuration file.  
Using sudo, put “darkice.cfg” in “/etc/”.   Then with your chosen editor (sudo nano, vi, etc.) and change the following lines in “/etc/darkice.cfg” to reflect your feed:

server = # use the server you are assigned 
port = 80 # Usually 80
password = passwrd # ENTER your password 
mountPoint = 123456789 # ENTER your mountpoint without leading "/"
name = Anytown FD Dispatch # ENTER name of your feed

Initialization Script (Optional)

Because the initialization script for darkice that is in place after the build was not working for me, I also have supplied an initialization script to run darkice as a daemon. It is based on the skeleton script in the /etc/init.d directory in the Raspbian OS release for the RasPi. It includes a “status” option to see if the daemon is running.  However be warned that this initialization script will run darkice under the root account and that is not compatible with the companion project, "radiosave."  Therefore if you are going to use "radiosave" and darkice streaming at the same time, from the same audio source, then you do not need this script.  If you do decide to use it,  place “darkice” (the init script, not the binary) in “/etc/init.d/”.  Make the init script executable ("sudo chmod +x /etc/init.d/darkice").

Testing the installation

To test darkice start it with this command
sudo /usr/bin/darkice
Listen to the feed and adjust the levels as needed. If all works as expected then “ctl-c” to stop darkice.  If you see this error when running darkice, “…lame lib opening underlying sink error…” then darkice was unable to connect to the server. Check “/etc/darkice.cfg” for the proper entries and make sure the RasPi can access the internet. 

Using darkice

If you decide to use the init script then you can start darkice as a daemon (background process) with command: “sudo service darkice start”. Other options besides start are stop, status, restart, and force-reload. All of these except start and status will interrupt a feed that is in progress.

To run darkice under a regular user account use: "/usr/bin/darkice". If you want to specify a different configuration file use: "/usr/bin/darkice -c /pathto/yourconfigfile". To force it to the background add a space and "&" to the end of the command. The you can use "pgrep darkice" to find the process id, and "kill pgrep darkice" to stop it.

Starting darkice at boot-up (Optional)

To have darkice start at boot using the init script, issue the command: “sudo update-rc.d darkice defaults”. That will create the links to the init script needed to start it at boot-up. If you see this warning, “insserv: warning: script 'mathkernel' missing LSB tags and overrides” then refer to this information. Note however that you should be able to safely ignore the warning.

To start darkice at boot without the init script add a line to your user’s crontab to start darkice at boot under your account.  Issue “crontab -e”, then add this line:

@reboot [ -x /usr/bin/darkice ] && /usr/bin/darkice > /dev/null
Exit and save the file.

Odds and Ends

You will not need icecast if all you are doing is a feed to however there are a few benefits to installing it. One is that it makes it easier to adjust the volume settings by monitoring your feed on a local networked computer rather than while feeding to Another is that you can listen to your feed on your local network instead of the internet. However setting up icecast is not covered here. 

On my system there is a nice feature where I can plug speakers into the USB output and listen to the audio input. Then using “alsamixer” I can mute the speaker and use the mic level (not capture in this case) and speaker level to adjust volume.

Note that I have found that playing audio on the RasPi at the same time as capturing and steaming it with darkice, causes the steam to become unintelligible. This occurs whether darkice is run under the root account or not.

Thanks to Steffen Müller ( This guide is basically nothing more than a rewrite of his guide specifically targeting feeding scanner audio to

The content of this website is distributed under the Creative Commons Attribution - ShareAlike 3.0 Unported license.