Internet Radio (with some Raspberry Pi)
User Rating: / 4
Written by Bryce Ringwood   

( Revised to be compatible with "wheezy" image. "Squeeze" image commands are greyed out )

This article was inspired by an Elektor "Internet Radio" project published in 2008. It is available on the web from Elektor. If you simply want to get a music centre up-and-running please look at xbmc. This will also play internet streams.

Most people reading this will already have an internet radio - although not everyone may realise that fact. These days, nearly every smartphone has an "app" for it (see inset) and every PC has the potential to become an internet radio through the use of "WinAMP", or software such as "RadioSure","Phonostar"and many others. There are also physical devices, such as the SOVOS SVWFPIR Internet/FM radio, for example, which looks and feels like a normal "tranny". Other internet radios are thinly disguised computers.

The Merits of Internet Radio

Nokia Internet RaddioFor the consumer, the greatest advantage is the vast choice that is offered. There must be well over 50 000 stations available, with every conceivable genre in all the world's languages. Reception is generally interference free - although there can be random breaks in transmission, rather like a dirty CD. Reception quality varies, but is generally as good or better than stereo FM broadcasts. Reception can be from any country in the world, and the broadcasts often carry additional information about what is being played. Like normal radio, internet radio is a continuous stream of audio that can't be paused or interrupted, as distinct from a podcast, which is an on demand broadcast.

For the webcaster (analogous to broadcaster in conventional radio terms), very low power is required and the broadcast can reach anywhere in the world where the internet is permitted. If you are contemplating setting up an internet radio station you will have to find a suitable service provider. You will be sending a continuous stream of music (or other content) to his server. The content has to obey applicable laws, but, as far as I know, does not have to have any involvement with ICASA. Your service provider should know the rules. I should add that many South African radio stations are not receivable on several of my internet radios. They are not even represented on a "portal" - so my Sovos radio can't even see they are there, nor can my Nokia phone. The moral of the story being - be sure you are going to use a widely accepted protocol and format. 

Internet Radio Problems

The most obvious problem is "no internet - no radio". A repressive government can switch the entire thing off very easily. Removing short-wave broadcasts involves setting up jamming equipment, as has been done in Zimbabwe. It might be good to keep a valve shortwave radio somewhere - just in case. Valves are less susceptible to emp than transistors.

Internet radios operate by contacting a "portal", such as "vtuner" in the case of the Sovos radio, which acts as a directory so that the radio can look up the stations you want and then play them. Products like "Radiosure" and the Nokia phone have their own directories. This is to make things a bit easier to use. You will remember "Radio Caroline, but you won't remember - which is where the stream originates, unless you are a savant.

The problem is that not all portals have the station you want to listen to. Some stations seem to be findable on just about any portal - Radio Caroline" being one of them.

Many conventional broadcasters in South Africa can be played from their own web-site, but are either not discoverable on an internet radio, or even if they are, cannot be played because they are using an unusual format. 

Finally, the internet radio will sometimes simply not work for no apparent reason on a particular network. It may start working at a later date. This happened to me at work where I am sysadmin.

Of course, you should not use internet radio at work because it consumes bandwidth for non-business purposes. This brings us to the final disadvantage - the cost to the consumer. Remember if you use Internet radio for 7 hours a day, 7 days a week, you can easily consume :

96000 bits/sec*60*60*7*30/8 = 9.072 Gb - assuming a 96kb/s streaming rate.

Obviously, this is not too good if you are using a smartphone and data bundles. Having said that, some smartphones have an FM transmitter, so you can select the BBC on your smartphone internet radio app, and transmit to your car radio on an unused FM frequency (if you can find one!). Most people will probably use up to 2 Gb, which will not be too expensive on a normal internet contract.  

Internet Radio using MPD on the Raspberry Pi

Before I begin, I would like to acknowledge the very good article on the Vladimiro Casinha web site. Let's begin by looking at some of the components and other resources we are going to need to use the RPi for internet radio.

Internet Connection

First of all, we will need an Internet connection. In my case this is a network cable connected to an iBurst router with a USB modem plugged into it, so the connection really is "wireless". It might be possible to plug the iBurst modem directly into the Raspberry Pi USB port, but it would require some drivers from iBurst. There are WiFi dongles that work with the Raspberry Pi.

Speakers and Sound Card

It is possible to use the RPi with an external USB sound card. I decided not to do this and used the built-in sound card. The speakers plug into the stereo jack (black socket). Please DO NOT plug low resistance stereo headphones directly into this socket you may overload your computer or its power supply. Or both. If using headphones through the speaker amp - TURN THE VOLUME DOWN LOW NOW. You have been warned.


MPD stands for "Music Player Daemon" . A daemon is a being who works tirelessy at some task without being noticed. The physcist James Clerk Maxwell proposed daemons that could separate fast moving or "hot" molecules from "cold", thereby creating a heating or cooling effect with very little energy input. Daemon is an alternative spelling to the more familiar "demon". The MPD software is a piece of software that sits in the background converting an input stream to audio output.

Note that an input stream is used here a little inaccurately to refer to a stream of data that can come from a file or from an internet location.

Because MPD just sits working in the background, it has no user interface and requires client software to talk to it. This is provided by MPC.


MPC is the "Music Player Client". It can be used to manage playlists - including lists of radio stations. It is the user interface for MPD - but it is possible (even desirable) to write a client that carries out tasks more appropriate to Internet radio. MPC has to be very general.

ALSA Utilities

These utilities control the sound card. Such things as volume, balance (if stereo) - and so on.

Linux Commands

I will try to introduce some of these as we go. Before I retired x years ago, the big boss decided the entire organisation was to ditch Microsoft and go for Linux. We would ditch Microsoft Word and we would use LaTex .  As the only UNIX (Solaris) user in the building, I wondered if this could be truly possible. Well, x years is a long time, and as far as I know they're still trying.

The thing is, even the raspberry pi feels like you're driving a mainframe computer. There are all those commands to learn in order to manage the beast., and the beast turns out to be a chip the size of a silver penny (i.e very small indeed). Well - no use procrastinating - here we go.

In this excercise, the command prompt is "$".

Installing the Software

 How much "disk" space do we have ? - we must have something free.  Enter the following command:

$df -k


pi@raspberrypi:~$ df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                    95416         0     95416   0% /lib/init/rw
udev                     10240       168     10072   2%

devtmpfs                95416         0     95416   0% /dev/shm
rootfs                 1602528   1309020    212100  87% /
/dev/mmcblk0p1           76186     28089     48097  37% /boot


This command tells us we have 212 Mb available on the file system "rootfs" - where we will install the software. (It may occur to you that we have much less space than is available on the SD card - where did it all go ? The answer is that it is unpartitioned - we can recover that space - story for another day.)

Now we can install the packages we need -presupposing we have enough space:

$sudo apt-get install mpd mpc alsa

This will install the utilities we need to get the audio working. In my case, this failed some time after I entered the confirmation that enough "disk space was available. I had to fix the installation with the suggestion given - by reinstalling mpd with a --fix-install option. This time, it worked and took quite a long time (maybe 30 minutes ) to complete the installation.

Since you are connected - you might as well install vim

$sudo apt-get install vim

Now you don't have to remember those pesky hjkl keys.

We have everything we need - we just need to get it all to work.

Configuring the software

Configuration is carried out by editing various files. The first file to alter is /etc/modules. We need to add the name of the sound driver to ensure it gets loaded at boot time. The name of the sound river is snd_bcm2835. The file snd_bcm2835 is located in /sys/modules and is not loaded by default in the squeeze image.

Edit /etc/modules (squeeze image)

$sudo vi /etc/modules

Add the line in red.

# /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.


 Now the sound driver will work.

You might need to set permissions for user pi (that's you!)

$sudo  service mpd stop

and change permissions using chmod

$sudo chmod -R g+w /var/lib/mpd

$sudo chmod -R g+w /var/run/mpd

Not sure if this is really required for internet radio. The "g" specifies members of the group and the +w makes files in thdirectories writeable. The -R means recurse down the directory tree.

You are going to have to restart the pi anyway, so the next file you need to edit is /etc/mpd.conf.

$sudo vi mpd.conf

Commment out the line

# For network
#bind_to_address                "localhost"


I found this gave an error if I left it in, so I commented it out with a # as above. You may need it later.

Alter the alsa output section, the last 4 lines were commented out (I need to check the why's and wherefores):

# An example of an ALSA output:
audio_output {
        type            "alsa"
        name            "My ALSA Device"
        device          "hw:0,0"        # optional
#       format          "44100:16:2"    # optional
#       mixer_device    "default"       # optional
#       mixer_control   "PCM"           # optional
#       mixer_index     "0"             # optional


Now we are nearly done - reboot

$sudo shutdown now -r

Using the Pi Internet Radio

At this point, you won't hear anything, you need to set the sound output using the alsa mixer:

$sudo amixer cset numid=3 1 (see the man pages for amixer)

You can also use the utility alsamixer". Alsa mixer did not work very well with my previous image. The problems appear to have been corrected with "wheezy". Alsamixer has been written with the "ncurses" library, which we might look at later.

$sudo alsamixer

Now, simply add the radio stream to the playlist

$mpc add  - for example, if you wanted to add "Radio Caroline"

$mpc play will play the station.

$mpc with no arguments will tell you what is going on .

You can keep adding stations with the add command to mpc. I found that in the main, stations with a "simple" address as above would play nicely, but a complex address would not work. I added quite a few stations:

pi@raspberrypi:~$ mpc playlist
Fine Music Radio


 "Fine music radio" from Cape Town ( is currently playing, so its IP address has been replaced with its name. Radio highveld won't play using this program. (must be that crazy microsoft media protocol -mms://).  To play stations, you have to enter their number in the list.

$mpc play 6 would play highveld if it couldfrown.

Highveld now plays with the new image laugh.

$mpc stop stops playing, and

$mpc del 6  will remove highveld from the list. After you have played the entire list, the addresses have some info:

pi@raspberrypi:~$ mpc playlist
Minimal, Techno, Electro Sets @ Marco Carola - Fluid Live 21.02.2009
Radio Caroline: Radio Caroline - Real People | Real Music - (07:20 BST)
Datempo Lounge - SKY.FM - amazing combination of jazz, lounge, bossa, and much more!: Plaid Feat. Bjork - Lilith
Fine Music Radio
Vaal Community Radio


The last station is "Radio Today" - like many other South African Internet Radio stations - it won't play on anything - even my PC. For some reason, K3COL gives an error - but plays anyway. Streams ending in .pls or .asx are playlists - you might have to download them and see what's inside. You can use "notepad" giving the URL of the playlist to see the contents and get the actual stream. I tried this with Vermont Public Radio" and it still wouldn't play. 

Moving on

Now that everything is installed and working, there are two ways to go. The first would be to attach controls and an LCD screen to the general purpose I/O pins on top of the PC board, add a WiFi dongle and make the RPi a true internet radio. The second would be to provide a decent user interface to control the RPi from a keyboard and monitor.

At least there's some music to listen to while porgramming / constructing / pottering about.

Commands used in this article


chgrp - Try to understand *NIx's permissions. - Users, Groups, Owners. It often causes grief.



vi / vim

By the way - it doesn't receive the BBC. Damned unpatriotic, I say.

Joomla template by a4joomla