Categories
Logitech Media Server Raspberry Pi

Getting HiFiBerry Amp2 Working With Squeezelite for Logitech Media Server

This mini tutorial assumes you have installed your HiFiBerry Amp2 hardware to your Raspberry Pi and configured it using this tutorial:

https://www.hifiberry.com/docs/software/configuring-linux-3-18-x/

This tutorial also builds off these excellent web pages

and just makes their advice specific to the HiFiBerry hardware.

(This worked with this hardware list: https://mystupidnotes.com/desktop-audio-raspberry-pi-logitech-media-server-shopping-list/

and after an upgrade to Raspberry Pi 4.)


First, let’s list all soundcards and digital audio devices on our Raspberry Pi with:

aplay -l

The result should be:

**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dacplus], device 0: HiFiBerry DAC+ HiFi pcm512x-hifi-0 [HiFiBerry DAC+ HiFi pcm512x-hifi-0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
Raspberry Pi list sound devices with aplay
There it is!

Let’s just double check that the HiFiBerry Amp2 is available to Squeezelite with:

sudo /usr/bin/squeezelite -l

Here it is:

Output devices:
  null                           - Discard all samples (playback) or generate zero samples (capture)
  default
  sysdefault:CARD=sndrpihifiberry - snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0 - Default Audio Device
  dmix:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0 - Direct sample mixing device
  dsnoop:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0 - Direct sample snooping device
  hw:CARD=sndrpihifiberry,DEV=0  - snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0 - Direct hardware device without any conversions
  plughw:CARD=sndrpihifiberry,DEV=0 - snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ HiFi pcm512x-hifi-0 - Hardware device with all software conversions
That’s the line we will need in our Squeezelite config.

I like to kill Squeezelite before modifying the config with this:

sudo service squeezelite stop

Let’s modify our Squeezelite config with the nano text editor:

sudo nano /etc/default/squeezelite

If you followed the tutorials at the top to get started, you should see something like this:

# Defaults for squeezelite initscript
# sourced by /etc/init.d/squeezelite
# installed at /etc/default/squeezelite by the maintainer scripts

# The name for the squeezelite player:
SL_NAME="$(hostname -s)"

# ALSA output device:
SL_SOUNDCARD="sysdefault:CARD=sndrpihifiberry"

# Squeezebox server (Logitech Media Server):
# Uncomment the next line if you want to point squeezelite at the IP address of
# your squeezebox server. This is usually unnecessary as the server is
# automatically discovered.
#SB_SERVER_IP="192.168.x.y"

# Additional options to pass to squeezelite:
# Please do not include -z to make squeezelite daemonise itself.
#SB_EXTRA_ARGS="-a 180"
There’s our card that was shown earlier with “sudo /usr/bin/squeezelite -l”

Line 9 in the code above the image is the one we want to get the HiFiBerry card working for Logitech Media Server.

On this excellent site: http://www.winko-erades.nl/installing-squeezelite-player-on-a-raspberry-pi-running-jessie/ it’s mentioned that you should change:

#SB_EXTRA_ARGS=""

To:

SB_EXTRA_ARGS="-a 180"

Although, I am not sure if that is needed with the HiFiBerry card. I can’t tell any difference either way, so I tried it, but ended up commenting it out in the config above.

Ctrl+o to save and then Ctrl+x to exit the nano editor.

sudo service squeezelite start

A refresh of your Logitech Media Server screen should show your Squeezelite player!

Categories
Logitech Media Server Raspberry Pi

Desktop Audio Raspberry Pi Logitech Media Server Shopping List

Logitech Media Server IconRaspberry Pi and Logitech Media Server Hardware Shopping List for Audio at Your Desk (or wherever)

Raspberry Pi 3 and HiFiBerry Amp2
Raspberry Pi 3 and HiFiBerry Amp2

I’ve lost track of how many ways I have turned my audio files into sound waves via Logitech Media Server.

Here’s a few:

But, this is an audio streaming hardware setup for Logitech Media Server that I am finally happy with.

(Some Common LMS Commands)

The only confusing part of this setup was incorporating the subwoofer with the HiFiBerry Amp2.

If the subwoofer amplifier has high level inputs (and the Polk sub listed below has these), then daisy chain them together with your speakers like this:

HiFi Berry Amp2 > Sub > Speakers


The Hardware:

This can definitely be improved on.

The Polk sub is just ok, but definitely worth it when it goes on sale. It lists at about $130 USD, but drops to $99 and below on a regular basis.

The Micca speakers are great for the price, but they have a newer more expensive version (Micca RB42) that looks like a worthy successor.

That’s the setup. Let me know if you have something better as I’m always looking to make changes!

Categories
Linux Logitech Media Server Raspberry Pi

Common Logitech Media Server (LMS) Commands

I’ve tried multiple self-hosted audio streaming options including: Ampache, Airsonic, Mopidy, Volumio and more.

However, I always come back to Logitech Media Server.
In my opinion, it’s the best for streaming your audio to your desk (It’s not so great for taking your tunes with you.)

I’m always tinkering or trying out new Logitech Media Server installs, and this is an accumulated Cheat Sheet of Linux/Raspberry Pi commands that I’ve used over the years.

Start, Stop, and Restart LMS

  • sudo service logitechmediaserver start
  • sudo service logitechmediaserver stop
  • sudo service logitechmediaserver restart

Get proper ownership of the main LMS directory

  • sudo chown squeezeboxserver -R /var/lib/squeezeboxserver/

Backup your LMS files

  • sudo cp -r /var/lib/squeezeboxserver MyBackupDirectory

Restore your LMS files

  • sudo service logitechmediaserver stop
  • cd MyBackupDirectory
  • sudo cp -r squeezeboxserver /var/lib/
  • sudo chown squeezeboxserver -R /var/lib/squeezeboxserver/
  • sudo service logitechmediaserver start

Need to copy your favorites back over and the “OPML Playlist Browser & Editor” isn’t cooperating?

CD to the folder where your backup is and use these commands

  • sudo service logitechmediaserver stop
  • sudo cp favorites.opml /var/lib/squeezeboxserver/prefs
  • sudo chown squeezeboxserver /var/lib/squeezeboxserver/prefs/favorites.opml
  • sudo service logitechmediaserver start

Restore just your plugins

  • sudo service logitechmediaserver stop
  • cd MyBackupDirectory/squeezeboxserver/cache/Installed Plugins
  • sudo cp -r Plugins /var/lib/squeezeboxserver/cache/InstalledPlugins/
  • sudo chown squeezeboxserver -R /var/lib/squeezeboxserver/
  • sudo service logitechmediaserver start

Installed a plugin and LMS won’t start?

  • sudo service logitechmediaserver stop
  • cd /var/lib/squeezeboxserver/cache/InstalledPlugins/Plugins
    sudo rm -r MyBadPlugin
  • sudo service logitechmediaserver start

Want to start over without reinstalling?

  • sudo service logitechmediaserver stop
  • cd /var/lib/squeezeboxserver/cache
  • sudo rm *.db
    • If you’d like to verify that you are deleting the correct db first, try this: echo sudo rm *.db which shows which db will be deleted or sudo rm -i *.db which will prompt you to delete the db before it happens.
  • sudo service logitechmediaserver start

Delete everything

  • sudo rm -r /var/lib/squeezeboxserver
  • sudo rm -r /etc/squeezeboxserver