For the player there are a number of open source implementations of the SqueezeBox functionality. Squeezelite is an excellent, simple one and great for running on a RPi.


Installing SqueezeLite on a RPi is well documented. One such guide is here or here.

Basically do the following

$ sudo apt-get install libflac-dev
$ sudo apt-get install libfaad2
$ sudo apt-get install libmad0
$ wget http://squeezelite-downloads.googlecode.com/git/squeezelite-armv6hf
$ wget http://squeezelite.googlecode.com/files/squeezelite-armv6hf


$ sudo mv squeezelite-armv6hf /usr/bin
$ cd /usr/bin
$ sudo chmod +x squeezelite-armv6hf
$ ./squeezelite-armv6hf

Bingo, using the LMS the player is found and you can play music.

This was all on the RPi using 2013-02-09-wheezy-raspbian.img

Audio does not sound right?

One issue that I found was that the quality of audio was nowhere what I expected it to be. To check what was going wrong I created an audio file containing a sine wave in PCM encoding. When looking at the audio out with an Oscilloscope one could see dropouts. This lead me to think there was some sort of underrun or overrun happening. Looking at the options for Squeezelite there was a parameter

-a <b>:<p>:<f>:<m> Specify ALSA params to open output device, b = buffer time in ms or size in bytes, p = period count or size in bytes, f sample format (16|24|24_3|32), m = use mmap (0|1)

Increasing the buffer size fixed the issue. These reports confirm the issue – Issue 4 , Issue 28
The full command that I used was

$ squeezelite-armv6hf –s -n Lounge -a 80

No Audio

If you do not get any audio then maybe you have not selected the correct audio output.

You can use the raspi-config tool to force the audio output to either the HDMI port or the jack.

Use the following to test the output

$sudo aplay /usr/share/sounds/alsa/Front_Center.wav

You should also check your volume by using the alsamixer command.


It is also good to set the name of the RPi. This can be done with the raspi-config tool:

Go to “8 Advanced Options”,
then to “A2 Hostname”,
choose “OK”,
and change the name

It can also be changed without the raspi-config tool, by editing the following files

$ sudo nano /etc/hostname
$ sudo nano /etc/hosts


To make Squeezelite run automatically at power on I created an init file. To get me started I used one that had been done before I found here.

This was then updated with my config, then I did the following to set it up

 $ sudo cp file-downloaded /etc/init.d/squeezelite
 $ sudo chmod 755 /etc/init.d/squeezelite
 $ sudo update-rc.d squeezelite defaults

Here is my init file

#! /bin/sh
# Provides: squeezelite
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Squeezelite
# Description: Light weight streaming audio player for Logitech's Squeezebox audio server

# Original Author: http://www.gerrelt.nl/RaspberryPi/squeezelitehf.sh
# Install Instructions
# Copy file to /etc/init.d/squeezelite
# chmod 755 /etc/init.d/squeezelite
# update-rc.d squeezelite defaults
# Create /etc/default/squeezelite to override any default
# variables defined here. No not edit this file.
# Uninstall Instructions
# update-rc.d squeezelite remove

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
DESC="Squeezebox client"
SLOPTIONS="-n Lounge -a 80 "
#OSS="`$DAEMON -V | grep -c 1810`"

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME


# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

# Function that starts the daemon/service

# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1

if [ -f ${SLLOG} ]; then
rm ${SLLOG}

start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE --background --exec $DAEMON -- $DAEMON_ARGS || return 2

# Function that stops the daemon/service
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"

# Function that sends a SIGHUP to the daemon/service
do_reload() {
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
return 0

case "$1" in
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#log_daemon_msg "Reloading $DESC" "$NAME"
#log_end_msg $?
# If the "reload" option is implemented then remove the
# 'force-reload' alias
log_daemon_msg "Restarting $DESC" "$NAME"
case "$?" in
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
# Failed to stop
log_end_msg 1
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3

Squeezebox Server

As mentioned in the first page on this topic there are a number of alternate ways of implementing an open source music player that performs similar to Sonos.

SqueezeBox is a Logitech solution that has a number of the components open source. It is a music streamer so music on a Squeeze Server can be streamed to a number of SqueezeBoxes.

The system consists of the Logitech Media Server and multiple SqueezeBoxes

Squeezebox is a network music player from Logitech (now discontinued) but there are a number of open source implementations that can be used.

Logitech Media Server (LMS) is the server software that powers audio players from Logitech (formerly known as SlimDevices), including Squeezebox, Squeezebox Boom, Squeezebox Receiver, Transporter, Squeezebox2, Squeezebox and SLIMP3. Logitech Media Server is the new name for Squeezebox Server, starting with version 7.7. Before it was known as Squeezebox Server (version 7.4 to 7.6) and SlimServer (before 7.4).

Logitech Media Server is Open Source Software and written in Perl. Logitech Media Server runs on pretty much any platform that Perl runs on, including Linux, Mac OSX, Solaris and Windows.
It can be downloaded from here http://www.mysqueezebox.com/download
Logitech maintains a good wiki at wiki.slimdevices.com/index.php/Logitech_Media_Server and wiki.slimdevices.com/index.php/Main_Page

Installing LMS is well documented on the wiki and various other posts so I will not go into detail here. I installed this on my Linux server that I run MythTv on, this server is always on so ideal for music anytime.

After installation you can access the LMS on the server using a web browser at port 9000. You will need to open port 9000 on the server firewall to access. Setup is simple, just enter the location of your music and LMS will scan the directories. The mp3 tags are read and the database is created. I have a file in each album directory called folder.jpg which is the cover art for each album. LMS reads these cover art files and displays in the user interface.

There is also a great iPhone app to select and play the music from Logitech and it is free – called Logitech Squeezebox Controller. This does the job, a better one exists, iPeng, but I have not tried it.

Battery Saver

I was sick and tired of my kids leaving their battery power toys left on and draining the batteries. Especially the toy walkie-talkies which use a 9V battery that are more expensive to replace.

So I added a small circuit to disconnect the battery when it had not been used for some time. A push button is needed to turn it on and start the timer. The walkie-talkies already had one so I just stole this.

Battery Saver Circuit

For reference here is a typical schematic for a kids walkie-talkie.

Kids Walkie Talkie

Looking around on the net I found these other battery saver circuits

Battery Saver Example One


Battery Saver Example Two


Raspberry Pi MPD streaming using PulseAudio

I have a Raspberry Pi as a music player using MPD. This is a local solution only, all the music files must be on the Pi SD card.

One of my original aims for this project was to have multiple players throughout the house, keeping the music updated on all players would be a pain. A centrally stored solution would be much better. Also I would like to be able to play the same song in multiple rooms in the house.

The plan was to have a number of Pis in various rooms connected to amplifiers and speakers. They would be network connected via WiFi or cable. Music would then be streamed to them.

Luckily I have an old laptop that is always on as my MythTv. This is running Fedora, is networked and has a large disk. This is an ideal place to store all the music and act as a music server. It is actually already all there as MythTv has a music player.

On the server I have MPD and PulseAudio installed. Setup MPD to use an audio output of pulse with a rtp sink, this will stream the audio using PulseAudio over the rtp protocol. This will ensure that all players are in sync. Add this to the mpd.conf on the server.

audio_output {
 type "pulse"
 name "Lounge"
 sink "rtp"

On the Raspberry Pi player MPD is no longer needed. Configure PulseAudio to receive from rtp. PulseAudio will need to be started in service mode rather than user mode. Here are some links of how it is all done.


On the server change the following the /etc/pulse/default.pa

load-module module-null-sink sink_name=rtp format=s16be channels=2
load-module module-rtp-send source=rtp.monitor

This sends rtp to pulseaudio’s default multicast address,

On the player edit /etc/pulse/system.pa.

load-module module-rtp-recv

This was all very good but I found the rtp flooded my wireless network. During search to find a solution it looks like it is a long standing PulseAudio issue.


There were some workarounds but this was getting too complicated.
On to a different way of doing this.

Raspberry Pi MPD audio without the pop and crackle

Using MPD as a music player on a Raspberry Pi is a great solution.

One annoying thing is the pop that happens on the audio port every time a song plays and finishes.

One way around this is to use PulseAudio rather than ALSA. These sites detail the solution

So I installed PulseAudio

sudo apt-get install pulseaudio

and changed the mpd.conf to the following

audio_output {
 type "pulse"
 name "MPD PulseAudio Output"

Then edit /etc/pulse/default.pa and remove or comment out load-module module-suspend-on-idle. This is the important part that prevents PulseAudio from sending the audio hardware to sleep. Then restart your Pi.

Now I have no more pops.

On to the next phase – streaming to multiple players.

Update – 5Aug2013.
The lastest version of Raspbian “wheezy” downloaded from the Raspberry Pi website has this issue fixed. Version at the time of writing was 2013-07-26-wheezy-raspbian

Raspberry Pi MPD setup

Installing Music Player Daemon (MPD) on the Pi is simple

$ sudo apt-get mpd

This will install the binaries, make mpd autostart, add a config file and create the directories under /var/lib/mpd.

The config file at /etc/mpd.conf works out of the box and the core bit of this is a follows

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

Note that by default it uses ALSA.

There are many other posts detailing the process. Here are a few

Put some music files in /var/lib/mpd/music and it is ready to go.
To actually play music with mpd you need a client to control it, this can be installed using

$ sudo apt-get mpc

To play a song do the following

$ mpc update                        'makes mpd read the music directory
                                    'and update its database
$ mpc listall                       'lists all the music in the database
$ mpc insert ‘album or song name’   'adds something to the playlist
$ mpc playlist                      'prints the playlist
$ mpc play                          'plays the playlist
$ mpc volume 70

MPD can also be controlled by a client on another device. A good remote for the iPhone is MPoD – http://www.katoemba.net/makesnosenseatall/mpod/

This can connect to MPD over the network and browse and play music. You will need to open port 6600 if you have a firewall and ensure that the mpd.conf file has MPD listening to all network addresses. In mpd.conf

bind_to_address     "any"

MPoD also has a means to show cover art, if you have a web server running you can enter a URL where it can find the cover art images. I already have a cover art image stored in each album directory so all I had to do was make the music directory accessible to a browser. I did this by adding it to the apache config as follows

Alias /mpd/ "/media/Store/Media/Music/"
<Directory "/media/Store/Media/Music/">
  Options Indexes FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
  Allow from 192.168.100

One annoying thing is that every time a song starts a pop is heard out of the audio port. This is a Raspberry Pi issue and is because the Pi audio out uses PWM,
See Raspberry Pi MPD audio without the pop and crackle

Using 2013-02-09-wheezy-raspbian.img
MPD pops at song start ‘mpc play’, pops at song end ‘mpc stop’

Update – 5Aug2013.
The lastest version of Raspbian “wheezy” downloaded from the Raspberry Pi website has this issue fixed. Version at the time of writing was 2013-07-26-wheezy-raspbian

Raspberry Pi Setup

I have received my Raspberry Pi, followed the Quick Start steps in the RPi website and got it up and running.

My RPi is a Model B with 512MB. The first boot and play I had it connected to a TV via HDMI – it worked as expected.

So I do not have to use a TV every time I plan to get a remote connection to it – remote terminal via ssh or remote desktop via VNC.

But first I am deciding whether to use Raspbian (an optimised version of Debian) or ArchLinux.

Here are some figures – all tests via terminal via ssh

Image Size Disk Usage Memory Total Memory Used
Raspbian 1.94G 1.5G 448996 54748
Arch1 1.98G 403M 188060 51716
Arch2 1.98G 403M 188060 51716

1. Default Arch image does not have X server or desktop or any updates
2. Upgrades were required to the image downloaded to get the RPi to use the full 512MB of memory (archlinux-hf-2012-09-18)

$ pacman -Syu
$ sync
$ reboot

Full details below

Raspbian (2012-12-16-wheezy-raspbian)

Image sizes

2012-12-16-wheezy-raspbian.img 1,939,865,600
2012-12-16-wheezy-raspbian.zip 507,098,306

Disk usage

$ df -h
Filesystem Size Used Avail Use% Mounted on
 rootfs 7.3G 1.5G 5.5G 21% /
 /dev/root 7.3G 1.5G 5.5G 21% /
 devtmpfs 220M 0 220M 0% /dev
 tmpfs 44M 220K 44M 1% /run
 tmpfs 5.0M 0 5.0M 0% /run/lock
 tmpfs 88M 0 88M 0% /run/shm
 /dev/mmcblk0p1 56M 17M 40M 30% /boot

Memory usage

$ free
 total used free shared buffers cached
Mem: 448996 54748 394248 0 9312 28008
-/+ buffers/cache: 17428 431568
Swap: 102396 0 102396

Installed apps

Arch (archlinux-hf-2012-09-18)

Arch is a very bare bones system, there is no X server or desktop.

Image sizes

archlinux-hf-2012-09-18.img 1,977,614,336
archlinux-hf-2012-09-18.zip 166,578,651

Disk usage

$ df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 1.8G 403M 1.3G 25% /
/dev/root 1.8G 403M 1.3G 25% /
devtmpfs 92M 0 92M 0% /dev
tmpfs 92M 0 92M 0% /dev/shm
tmpfs 92M 260K 92M 1% /run
tmpfs 92M 0 92M 0% /sys/fs/cgroup
tmpfs 92M 0 92M 0% /tmp
/dev/mmcblk0p1 94M 36M 59M 38% /boot

Memory usage

$ free
 total used free shared buffers cached
Mem: 188060 51716 136344 0 7292 29524
-/+ buffers/cache: 14900 173160
Swap: 0 0 0

Installed apps