RadioReference on Facebook   RadioReference on Twitter   RadioReference Blog
Wiki Home
View source

Personal Tools

Search the Wiki


Live Audio/Ubuntu Darkice


HOWTO - Ubuntu Darkice Configuration for Live Audio Feeds


This page describes the configuration for Ubuntu Linux 9.04 for darkice stream feeds for RR Live Audio feed provisioning. This should work in a generic sense for most any linux distribution using darkice, but contains some Ubuntu specific instructions for installing the packages needed to get things rolling.

Pre-Requisite Assumptions

This HOWTO makes an assumption that you already have your input device, either mic or line-in configured as a capture device in the mixer and that your capture levels are high enough to get audio feeding into /dev/dsp (the OSS sound device).

In linux, your capture level is the level that will feed into the stream, this is where you wind up with either excessive hiss from too low an output from the scanner and too high a capture input boost or you can get distortion on the feed from too high a drive from the scanner ouput and/or too high a capture level drive.

I recommend a healthy level of output from the scanner/radio device and backing down the capture level to about 1/2 or until the feed is not distorted from the loudest level from the scanner/radio input device.

To monitor locally the 'mic' slider is the one that will output to the PC speakers, this won't affect the actual drive level to the capture device and the feed output itself.

EDIT FROM USER - As of LTS 10.04 and Beta 10.10 - Ubuntu no longer uses the OSS sound system; and I was not able to get Darkice to work with the new sound drivers. Work-arounds appear to be a) use an older (9.x) Ubuntu distribution or b) recompile the kernel to support OSS. I'll admit it - I took the easy-way out, and downgraded to 9.10, as I had a disc handy; the kernel rebuild option was suggested by others via Google. RECENT EDIT FROM USER: As of 16.04, the best way to map your device to DarkIce, is to use device = default. Unless you have some configuration that takes you away from the default setting.

Packages needed

Darkice - This will take the audio feed captured, transcode it and direct the stream to the icecast/shoutcast service you are publishing to. This takes audio and converts it to mp3 stream format.

To fetch the package

Open a terminal window of your choosing.

Update your current list of packages.

sudo apt-get update

Fetch and install the software.

sudo apt-get install darkice screen

The 'screen' package will become more obvious later. It is merely an alternate way to run the darkice process in the background.

This should take care of the installation of the packages themselves and the supporting documentation. It's just that simple.

Darkice configuration

Documentation for darkice can be viewed a few ways.

man darkice 

shows the command line syntax for starting darkice

man darkice.cfg

shows details for the config file syntax

Pointing a browser at


Just cut/paste this as though you are going to a web site http:// in front. This is the location of the sample config file in /usr/share/doc/darkice/examples/

First step is to create your own configuration file or darkice won't do much of anything for you.

Here is a starter file for you. You can cut and paste this in or just copy it and create a file named darkice.cfg. The file name is not important, you can call it whatever you want.

Darkice Configuration File

# sample DarkIce configuration file, edit for your needs before using
# see the darkice.cfg man page for details

# this section describes general aspects of the live streaming session
duration        = 0        # duration of encoding, in seconds. 0 means forever
bufferSecs      = 1         # size of internal slip buffer, in seconds
reconnect       = yes       # reconnect to the server(s) if disconnected

# this section describes the audio input that will be streamed
#device          = /dev/dsp  # OSS DSP soundcard device for the audio input COMMENTED OUT
device            = default # best configuration as of Ubuntu 16.04
sampleRate      = 22050     # sample rate in Hz. 22050 is the RR Standard
bitsPerSample   = 16/32     # bits per sample. 16 for mono feeds, 32 for stereo feeds
channel         = 1 or 2    # channels. 1 = mono, 2 = stereo

# this section describes a streaming connection to an IceCast server
# there may be up to 8 of these sections, named [icecast-0] ... [icecast-7]
# these can be mixed with [icecast2-x] and [shoutcast-x] sections
# If you want to send to your own icecast server, you basically copy
# this whole section and put in the values to point the feed to your own
# server instead of the RR information below
# Don't forget, the name [icecast2-0] needs to change to [icecast2-1]
# and 2 and 3 as you add more feed destinations.
# The audio format to encode to, we're using mp3 here
format          = mp3

# The bit rate mode to use, the commented out lines are for a fixed bit
# rate "constant bit rate" at 16 bits.  I prefer the variable bit rate
# for the sound quality it has and the throughput is very similar on avg

#bitrateMode    = cbr (do not use vbr)
bitrate        = 16 or 32 # (16 for mono feeds, 32 for stereo feeds)

bitrateMode     = cbr # (do not use vbr)

# Quality at .1, max is 1.0, but as you increase, so does the bandwidth
# used.  For mono scanner audio .1 is totally fine.
quality         = 0.1

# Takes the input and mixes it down to a mono output for the feed.
channel         = 1

# Cuts frequency response over 5kHz.  For scanner feed this mostly
# eliminates hiss and harshness on paging tones.  Saves a bunch of
# bandwidth as well.
lowpass         = 5000

# Server shown on your RR feed owner page that hosts your feed
# You need to log in to RR, go to Account -> My Live Audio Feeds ->
# click the feed owner page icon at the far right of your feed listing.
# Then you will see all this information.

# From Feed Technical Details, the "Server"
server          = audio? FROM_YOUR_RR_FEED_PROVIDER_PAGE

# From Feed Technical Details, the "Port"
port            = 80      # port of the IceCast server, usually 8000

# From Feed Technical Details, the Password exactly as shown

# From Feed Technical Details, the mount...remove the leading "/", it's
# not needed in this file.  So if it is /999999 make it just 999999

# name of the stream
# On My Live Audio Feeds, it's the first part ending in a colon ":"

# On My Live Audio Feeds, it's the part in parentheses in the Feed name

# I don't think this is really needed because RR takes care of links
url             =
genre           = Scanner
public          = yes

Now we have a base configuration for darkice.

Another approach:

Sample config file for Darkice using ALSA on Ubuntu using the model HY552 USB 3D Audio Sound Card:

Find the ALSA device source:

$ aplay -l 
card 1: Set [USB Headphone Set], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

This means your device is hw:1,0, which you can use in the config file below:

duration = 0
bufferSecs = 10

device = hw:1,0
sampleRate =  22050
bitsPerSample = 16
channel = 1

bitrateMode = cbr
format = mp3
bitrate = 16
channel = 1
lowpass = 5000
sampleRate = 22050
server = audio?   (change the ? to the server number)
port = 80 (or try 8000)
password = xxxxxxxx  
mountPoint = 12345678
name = Name of your feed here as listed on your feed page.

Now execute Darkice in the background:

darkice -c darkice.cfg

Starting Darkice

To start darkice, you simply have to do

darkice -c /path/to/darkice.cfg

If you don't use this computer for anything but serving this feed, you can ensure the highest quality of streaming by running darkice as root so it will get the highest time priority possible on the system. I DO NOT recommend doing this if you use the system for anything else, as it will bog it down a fair amount. If you do want to do this, change the command to.

sudo darkice -c /path/to/darkice.cfg

This should begin your stream if you have all the configuration parameters correct. Connect to your stream link and give it a bit until the latency catches up to test it. With a scanner, it may be a good idea to just open the squelch or put on NOAA so you have something with constant output to test the stream.

Now that you have it working, you need to be able to leave it running unattended if you log out of your machine.

Stopping and managing Darkice

Stop darkice by typing the following in the terminal you started it in.


This literally means to hold down the ctrl key and hitting c while you hold it down. It is a 'break' sequence and stops the current running process in the terminal session.

Now start screen. This will open a 'virtual' window that will hold the running process.


This will drop you to a command prompt again, so now start darkice again

darkice -c /path/to/darkice.cfg

And now it's running inside a virtual window 'screen' session. So let's get out of this and go about our business. You want to 'detach' the screen session, so type the following.

ctrl-a d

This is in literal, hitting ctrl key, pressing 'a' while doing so, then releasing and hitting 'd' to 'detach' the screen session and return to the main terminal session.

Now you are 'outside' the screen and can log out of the system and darkice will continue to run.

If you want to re-attach to the screen session, you do the following

screen -dr

This should bring you back to where you left darkice running. You'll see any error output generated if any and you can stop it if need be by typing


There are a bunch of useful pages via on how screen works. It's a great utility to know and understand.

You can of course make a systemwide init script so that darkice starts when the system reboots or you stop and start your system, but that's a bit beyond the scope of this article.

Example Init Script

So...I've found that this script information below doesn't work reliably on bootup. I haven't been able to isolate why. Once the system is up and running it works fine if invoked manually, but possibly the sound system isn't up 'enough' for darkice to work during the boot sequence.

My 'fix' for this is a cron job as root that runs every 15 mins. Checks to see if darkice is running and if not, it starts it. This has been reliable through the many power failures I've been having lately.

The following information will work, but not automatically at boot as it is supposed to.

This script can be cut and pasted as /etc/init.d/darkice , this will enable you to automatically start your darkice stream when the system is rebooted. This will also allow you to start and stop it cleanly as you need to when the system is already up by issuing the following commands.

sudo /etc/init.d/darkice start    -- to start it
sudo /etc/init.d/darkice stop     -- to stop it

To enable the script with the runlevel links you need, you can execute the following command and it will take care of all the default linking. This will push darkice to start after everything else on the system is up...this is important as obviously your networking needs to be up first or it will not work. You will also need to stagger darkice after icecast2 if you are running your own copy of that service.

sudo update-rc.d darkice defaults 99

Here's the example config... cut and paste this as /etc/init.d/darkice as root..via sudo

This will run darkice as your local user inside a screen session. The reason I like using screen for processes like this is simply that you can re-attach the screen session and see any error output from the process.

#!/usr/bin/env bash

# init script for starting darkice streaming on system boot
# Define the variables to suit your individual system install
# and link this script to the appropriate run level for your system.
# Author: KC2RGW
# Date: 23 October 2009

# Define a basic path for the script to run
export PATH


# Where darkice lives

# Full command to start darkice 

# The system username you wish your darkice binary to run as
# basically, your username.

# The screen utility, it will be used to give a terminal to the 
# running server process

# Options to pass to screen.  These will detach the session upon
# invocation and name it as 'darkice_stream' 

SCREENOPTS="-d -m -S darkice_stream"

case "$1" in

               #Test for the server binary
               if [ -x "$DARKBIN" ] ; then
                  echo "Can't find $DARKBIN are you sure it is installed?"
                  exit 1

               #Test for the darkice config
               if [ ! -f "$DARKCONFIG" ] ; then
                  echo "Can't find $DARKCONFIG is it there?"
                  exit 1
               #Test for your 'screen' utlility binary
               if [ -x "$SCREENEXE" ] ; then
                  echo "Can't find $SCREENEXE is it installed?" 
                  exit 1

               #Test for an already running qs1rserver instance
               if (su "$DARKUSER" -c "$SCREENEXE"' -ls | grep darkice') ; then
                  echo "Already found a screen session with darkice running!...exiting"
                  exit 1

               # Change to the directory where the server is and start it
               su "$DARKUSER" -c "$SCREENEXE"" $SCREENOPTS"" $DARKCMD"


               # Check for the pid of running instances and kill it
               # If there is more than one...kill those too
               if (su "$DARKUSER" -c "$SCREENEXE"' -ls | grep darkice') ; then
                 for PID in `su "$DARKUSER" -c "$SCREENEXE"' -ls | grep darkice' | awk '{print $1}' | cut -d . -f1` ; do
                     kill $PID; done
                   exit 0
                  echo "No instances of $DARKBIN found running..."
                  exit 1

               echo "This starts the Darkice server"
               echo "Use: $0 start|stop"

Copyright 2019 by LLC Privacy Policy  |  Terms and Conditions