Adding Spotify / Airplay can it coexist

@spockfish Harry I wonder if you have ever thought of how someone could add Spotify / Airplay etc support to RoPieee.

pre RoPieee I used to run Volumio / DietPi on a couple of devices with/without displays and Roon Bridge and my wife now complains she can’t play spotify to the roon endpoints as they all run Ropieee now.

Not being a software/linux guru I am not sure how they might coesist if I managed to somehow get my way through adding the needed options to Ropieee and how it might survive reboots and updates.

In DietPi I think they (Spotify, Shareplay, Roon etc etc) are all available but obviously without the display support.

trying to find a happy ground where my wife can stream from iTunes or spotify to my RPi roon devices.

Plus one. Would stop me needing to use diet-pi

But then isn’t it in danger of becoming DietPi? :wink:

I dont think so…dietpi is a much more flexible platform for all things pi.

I’m not suggesting Ropieee include spotify or airplay or tidal play etc if there is such a thing but that maybe some consideration of how to install these in a RoPieee setup could be documented without breaking Ropieee and Roon. Im not a linux guru so would love to see some guidance in this area. As good as DietPi is for many situations I rather have my Ropieee / Roon combo as the base with some option to extend it for direct playback options without roon in the mix.

Spotify is not that simple as Librespot is not built for ArchLinux as it is for other distros.

Granted some might not be doable but those that are maybe someone who can figure it out can help those of us that can’t :smiley:

It takes slightly under 30 seconds to download and install shairplay onto a Ropiee build… All my Ropiee devices are co-loaded with both - works beautifully

if it’s so easy then why keep wasting time saying so and give the instructions in a simple layman’s list.

1 Like

ssh into your Ropiee box, then:

pacman -S shairport-sync
systemctl enable shairport-sync

Job done. If you want to tweak names etc. edit /etc/shairport-sync.conf and set the system name to what you like. Depending on the output from your Ropiee box, you may need to change the output device setting.

I just installed Shairport. Here’s what I did.

Login to the ropieee box using ssh.

Run:

pacman -S --needed base-devel
pacman -S --needed git
git clone https://github.com/mikebrady/shairport-sync-for-arch-linux.git
cd shairport-sync-for-arch-linux
makepkg -sfi

This will build and install shairport

Edit your /etc/shairport-sync.conf to reflect your settings. For my DAC I changed the following:

name = “whatever”
interpolation = “soxr”
output_backend = “alsa”
ignore_volume_control = “yes”
output_device = “hw:CARD=sndrpihifiberry”
convolution = “no”
loudness = “no”

run:
systemctl enable shairport-sync

That should be it. A bit fiddly but very quick once you know how.

not so good so far…it did just update to Ropieee B262 tho

[root@ropieee54 ~]# pacman -S shairport-sync
error: failed to init transaction (unable to lock database)
error: could not lock database: File exists
  if you're sure a package manager is not already
  running, you can remove /var/lib/pacman/db.lck
[root@ropieee54 ~]#

same for the pacman -S --needed base-devel option but now seems to be different

Running thru a bunch of stuff now on the pacman -S --needed base-devel part…

well after some things going ok I end up here

[root@ropieee54 shairport-sync-for-arch-linux]# makepkg -sfi
==> ERROR: Running makepkg as root is not allowed as it can cause permanent,
catastrophic damage to your system.
[root@ropieee54

I got around that by editing /usr/bin/makepkg. Search for “catastrophic” and hash out this block:

if (( ! INFAKEROOT )); then
if (( EUID == 0 )); then
error “$(gettext “Running %s as root is not allowed as it can ca
use permanent,\n
catastrophic damage to your system.”)” “makepkg”
exit $E_ROOT
fi
else
if [[ -z $FAKEROOTKEY ]]; then
error “$(gettext “Do not use the %s option. This option is only
for internal use by %s.”)” “’-F’” “makepkg”
exit $E_INVALID_OPTION
fi
fi

By the way - Richard Harris’s solution in this thread seems simpler than mine if you can get it to work. Your pacman errors can probably be fixed by removing the /var/lib/pacman.db.lck file mentioned, or possibly by just rebooting the ropieee.

I’m going to try it again on a fresh build with Richards 2 liner. Software is not my forte sadly…but I can follow along on SSH commands given ones that will work :stuck_out_tongue:

Ok Richards worked I think - though I can’t see it as an airplay device in Roon…but can still see the Dragonfly DAC connected to it… this /etc/shairport-sync.conf is a bit of a brain drain…no idea where to start

But now Spotify is what I really wanted…any thoughts on that one?

Glad it worked - I found that the simple version (not requiring the base-devel and git dependencies) worked fine for me. I did those installs on the then current Ropiee (20190420), and everything shows up as an Airplay device in Ropiee and in other Airplay apps. I did three installs:

  1. Raspberry Pi Model 3 B & Hifiberry Digi+ Pro
  2. Raspberry Pi Model 3 Model B+ & Meridian USB DAC
  3. Raspberry Pi Type B (1st gen) - analogue output.

Well it worked for apple airplay but not in roon airplay…maybe need to restart the core. Will update when I have some time to do some reboots

OK seems to be OK in Roon too

Some update while Spotify on iOS can select to play via the Shairport connection, nothing comes out of my IQAudIO digiamp+ hat, nor does it work for apples itunes. Maybe something different with the hat verses dragonfly on Usb.

Oh well it’s 02:36 and I’m going to crash…mrs is playing Spotify via the Oppo sonica speakers on her side table…such is life.

I just made my first attempt at adding Spotify Connect to RoPieee (which I’ve been using for a few months now) and have to say it was deceivingly easy. I have two RoPieee end points now and while the process was generally the same for both, I did run into a bit of trouble on the second.

Backstory

First, when looking into what to use I came across Raspotify. It is clearly targeted at Raspbian and it’s Debian base so that didn’t appear promising, but it did give a good overview… that it was essentially a small wrapper of librespot. In searching about librespot, I came across spotifyd - a small wrapper (written in rust) around the more library-centric librespot (also rust) project to turn it into an all around easier-to-use binary. I checked it out to see how much effort might be involved, but to my surprise… it just worked!

Second, I doubt I can provide much support if you decide to take this route as I’m sure there’s quite a few hardware variables out there and I’m no ALSA expert, but hopefully my two examples will be enough to point people in the right direction.

Instructions:

  • Head over to the spotifyd releases page on Github and copy the link to the latest armv6 release.
  • SSH to your RoPieee box (out of scope, but simply the following on Mac/Linux):
    • ssh root@192.168.your.ip
    • password is root
# use the link you copied from the above Github releases page - the below link is up to date as of the time of this post
wget https://github.com/Spotifyd/spotifyd/releases/download/0.2.11/spotifyd-2019-06-19-armv6.zip
# if the below pacman command fails, just try it again
pacman -S unzip
# unzip the file you downloaded
# probably easiest to use tab-completion - simply type: unzip spot<Tab key>
unzip spotifyd-2019-06-19-armv6.zip
# move the spotifyd binary into place
mv spotifyd /usr/local/bin/
# create a SystemD unit file, file contents listed separately below
# I used vi for this as that was the only editor available, but since that
# has a steep learning curve, definitely feel free to install nano with:
# pacmac -S nano
vi /etc/systemd/system/spotifyd.service
# create spotifyd config
# same as above regarding editor of choice
vi /etc/spotifyd.conf
# enable spotifyd service so it starts on boot
systemctl enable spotifyd
# start the service now!
systemctl start spotifyd

SystemD service unit file contents: /etc/systemd/system/spotifyd.service

[Unit]
Description=A spotify playing daemon
Documentation=https://github.com/Spotifyd/spotifyd
Wants=sound.target
After=sound.target
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/local/bin/spotifyd --no-daemon
Restart=always
RestartSec=10

[Install]
WantedBy=default.target

spotifyd config: /etc/spotifyd.conf
Check the README on spotifyd’s Github page (github dot com/Spotifyd/spotifyd) for more details about this config file and all it’s options.

[global]
backend = alsa
volume-control = alsa
device_name = Your_Device_Name     # can NOT contain spaces
bitrate = 320
volume-normalisation = false
initial-volume = 100
disable-audio-cache = true

The above simple config “just worked” for my Raspberry Pi 4 running RoPieee (beta) connected to a USB DAC. On my second attempt at this on a Raspberry Pi 3 B+ running RoPieee (stable) with a Allo DigiOne HAT, I struggled to get audio. After plenty of trial and error, I wound up adding the below to my /etc/spotifyd.conf above in order to get this to work:

device = hw:1

So how did I arrive at that value? Here is the output from a couple of commands, some device names I tried (that failed), and what that hw:1 even means. Wikipedia even has a good primer on ALSA concepts (wikipedia dot org/wiki/Advanced_Linux_Sound_Architecture#Concepts).

[root@ropieee ~]# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=sndallodigione
    snd_allo_digione, 
    Default Audio Device
iec958:CARD=sndallodigione,DEV=0
    snd_allo_digione, 
    IEC958 (S/PDIF) Digital Audio Output

From the above output I tried names like:

  • sysdefault
  • sysdefault:CARD=sndallodigione
  • sysdefault:sndallodigione
  • iec958
  • iec958:sndallodigione
  • iec958:sndallodigione,0
  • many I’ve forgotten

However, based on reading the ALSA project’s wiki entry on device names (alsa-project dot org/wiki/DeviceNames) I was able to piece together hw:1 from the below output:

[root@ropieee ~]# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: sndallodigione [snd_allo_digione], device 0: Allo DigiOne HiFi wm8804-spdif-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I even tried hw:1,0 which failed, but hw:1 for “use hardware interface for card 1” worked. The ALSA wiki suggests avoiding this for anything besides mono output, but I clearly get stereo output, though my present DAC doesn’t give me any indication as to what format.

Apologies for the long first post, but hopefully others will find this useful! I’ve only been using it for a couple of days so I have no idea on long-term stability (something RoPieee excels at for Roon!), but it’s been working well so far.

Edited to remove helpful links since I’m a new user which limits me to two.

3 Likes

@Frick
You’re a genius. No way that I would have figured it out without this guide!
Thanks a lot :+1: :kissing_heart:

It just works flawlessly on my PI 3B+ with a Justboom Digi HAT