Raspotify
This software is a Spotify Connect receiver. It is meant for a “headless” Linux system, meaning no keyboard/mouse/monitor attached. You need a Spotify Premium account to use this.
Website of the software: https://github.com/dtcooper/raspotify
How to use
What you can do in practice:
- You can run the Spotify app on e.g. your TV, laptop or phone
- Connect to the Raspberry Pi as playback device in the app
- Your Raspberry Pi streams music directly from Spotify (as requested via the app)
Installation
sudo apt-get -y install curl
curl -sL https://dtcooper.github.io/raspotify/install.sh | sh
This executes an installation script that also adds a Debian package repository for the software. That way you can update it with apt afterwards. (See also Linux: software packages.)
ALSA loopback
In my use case I don't want Raspotify to directly output the audio to a playback device. Instead I want to connect it to an ALSA loopback device. See page Linux: audio about what it is.
This allows me to select either the music from Spotify or my TV as input in CamillaDSP. With the configuration below I can use dsnoop:Loopback,1,0 to get the sound from Raspotify. The sound from Raspotify is always 16 bit (format S16LE) with sample rate 44.1 kHz.
Configuration
Edit the following lines in /etc/raspotify/conf:
BITRATE=320 # Highest possible quality
LIBRESPOT_ENABLE_VOLUME_NORMALISATION=off # Set to your preference
LIBRESPOT_NAME="Raspberry Pi Jarkko" # Change to what you want
LIBRESPOT_DEVICE="hw:Loopback,0,0" # Send audio to ALSA loopback
Then restart the Raspotify service:
sudo systemctl restart raspotify