Squeezelite up and running on Raspian Wheezy Hard Float


24 posts
by Gerrelt » Sat Dec 15, 2012 8:39 pm
I have got Squeezelite running on my Raspbery Pi 256 mb model B for a couple of weeks now. I am now running Raspbian Wheezy Hard Float. At first Squeezelite wasn't available for
hard float, so I had it running on Debian Wheezy Soft Float. Debian Wheezy Soft Float is a bit harder to work with then Raspian Wheezy hardfloat, but I got it running, which I
described in this thread.
But then (just after I got it running) it was offered for Raspian Wheezy Hard Float too! So I switched back to Hard Float.
In this thread I will describe how I got it running, and there's a video demonstration at the end...

Squeezelite is a software version of the Logitech Squeezebox. A squeezebox can connect to a Logitech Media Server (LMS). This server streams music to the players.
Internet radio, MP3's and I believe even Spotify is possible.

Also it's possible to synchronize playes, to create a multi room sytem. Which is my goal actually. I want a player in the living room and in the kitchen and synchronize these two.
Currently I own one Raspberry, and I've ordered two more raspberries. But I am still waiting on them.. :-(
In the meantime I am running squeezelite on this one raspberry, which I turned into a portable squeezelite player with retro looks (see this thread).

This is the forum thread about squeezelite: Thread: Announce: Squeezelite - a small headless squeezeplay emulator for linux (alsa only).
The developer (thanks again Triode, you're doing an excellent job!!) is on there too.
This is the google code homepage: http://code.google.com/p/squeezelite

First create a SD card with the Debian Wheezy Hard Float image on it. Connect it to a network cable and log in using SSH (Putty is my favorite SSH client).

Run the config tool:
Code: Select all
sudo raspi-config

Enlarge the SD card, enable SSH (probably not necessary), set locale and timezone to your liking and run the update (takes a long time).

Changing the Hostname (optional)
I then changed the hostname:
Code: Select all
sudo nano /etc/hosts

Change the name "raspberrypi" into something you like (I just "blueberry" this time).
Then open the next file, and put the same name behind "127.0.1.1":
Code: Select all
sudo nano /etc/hostname


Get WiFi up and running (optional)


Then to get Wifi working (I have a Logilink WiFi dongle. RTL8188CUS based), I had to modify this file:
Code: Select all
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

And make it look like this:
Code: Select all
    ctrl_interface=/var/run/wpa_supplicant
    network={
    proto=RSN
    scan_ssid=1
    key_mgmt=WPA-PSK
    pairwise=CCMP TKIP
    group=CCMP TKIP
    ssid="your network ID in quote marks"
    psk="your network password in quote marks"
    }
    }

I had to add the network={ ... } stuff, and change the ssid and psk.

After restarting I used ifconfig and saw that there was a IP address assigned to the wlan.
I unplugged the network cable and I got wireless network up and running.


Installing Squeezelite

First set the sound level:
Code: Select all
sudo alsamixer


Use the F6 key to select the right soundcard (I am using an USB soundcard), and then set the volume.
I also set the microphone volume to zero, to make sure it will not cause interference.

Install some libs:
Code: Select all
sudo apt-get install libflac-dev

(answer Y to the question)
Code: Select all
sudo apt-get install libfaad2

Did this too, but it turned out it was allready installed on Raspbian:
Code: Select all
sudo apt-get install libmad0


Create a squeezelite "work" directory:
Code: Select all
mkdir squeezelite
cd squeezelite


Now get squeezelite:
Code: Select all
wget http://squeezelite.googlecode.com/files/squeezelite-armv6hf

Move it to the usr directory, and make it executable:
Code: Select all
sudo mv squeezelite-armv6 /usr/bin
cd /usr/bin

sudo chmod u+x squeezelite-armv6


Because I use a USB soundcard, so I had to tell squeezelite which sound device to use.
First list all the devices:
Code: Select all
squeezelite-armv6hf -l

The result:
Code: Select all
#Output devices:
  null                           - Discard all samples (playback) or generate zero samples (capture)
  sysdefault:CARD=ALSA           - bcm2835 ALSA, bcm2835 ALSA - Default Audio Device
  sysdefault:CARD=Set            - C-Media USB Headphone Set, USB Audio - Default Audio Device
  front:CARD=Set,DEV=0           - C-Media USB Headphone Set, USB Audio - Front speakers
  surround40:CARD=Set,DEV=0      - C-Media USB Headphone Set, USB Audio - 4.0 Surround output to Front and Rear speakers
  surround41:CARD=Set,DEV=0      - C-Media USB Headphone Set, USB Audio - 4.1 Surround output to Front, Rear and Subwoofer speakers
  surround50:CARD=Set,DEV=0      - C-Media USB Headphone Set, USB Audio - 5.0 Surround output to Front, Center and Rear speakers
  surround51:CARD=Set,DEV=0      - C-Media USB Headphone Set, USB Audio - 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
  surround71:CARD=Set,DEV=0      - C-Media USB Headphone Set, USB Audio - 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
  iec958:CARD=Set,DEV=0          - C-Media USB Headphone Set, USB Audio - IEC958 (S/PDIF) Digital Audio Output

I wanted to use only the front speakers, so I had to tell squeezelite to use "front:CARD=Set,DEV=0" .

Now to start Squeezelite I had to run (ip address is the address of the LMS server):
Code: Select all
./squeezelite-armv6hf -o front:CARD=Set,DEV=0 192.168.2.4

And it worked!

Starting without the IP address for the LMS server:
Code: Select all
./squeezelite-armv6hf -o front:CARD=Set,DEV=0

Without the IP address squeezelite uses auto discovery to determine the IP address of the LMS server.

Starting Squeezelite on startup
It was working well, so now I wanted to have it started on startup. So, to automate things, I made a daemon start script to start Squeezelite.

I made the script available through my website, it's my very first linux daemon script, so use at your own risk!
Do the next commands to automate startup:
Code: Select all
cd /home/pi/squeezelite
sudo wget http://www.gerrelt.nl/RaspberryPi/squeezelitehf.sh
sudo mv squeezelitehf.sh /etc/init.d/squeezelite

cd /etc/init.d
sudo chmod u+x squeezelite

sudo update-rc.d squeezelite defaults

In the script the name of the squeezelite client is set to "Framboos" which is the dutch word for Raspberry. :)
To change it, run:
Code: Select all
sudo nano squeezelite

Search for the word "Framboos" and change it to your liking.
Now you have to set the soundcard here too.
Search for this line (same line as where "Framboos" is):
Code: Select all
SLOPTIONS="-o front:CARD=Set,DEV=0 -n Framboos"

Change "front:CARD=Set,DEV=0" to the one you selected earlier.
Save and close the script file.

This is how you test the script:
Code: Select all
sudo ./squeezelite start

The command prompt should return immediately. Now check if the squeezelite process is up:
Code: Select all
ps -A |grep squeeze

It should return something like this (the number will be different):
Code: Select all
2324 ?        00:00:01 squeezelite-arm

To stop squeezelite:
Code: Select all
sudo ./squeezelite stop

And that's it, if you now reboot the raspberry (sudo shutdown -r now), squeezelite should be started automatically.


See this video for a demonstration: CLICK FOR YOUTUBE DEMO


Greetings,

Gerrelt.
Posts: 60
Joined: Sat Nov 10, 2012 9:01 am
by Frenchy » Sun Jan 27, 2013 5:58 pm
Hi Gerrelt,

Thanks for your helpful tutorial!
It was my first steps with linux and I succeeded to install squeezelite on raspbian.
I just found 2 little errors ;)


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

I have 3 USB DAC and I’d like to start 3 squeeze lite session as the RPI starts. I’ve downloaded your script and need some help to adapt it…
Can-you help-me and tell-me which parts needs to be updated?

Can I simply copy/paste this line (and create differentes params)

Code: Select all
start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE --background --exec $DAEMON -- $DAEMON_ARGS -m $SLMAC || return 2


Thanks,

Frenchy
Posts: 8
Joined: Tue Jan 22, 2013 2:58 pm
by Gerrelt » Sun Jan 27, 2013 8:00 pm
Hi Frenchy,

I'm glad you found it usefull. 8-)

Ah, yes, there should be "hf" added in the instructions. Sadly, I'm not allowed to edit the post anymore, because of forum rules.
I hope everybody reads your post so they know how to correct it.

About adding the lines to the daemon script:
I think it would be simpler to copy the script two times, and change the scripts. Then make the other scripts start at startup too.
Like this:
Code: Select all
cd /etc/init.d
cp squeezelite squeezelite_dac2
cp squeezelite squeezelite_dac3
sudo chmod u+x squeezelite_dac2
sudo chmod u+x squeezelite_dac3

Then edit the two new scripts to make them use the different dacs:
Code: Select all
sudo nano squeezelite_dac2
sudo nano squeezelite_dac3

And then make them start when the raspberry boots:
Code: Select all
sudo update-rc.d squeezelite_dac2 defaults
sudo update-rc.d squeezelite_dac3 defaults


Be aware: Because you are starting three squeezelite isntances you must assign different mac addresses to them.
In each script change this line (at linenumber 40):
Code: Select all
SLMAC="00:00:00:00:00:01"

So it contains a unique mac address. For example, use: 00:00:00:00:00:01, 00:00:00:00:00:02 and 00:00:00:00:00:03

If you don't do that, then the LMS server cannot identify the players seperately. As soon as the second player instance becomes active, it will "overwrite" the previous one with the same mac address.
Assigning different mac addresses to them prevents this from happening.
Posts: 60
Joined: Sat Nov 10, 2012 9:01 am
by Frenchy » Mon Jan 28, 2013 9:31 pm
Thanks for your help.

Unfortunately, the second instance doesn't want to start...no error message to tell-me why :(

When I executed this line
Code: Select all
sudo update-rc.d squeezelite_dac2 defaults

I had an error telling me that squeezelite service was already registered.

So I updated this line
Code: Select all
# Provides:          squeezelite

into
Code: Select all
# Provides:          squeezelite2


Then I executed again the
Code: Select all
sudo update-rc.d squeezelite_dac2 defaults

and got no error.

When the RPI starts, It only start the first instance of Squeezelite (and It working well)

If I manually start the second instance:
Code: Select all
sudo ./squeezeliteDAC2 start

No error...but nothing started...

How can I debug this?

I also tried
Code: Select all
ps -A |grep squeeze

And It returned one line...

Do-you have any idea where could b the problem?
Have-you tried multiple instance of squeezelite?

Thanks for your time,

Frenchy
Posts: 8
Joined: Tue Jan 22, 2013 2:58 pm
by Gerrelt » Mon Jan 28, 2013 11:14 pm
No I didn't try it myself. But, looking at the script, I think you should change this line (line 36):
Code: Select all
PIDFILE=/var/run/$NAME.pid


And change it so it's unique to the dac the script is for.
For example, for squeezeliteDAC2 you could change it to:
Code: Select all
PIDFILE=/var/run/$NAME_dac2.pid


The PIDFILE is the file where the process id is stored for this daemon. The proces ID is the number you see when you execute
this command:
Code: Select all
ps -A |grep squeeze


The PIDFILE is used to check if the process is allready running, and to make the daemon stop it's process.
Currently alle the scripts use the same PIDFILE name, which cannot work. So you got to make it unique for each script.
Posts: 60
Joined: Sat Nov 10, 2012 9:01 am
by Frenchy » Wed Jan 30, 2013 11:27 am
YES It works :mrgreen:

One thing I don't understand;

Code: Select all
PIDFILE=/var/run/$NAME_dac2.pid


$NAME_dac2 => this variable isn't initiated at anytime...is It normal?
It's working but don't understand how
Posts: 8
Joined: Tue Jan 22, 2013 2:58 pm
by Gerrelt » Wed Jan 30, 2013 12:14 pm
Nice! 8-)

A few lines above it, there this line:
Code: Select all
NAME=squeezelite-armv6hf


So, variable $NAME will have value "squeezelite-armv6hf".

PIDFILE will therefore evaluate to "/var/run/squeezelite-armv6hf_dac2.pid" in your example.

To check, execute this command while your squeezelite daemons are running:
Code: Select all
sudo ls /var/run/squeezelite-armv6hf*.pid


It should display 3 entries.
Posts: 60
Joined: Sat Nov 10, 2012 9:01 am
by Frenchy » Wed Jan 30, 2013 2:51 pm
Okaaayy

I'm from the Microsoft .NET world :oops:
That's really different....

So you can concatenate a variable to a string without giving any "",+,...or anything
That's strange. i'll remember it
Posts: 8
Joined: Tue Jan 22, 2013 2:58 pm
by Gerrelt » Wed Jan 30, 2013 8:05 pm
I am currently in the .NET world too. :)
But in my previous job I worked with Oracle, Java and unix servers, so I have done some scripting too.

Remember, this is just a script and not a "real" programming language.. ;)
As long as you don't create a variabel with the name "NAME_dac2" this will work fine.
But even if you do, you probably could solve it by using { }.
Like this: PIDFILE=/var/run/${NAME}_dac2.pid

It might even be recommended to do it like that.
Posts: 60
Joined: Sat Nov 10, 2012 9:01 am
by Frenchy » Mon Feb 04, 2013 7:40 pm
I'm back...I juste received my 3rd DAC and It doesn't want to start during the boot process.

I exactly did the same as for DAC2...but It doesn't start :?

So I tried to start it manually:
Code: Select all
sudo squeezelite-armv6hf -o front:CARD=DAC_2,DEV=0 -m 00:00:00:82:84:56 -n SqueezeC 192.168.1.200 -z

OK It works

Then I tried to run the "daemonized"
Code: Select all
sudo ./squeezeliteDAC3 start

No It doesn't start :cry:

Then I checked in the logs (/var/log/); no file "squeezeslite.log"

I triple checked the init.d/squeezeliteDAC3 file...so I really don't know why It doesn' start.

Is there a way to debug it? or to get some logs...

Thanks
Posts: 8
Joined: Tue Jan 22, 2013 2:58 pm
by Gerrelt » Mon Feb 04, 2013 9:00 pm
Hmm...just had a look at the script again.. it seems the logging is totally absent. Yes, there is a variable SLLOG defined, but it doesn't do anything with it.

You could put in some debug messages like:
Code: Select all
echo The scrip is doing this  >> ${SLLOG}


Can you PM me the script for DAC3 ?
Posts: 60
Joined: Sat Nov 10, 2012 9:01 am
by Frenchy » Tue Feb 05, 2013 8:45 pm
Yep I've sent you the script in PM.

Another (little) problem is that radio and apps only work on one out of 3 DACs (music works on the 3 DACs).

Nothing to do, when playing radio, the sounds only works with one DAC...
I also tried to sync the players (wich works with music) and same problem, the sound only comes out from one player...
Posts: 8
Joined: Tue Jan 22, 2013 2:58 pm
by castalla » Wed Feb 06, 2013 7:02 pm
Followed you instructions to install squeezelite on Raspian (but on a Cubieboard, not a Pi).

Seems to go all okay until the -o output options.

As far as I can see this version of Raspian is set up to use PulseAudio (aaargh!). ... I've no idea how to handle that.

If I post the squeezelite -l & aplay -L listings - do you think you can help?

I imagine I'll have to get rid of pulseaudio to get anywhere.
Posts: 408
Joined: Thu Jul 19, 2012 3:46 pm
by Gerrelt » Wed Feb 06, 2013 8:55 pm
Frenchy wrote:Yep I've sent you the script in PM.

Another (little) problem is that radio and apps only work on one out of 3 DACs (music works on the 3 DACs).

Nothing to do, when playing radio, the sounds only works with one DAC...
I also tried to sync the players (wich works with music) and same problem, the sound only comes out from one player...


So, playing MP3's through LMS - Squeezelite works, but playing radio through LMS - squeezelite does not work correctly? Hmm..strange.. :?
Did you try the modified script I send you? It could be a problem with the way you add the Mac addres to squeezelite.

castalla wrote:Followed you instructions to install squeezelite on Raspian (but on a Cubieboard, not a Pi).

Seems to go all okay until the -o output options.

As far as I can see this version of Raspian is set up to use PulseAudio (aaargh!). ... I've no idea how to handle that.

If I post the squeezelite -l & aplay -L listings - do you think you can help?

I imagine I'll have to get rid of pulseaudio to get anywhere.


I know nothing about Cubieboards or PulseAudio. But I am curious about the squeezelite -l listing. Yes, post it.
Posts: 60
Joined: Sat Nov 10, 2012 9:01 am
by castalla » Wed Feb 06, 2013 9:14 pm
Here's the output:

Code: Select all

pi@raspberrypi ~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sun4isndhdmi [sun4i-sndhdmi], device 0: SUN4I-HDMIAUDIO sndhdmi-0 []
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: sun4icodec [sun4i-CODEC], device 0: M1 PCM [sun4i PCM]
  Subdevices: 0/1
  Subdevice #0: subdevice #0


pi@raspberrypi ~ $ squeezelite-armv6hf -l
Output devices:
  null                           - Discard all samples (playback) or generate zero samples (capture)
  pulse                          - Playback/recording through the PulseAudio sound server
  sysdefault:CARD=sun4isndhdmi   - sun4i-sndhdmi,  - Default Audio Device
  sysdefault:CARD=sun4icodec     - sun4i-CODEC, sun4i PCM - Default Audio Device

pi@raspberrypi ~ $


The output from a test:

Code: Select all

pi@raspberrypi ~ $ aplay tada.wav
Playing WAVE 'tada.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
aplay: pcm_write:1710: write error: Input/output error
pi@raspberrypi ~ $
Posts: 408
Joined: Thu Jul 19, 2012 3:46 pm
by Gerrelt » Wed Feb 06, 2013 9:23 pm
Dit you try this as -o setting? :

Code: Select all
SLOPTIONS="-o sysdefault:CARD=sun4icodec -n Framboos"


Or this one, but that's probably for the HDMI output:

Code: Select all
SLOPTIONS="-o sysdefault:CARD=sun4isndhdmi -n Framboos"
Posts: 60
Joined: Sat Nov 10, 2012 9:01 am
by castalla » Wed Feb 06, 2013 9:39 pm
Looks like the audio is not configured properly - I've got a different Debian image where I know the onboard audio does actually play, so I'll try that.

I'll also have a bash at uninstalling Pulseaudio ...

Will report back here on progress - thanks for the help

Code: Select all
pi@raspberrypi /usr/bin $ squeezelite-armv6hf -o sysdefault:CARD=sun4icodec -n Framboos
[22:31:41.309293] test_open:152 playback open error: Device or resource busy
[22:31:41.310142] output_init:1336 unable to open output device
pi@raspberrypi /usr/bin $
Posts: 408
Joined: Thu Jul 19, 2012 3:46 pm
by castalla » Wed Feb 06, 2013 9:52 pm
Bingo!

Removing Pulseaudio seems to have worked!

At least I can see Framboos in Squeezeplay and control streams, etc. Now to actually plug in a speaker!

cheers
Posts: 408
Joined: Thu Jul 19, 2012 3:46 pm
by perplu » Sun Feb 24, 2013 4:38 am
Have put all the test information below only as additional context. TEST 3 below is a working solution for synchronised music play-back to multiple audio devices running Squeezelite.

The only issue noted is that the volume is much quieter in TEST 3 than in TEST 2. Don't quite know why this was. Will need to investigate. But - the solution seems to be use Squeezelite, Raspberry PI stuck on the back of powered speakers in each room of the house. The ony down-side is the Squeeze Server interface could do with a refresh - its a bit tired. Useful also is that there are two android apps that are OK for use as a remote control.

SETUP:
DS 109+
All music FLAC.

AIRPLAY TEST:
Three airplay receivers setup:
- Android 2.3 with AirBubble
- Shairport on Raspberry PI - http://jordanburgess.com/post/389864343 ... pi-airplay
- Windows 7 Laptop with Shairport4W

TEST 1:
Played to all from DS Audio.
No music played; Raspberry crashes.

TEST 2:
Played simultaneously to all from MusicBee with Remote Speakers Out add-in installed and all three airplay receivers selected.
Music played OK, but not in sync.

SQUEEZE-SERVER TEST:
Two squeeze receivers setup:
Squeezelite on Windows 7 Laptop.
Squeezelite on Raspberry PI viewtopic.php?f=38&t=25778 . Audio was out via Raspberry HDMI port to Onkyo receiver.

TEST 3:
Played same track simultaneously from DS NAS Squeeze and all in sync to both Squeeze receivers. Could also play to multiple audio devices the same track synchronised using either of two android apps on my smartphone running android 2.3.
Posts: 9
Joined: Sun Feb 24, 2013 4:30 am
by perplu » Sun Feb 24, 2013 8:18 am
I should add - if you use active speakers with an internal DAC you can presumably hook them up directly to the RPi USB in some cases or just need to get an HDMI to TOSLINK converter thing. Better yet would be an active speaker with internal DAC that also has an HDMI in. But some digital speakers I've found are:

http://www.aktimate.com.au/mini+.html
http://www.vanatoo.com/ - this one has USB in. But before buying I'd want to know if it would work from RPi to USB in on the speakers. I'm guessing if there's anything that needs tweaking it will be with the RPi USB setup.

Just found this - http://www.samsung.com/us/video/home-theater/HW-D551/ZA
I'm guessing the other major audio-visual manufacturers make soundbars now - and I'm guessing they'll all have an HDMI in. If you have somewhere you can hide the speaker - then this is probably the best lowcost option. The speakers are pretty reasonable - their competitors are likely the same.
Posts: 9
Joined: Sun Feb 24, 2013 4:30 am
by perplu » Mon Mar 11, 2013 7:26 am
The other thing I've just realised is that there are dozens of speakers out there with an HDMI-in. All the soundbars from Sony, Phillips, Panasonic etc. Some have wireless subs and some have not sub. The setup I plan to end up with is PC upstairs with SqueezeLite which is connected to upstairs amp and speakers; downstairs amp and speakers connected to RPI via HDMI, soundbar in kitchen above cupboards where you won't see it connected to PRI via HDMI and then somehow put a soundbar in the bathroom connected to RPI via HDMI. All in sync. Yay.

I have a Synology diskstation which has the latest DMS on it which while it plays the same track to multiple airplay devices the output is not always in sync. The only options to get them in sync is either Porthole software or Airfoil speakers - both of which means I'd either need to find a way to install them on the Synology NAS (linux) which I don't know how to port and do; or I need to set up a separate intel box alongside the NAS running Airfoil or Porthole - which I'm tempted to do and then I can just buy any airplay speakers and forget the whole rapsberry thing. Food for thought.
Posts: 9
Joined: Sun Feb 24, 2013 4:30 am
by 00Luke » Tue Mar 19, 2013 9:42 pm
Hello,

Thanks so much for this great tutorial and start up script!

I've just run through it all and it's working great when I start ./squeezelite-armv6hf manually, but when I try to get your auto start up script working I'm struggling.

I've installed and edited it as advised, but when I try and run it, it seems to do nothing. If I run ps -A |grep squeeze I get nothing coming back, and /etc/init.d $ sudo ./squeezelite status returns:
[FAIL] squeezelite-armv6hf is not running ... failed!

Any tips or advice? If there's any other information you need please let me know - I'm really knew to all this so still learning what's useful / important and what isn't :)

Cheers!
Posts: 1
Joined: Tue Mar 19, 2013 9:36 pm
by perplu » Wed Mar 20, 2013 2:43 am
These links should be helpful. One is for getting VNC to start on start-up, just follow the same instructions but replace VNC stuff with SqueezeLite stuff.

http://myraspberrypiexperience.blogspot ... cally.html

http://danielmuller.asia/2013/02/squeez ... spberrypi/

Cheers.
Posts: 9
Joined: Sun Feb 24, 2013 4:30 am
by Gerrelt » Fri Mar 22, 2013 6:54 pm
@perplu: I searched around for pc speakers with HDMI input, but I couldn't find affordable ones. I think it's too soon for HDMI input PC speakers.

@00Luke: How do you try to start it? What is the command line, and in which directory are you in when starting it?
Posts: 60
Joined: Sat Nov 10, 2012 9:01 am