Skip to content

Instantly share code, notes, and snippets.

@Pindar
Last active March 30, 2019 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pindar/43f88e47e813c1bb33485697328cd6f2 to your computer and use it in GitHub Desktop.
Save Pindar/43f88e47e813c1bb33485697328cd6f2 to your computer and use it in GitHub Desktop.
Raspotify with HifiBerry

To use raspotify properly with HifiBerry on raspberry pi 2 (kernel 4.19.29-v7)

  1. Compile https://github.com/librespot-org/librespot
sudo apt-get install build-essential libasound2-dev
curl https://sh.rustup.rs -sSf | sh
cargo build --release --features alsa-backend
  1. Point /etc/systemd/system/raspotify.service to compiled binary from (1), e.g. /home/pi/librespot/target/release/librespot
# /etc/asound.conf
pcm.!default {
type hw card 0
}
ctl.!default {
type hw card 0
}
# /etc/default/raspotify -- Arguments/configuration for librespot
# Device name on Spotify Connect
DEVICE_NAME="Stereoanlage"
# Bitrate, one of 96 (low quality), 160 (default quality), or 320 (high quality)
BITRATE="320"
# Additional command line arguments for librespot can be set below.
# See `librespot -h` for more info. Make sure whatever arguments you specify
# aren't already covered by other variables in this file. (See the daemon's
# config at `/lib/systemd/system/raspotify.service` for more technical details.)
#
# To make your device visible on Spotify Connect across the Internet add your
# username and password which can be set via "Set device password", on your
# account settings, use `--username` and `--password`.
#
# To choose a different output device (ie a USB audio dongle or HDMI audio out),
# use `--device` with something like `--device hw:0,1`. Your mileage may vary.
#
OPTIONS="--device hw:0,0 --mixer-card=hw:0 --mixer=alsa --mixer-name=Digital --username XXX --password XXXX"
# Uncomment to use a cache for downloaded audio files. Cache is disabled by
# default. It's best to leave this as-is if you want to use it, since
# permissions are properly set on the directory `/var/cache/raspotify'.
#CACHE_ARGS="--cache /var/cache/raspotify"
# By default, the volume normalization is enabled, add alternative volume
# arguments here if you'd like, but these should be fine.
VOLUME_ARGS="--enable-volume-normalisation --linear-volume --initial-volume=75"
# Backend could be set to pipe here, but it's for very advanced use cases of
# librespot, so you shouldn't need to change this under normal circumstances.
BACKEND_ARGS="--backend alsa"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment