SqueezeBox

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.

Install

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

then

$ 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 192.168.100.100 -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.

Hostname

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

Autostart

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
### BEGIN INIT INFO
# 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
### END INIT INFO

# 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
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Squeezebox client"
NAME=squeezelite-armv6hf
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
SBSHOST="-s 192.168.100.100 "
#SLMAC="00:00:00:00:00:01"
SLOPTIONS="-n Lounge -a 80 "
#SLLOG=/var/log/squeezelite.log
#OSS="`$DAEMON -V | grep -c 1810`"
#AOSS=/usr/bin/aoss

# 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

DAEMON_ARGS="${SLOPTIONS} ${SBSHOST} ${SLOPTIONSLOG}"

# 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
#
do_start()
{

# 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}
fi

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

#
# Function that stops the daemon/service
#
do_stop()
{
# 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="$?"
[ "$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
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# 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"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s