-
-
Notifications
You must be signed in to change notification settings - Fork 220
Basic Setup Guide
Raspotify is built on and for Debian Stable and requires Debian Stable or a Debian Stable based/compatible OS.
armhf, arm64 and amd64 builds are provided. Support for ARMv6 (Pi v1 and Pi Zero v1.x) has been dropped.
This is a very basic guide that assumes you're starting from a fresh Debian Stable Minimal Server or Raspberry Pi OS Lite (Stable) install.
These instructions will install and configure Raspotify and will reconfigure system wide audio settings.
It will NOT explain how to install Debian, use a text editor, set up Raspotify/librespot
as a whatever-cast source or make you a sandwich.
If following these instructions breaks your system you get to keep all the pieces.
sudo apt-get -y install curl && curl -sL https://dtcooper.github.io/raspotify/install.sh | sh
This requires your output device to be "dmix-able", as in it is software mixable via ALSA's dmix plugin. The HDMI ports on Raspberry Pi's are NOT "dmix-able".
Install asound-conf-wizard
If you have added the Raspotify repo:
sudo apt update && sudo apt install -y asound-conf-wizard
If not the latest asound-conf-wizard builds can be found here:
- asound-conf-wizard-latest_armhf.deb
- asound-conf-wizard-latest_arm64.deb
- asound-conf-wizard-latest_amd64.deb
sudo awiz
Follow the prompts, take note of the Format that was used, and skip ahead to Configure librespot
.
A Glossary of Terms is available in the asound-conf-wizard
wiki if you get stuck or have questions on what settings you should pick.
As of version 0.43.47 the version of librespot built for Raspotify supports 44.1kHz, and though builtin resampling 48kHz, 88.2kHz and 96kHz.
librespot -d ?
Example output:
Compatible alsa device(s):
--------------------------------------------------------------------
Device:
hw:CARD=D10s,DEV=0
Description:
D10s, USB Audio
Direct hardware device without any conversions
Supported Format & Sample Rate Combinations:
Format: S32 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
--------------------------------------------------------------------
Device:
plughw:CARD=D10s,DEV=0
Description:
D10s, USB Audio
Hardware device with all software conversions
Supported Format & Sample Rate Combinations:
Format: S16 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
Format: S24 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
Format: S24_3 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
Format: S32 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
Format: F32 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
Format: F64 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
--------------------------------------------------------------------
Device:
sysdefault:CARD=D10s
Description:
D10s, USB Audio
Default Audio Device
Supported Format & Sample Rate Combinations:
Format: S16 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
Format: S24 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
Format: S24_3 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
Format: S32 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
Format: F32 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
Format: F64 Sample Rate(s): 44.1kHz, 48kHz, 88.2kHz, 96kHz
--------------------------------------------------------------------
To set the format, change:
# Output format {F64|F32|S32|S24|S24_3|S16}. Defaults to S16.
#LIBRESPOT_FORMAT="S16"
To:
# Output format {F64|F32|S32|S24|S24_3|S16}. Defaults to S16.
LIBRESPOT_FORMAT="match the audio output format"
For example:
# Output format {F64|F32|S32|S24|S24_3|S16}. Defaults to S16.
LIBRESPOT_FORMAT="S32"
To set the sampling rate, change:
# Sample Rate to Resample to {44.1kHz|48kHz|88.2kHz|96kHz}.
# Defaults to 44.1kHz meaning no resampling.
# The option does not exist in upstream librespot.
# DO NOT file a bug with librespot about this.
#LIBRESPOT_SAMPLE_RATE="44.1kHz"
To:
# Sample Rate to Resample to {44.1kHz|48kHz|88.2kHz|96kHz}.
# Defaults to 44.1kHz meaning no resampling.
# The option does not exist in upstream librespot.
# DO NOT file a bug with librespot about this.
#LIBRESPOT_SAMPLE_RATE="match the audio output sampling rate"
For example:
# Sample Rate to Resample to {44.1kHz|48kHz|88.2kHz|96kHz}.
# Defaults to 44.1kHz meaning no resampling.
# The option does not exist in upstream librespot.
# DO NOT file a bug with librespot about this.
#LIBRESPOT_SAMPLE_RATE="48kHz"
You may also want to increase the interpolation quality:
# Interpolation Quality to use if Resampling. {Low|Medium|High}.
# Defaults to Low.
# The option does not exist in upstream librespot.
# DO NOT file a bug with librespot about this.
#LIBRESPOT_INTERPOLATION_QUALITY="Low"
If you're not limited by data caps or connection speeds you can also want set the audio quality to 320kbps by changing:
# Bitrate (kbps) {96|160|320}. Defaults to 160.
#LIBRESPOT_BITRATE="160"
To:
# Bitrate (kbps) {96|160|320}. Defaults to 160.
LIBRESPOT_BITRATE="320"
Unless you have disabled zeroconf (mDNS) discovery, librespot
does not need your Spotify credentials, zeroconf will take care of authentication.
However if you have disabled discovery for whatever reason and you provided your credentials you will also want to enable credential caching so that librespot
will cache the auth token and not have to login every time you connect. Unless you like nag emails ofc?
To enable credential caching change this in /etc/raspotify/conf
:
# Disable caching of credentials.
# Caching of credentials is not necessary so long as
# LIBRESPOT_DISABLE_DISCOVERY is not set.
LIBRESPOT_DISABLE_CREDENTIAL_CACHE=
To this:
# Disable caching of credentials.
# Caching of credentials is not necessary so long as
# LIBRESPOT_DISABLE_DISCOVERY is not set.
# LIBRESPOT_DISABLE_CREDENTIAL_CACHE=
By default librespot
"download buffers" tracks, meaning that it downloads the tracks to disk and plays them from the disk and then deletes them when the track is over. This practice is very common, many other audio frameworks and players do the exact same thing as a disk based tmp cache is easy to use and very resilient. That being said there may be cases where a user may want to minimize disk read/writes.
If you don't know what this means or understand the ramifications do NOT do this.
To make Raspotify use tmpfs for /tmp
change this in /etc/raspotify/conf
:
# Commenting this out will cause `librespot` to use a tmpfs so that provided there
# is enough RAM to hold the track nothing is written to disk but instead to a tmpfs.
# See https://github.com/dtcooper/raspotify/discussions/567
# And https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html
TMPDIR=/tmp
To this:
# Commenting this out will cause librespot to use a tmpfs so that provided there
# is enough RAM to hold the track nothing is written to disk but instead to a tmpfs.
# See https://github.com/dtcooper/raspotify/discussions/567
# And https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html
#TMPDIR=/tmp
If you run UFW on your pi, you'll find that you need to open some ports for it to work. First, specify the zeroconf port in /etc/raspotify/conf
:
LIBRESPOT_ZEROCONF_PORT="65444"
Next, allow ports 5353 UDP and 65444 TCP. On a network running on the 192.168.11.0/24
space that looks like this
sudo ufw allow from 192.168.11.0/24 to any port 5353 proto udp
sudo ufw allow from 192.168.11.0/24 to any port 65444 proto tcp
If you're setting up UFW for the first time, make sure you also allow port 22 for ssh. If you already use UFW you will have this.
sudo ufw allow from 192.168.11.0/24 to any port 22 proto tcp
This is what your UFW config might look like if these are the only ports you've opened:
pi@raspberrypi:~ $ sudo ufw status
Status: active
To Action From
-- ------ ----
22/tcp ALLOW 192.168.11.0/24
5353/udp ALLOW 192.168.11.0/24
65444/tcp ALLOW 192.168.11.0/24
To make sure all changes take effect you must restart the Raspotify service:
sudo systemctl restart raspotify
Completely uninstall Raspotify and asound-conf-wizard:
sudo apt purge -y raspotify asound-conf-wizard
Remove the repo:
sudo rm -f /etc/apt/sources.list.d/raspotify.list
Delete the repo's key:
sudo rm -f /usr/share/keyrings/raspotify_key.asc
Delete /etc/asound.conf
:
sudo rm -f /etc/asound.conf