Skip to content

Instantly share code, notes, and snippets.

@urbans0ft
Last active January 13, 2026 23:08
Show Gist options
  • Select an option

  • Save urbans0ft/2f6420039ff25d9197cdc4b596f09c0f to your computer and use it in GitHub Desktop.

Select an option

Save urbans0ft/2f6420039ff25d9197cdc4b596f09c0f to your computer and use it in GitHub Desktop.
HifiBerry MiniAmp Raspian Lite armv7 (64bit) with Spotify and Airplay

RPi Configuration

Packages

# needed for spotifyd to run on 64bit
sudo dpkg --add-architecture armhf
sudo apt update -y
sudo apt upgrade -y
sudo apt install vim -y
# needed for spotifyd to run on 64bit
sudo apt install libasound2-plugins:armhf libasound2-dev:armhf libssl-dev:armhf \
    libpulse-dev:armhf libdbus-1-dev:armhf libsystemd-dev:armhf libssl1.1:armhf \
    libc6:armhf libstdc++6:armhf -y
# needed for floating point comparison
sudo apt install bc -y

/etc/rc.local

# Turn off the red/power LED
echo 0 | sudo tee /sys/class/leds/PWR/brightness

/boot/firmware/config.txt

# remove the following line
dtparam=audio=on
# modify this line
dtoverlay=vc4-kms-v3d,noaudio
# insert this line
dtoverlay=hifiberry-dac

# Disable Power LED (Red)
dtparam=pwr_led_activelow=off

# Disable Activity LED (Green)
dtparam=act_led_trigger=none
dtparam=act_led_activelow=off

Alsa Configuration

/etc/asound.conf

# source: https://alsa.opensrc.org/Hardware_mixing,_software_mixing
pcm.hifiberry {
  type hw
  card 0
}
ctl.!default {
  type hw
  card 0
}
pcm.dmixed {
    type dmix
    ipc_key 1024
    #  ipc_key_add_uid false   # let multiple users share
    #  ipc_perm 0666           # IPC permissions for multi user sharing (octal, default 0600)
    slave {
    pcm "hifiberry"
    #   rate 48000
    #   period_size 512
    }
}
pcm.dsnooped {
    type dsnoop
    ipc_key 2048
    slave {
    pcm "hifiberry"
    #   rate 48000
    #   period_size 128
    }
}
pcm.asymed {
    type asym
    playback.pcm "dmixed"
    capture.pcm "dsnooped"
}
pcm.pasymed {
    type plug
    slave.pcm "asymed"
}
pcm.dsp0 {
    type plug
    slave.pcm "asymed"
}
# https://alsa.opensrc.org/Plugin_Documentation
# Some applications always try to open a control device with the same name as the pcm device 
# they are given, so you may also need to create a dummy control device with the same name:
pcm.softvol {
    type            softvol
    slave {
        pcm         "pasymed"
    }
    control {
        name        "Master"
        card        0
    }
}
# Some applications always try to open a control device with the same name as the pcm device
# they are given, so you may also need to create a dummy control device with the same name.
ctl.softvol {
  type hw
  card 0
}
pcm.!default {
    type plug
    slave.pcm "softvol"
}

-> speaker-test otherwise 'Master' volume won't be available

AirPlay

sudo apt install --no-install-recommends build-essential git autoconf automake libtool \
    libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev \
    libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev \
    uuid-dev libgcrypt-dev xxd -y

NQPTP

cd ~
git clone https://github.com/mikebrady/nqptp.git
cd nqptp
autoreconf -fi
./configure --with-systemd-startup
make
sudo make install
sudo systemctl enable nqptp
sudo systemctl start nqptp
sudo systemctl status nqptp

Shairport Sync

cd ~
git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync
autoreconf -fi
./configure --sysconfdir=/etc --with-alsa --with-soxr --with-avahi --with-ssl=openssl \
    --with-systemd --with-airplay-2
make
sudo make install
which shairport-sync
/usr/local/bin/shairport-sync

Test

shairport-sync -v --statistics

Enable and Start Service

sudo systemctl enable shairport-sync
sudo systemctl start shairport-sync
sudo systemctl status shairport-sync

Configure /etc/shairport-sync.conf

    run_this_before_entering_active_state = "/usr/bin/amixer sset 'Master' 100%";
    run_this_after_exiting_active_state = "/usr/bin/amixer sset 'Master' 50%";
    ignore_volume_control = "yes";
    run_this_when_volume_is_set = "/usr/local/bin/shairport-volume-control.sh";

/usr/local/bin/shairport-volume-control.sh

#!/bin/bash

volume=""
if (( $(echo "$1 <= -30.000000" | /usr/bin/bc -l) )); then
    volume="04"

elif (( $(echo "$1 <= -28.125000" | /usr/bin/bc -l) )); then
    volume="10"

elif (( $(echo "$1 <= -26.250000" | /usr/bin/bc -l) )); then
    volume="16"

elif (( $(echo "$1 <= -24.375000" | /usr/bin/bc -l) )); then
    volume="22"

elif (( $(echo "$1 <= -22.500000" | /usr/bin/bc -l) )); then
    volume="28"

elif (( $(echo "$1 <= -20.625000" | /usr/bin/bc -l) )); then
    volume="34"

elif (( $(echo "$1 <= -18.750000" | /usr/bin/bc -l) )); then
    volume="40"

elif (( $(echo "$1 <= -16.875000" | /usr/bin/bc -l) )); then
    volume="46"

elif (( $(echo "$1 <= -15.000000" | /usr/bin/bc -l) )); then
    volume="52"

elif (( $(echo "$1 <= -13.125000" | /usr/bin/bc -l) )); then
    volume="58"

elif (( $(echo "$1 <= -11.250000" | /usr/bin/bc -l) )); then
    volume="64"

elif (( $(echo "$1 <= -9.375000" | /usr/bin/bc -l) )); then
    volume="70"

elif (( $(echo "$1 <= -7.500000" | /usr/bin/bc -l) )); then
    volume="76"

elif (( $(echo "$1 <= -5.625000" | /usr/bin/bc -l) )); then
    volume="82"

elif (( $(echo "$1 <= -3.750000" | /usr/bin/bc -l) )); then
    volume="88"

elif (( $(echo "$1 <= -1.875000" | /usr/bin/bc -l) )); then
    volume="94"

elif (( $(echo "$1 <= 0.000000" | /usr/bin/bc -l) )); then
    volume="100"

else
    volume="50"
fi

echo "$1 setting volume to $volume"
/usr/bin/amixer sset 'Master' "${volume}%" >/dev/null
sudo chmod 755 /usr/local/bin/shairport-volume-control.sh

Spotify

Download

cd ~
wget https://github.com/Spotifyd/spotifyd/releases/download/v0.3.5/spotifyd-linux-armv6-slim.tar.gz
tar xzf spotifyd-linux-armv6-slim.tar.gz

Test

./spotifyd --no-daemon --volume-controller alsa_linear --device-name local --device-type speaker \
    --initial-volume 50

Daemon

mkdir -p ~/.config/systemd/user/

~/.config/systemd/user/spotifyd.target

[Unit]
Description=Multiple spotifyd
Requires=spotifyd@remote.service spotifyd@local.service

[Install]
WantedBy=default.target

~/.config/systemd/user/spotifyd@.service

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

[Service]
Environment="CONFIG_FILE=/home/pi/.config/spotifyd-%i.conf"
ExecStart=/home/pi/spotifyd --no-daemon --volume-controller alsa_linear --device-type speaker --initial-volume 50 --config-path $CONFIG_FILE
Restart=always
RestartSec=12

[Install]
WantedBy=default.target

Create to config files:

  • ~/.config/spotifyd-local.conf
  • ~/.config/spotifyd-remote.conf

Take the content from: https://docs.spotifyd.rs/config/File.html Don't use credential in the spotify-local.conf file so that daemon can be discovered via the local network by other clients. Both configs should name change the 'device_name' to something unique.

    
systemctl --user start spotifyd.target
sudo loginctl enable-linger pi
systemctl --user enable spotifyd.target
systemctl --user status spotifyd.target
journalctl --user -xefu spotifyd@remote.service
journalctl --user -xefu spotifyd@local.service

CLI client

cd ~ wget https://github.com/hrkfdn/ncspot/releases/download/v1.1.1/ncspot-v1.1.1-linux-arm64.tar.gz tar xzf ncspot-v1.1.1-linux-arm64.tar.gz

probably

sudo apt install libssl1.1

Maybe?

sudo apt install libdbus-1-dev libncursesw5-dev libpulse-dev libssl-dev libxcb1-dev
libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev -y

Resources

Notes

How to activate mpris

Spotifyd/spotifyd#1109

python Spotify

https://github.com/spotipy-dev/spotipy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment