└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Snapcast-pi 2 | 3 | Turn a **Raspberry Pi** into a Snapcast server that accepts **AirPlay** streams (from iOS/macOS) and re‑distributes them to any Snapclients you add later. The server itself also runs the first Snapclient, giving you an instant **master room**. 4 | 5 | The Hardware if have choosen here is to power some biger passive Speakers using Amp4 and some smaller passive Speakers using the miniAmp. 6 | 7 | **NOTE**: This is a basic setup to stream music via airplay. You ca add more streams follwing the docs here: https://github.com/badaix/snapcast 8 | 9 | 10 | ## Software 11 | 12 | | Component | Version / Role | 13 | | -------------- | ---------------------------------------------------------- | 14 | | Snapserver | **0.31.0**  + built‑in Snapclient | 15 | | Shairport‑Sync | **4.3.x** (Debian Bookworm, AirPlay 1) | 16 | | Device overlay | **HiFiBerry Amp4 Pro** *(swap for your own overlay if needed)* | 17 | | Web UI | **Snapweb** – grouping, volume & status | 18 | 19 | --- 20 | 21 | ## Hardware 22 | ### Server 23 | 24 | | Part | Notes | 25 | | ------------------ | ---------------------------------------------------- | 26 | | **Pi 5** | Raspberry Pi OS Lite **64‑bit Bookworm** recommended | 27 | | **HiFiBerry Amp4 Pro** | Just Plug it on your GPIOs | 28 | | **Power Supply** | Amp4 is powered via DC and the pi via GPIO | 29 | 30 | ### Client 31 | 32 | | Part | Notes | 33 | | ------------------ | ---------------------------------------------------- | 34 | | **Pi Zero 2 WH** | Raspberry Pi OS Lite **64‑bit Bookworm** recommended | 35 | | **HifiBerry Mini Amp** | Just Plug it on your GPIOs | 36 | | **Power Supply** | Amp is powered via GPIO | 37 | 38 | --- 39 | 40 | 41 | 42 | ## 1 · Flash OS & SSH into the Pi 43 | 44 | 1. **Download** [Raspberry Pi Imager](https://www.raspberrypi.com/software/). 45 | 2. Select **Raspberry Pi OS Lite (64‑bit, Bookworm)**. 46 | 3. In *OS customisation*: 47 | 48 | * **Enable SSH** 49 | * **Hostname:** `audiopi` 50 | * *(Optional)* enter Wi‑Fi credentials if you plan using Wi-Fi 51 | 4. Flash the card, insert it, boot up the Pi. 52 | 53 | ### SSh into the pi 54 | 55 | ```bash 56 | ssh pi@audiopi.local 57 | sudo apt update && sudo apt full-upgrade -y 58 | ``` 59 | 60 | --- 61 | 62 | ## 2 · Activate Drivers (HIFI Berry Amp 4 example) 63 | 64 | Based on hifi berry docs: https://www.hifiberry.com/docs/software/configuring-linux-3-18-x/ 65 | 66 | ```bash 67 | sudo nano /boot/firmware/config.txt 68 | ``` 69 | 70 | 71 | 72 | **Remove** the line: 73 | ``` 74 | dtparam=audio=on 75 | ``` 76 | 77 | Add **instead**: 78 | 79 | ```ini 80 | dtoverlay=hifiberry-amp4pro 81 | ``` 82 | Scorll down and find this line: 83 | 84 | ``` 85 | dtoverlay=vc4-kms-v3d 86 | ``` 87 | 88 | add "noaudio" and makesure it looks exactly like this: 89 | 90 | ``` 91 | dtoverlay=vc4-kms-v3d,noaudio 92 | ``` 93 | 94 | 95 | 96 | Reboot, 97 | 98 | ``` 99 | sudo rebbot 100 | ``` 101 | SSH back in,then verify: 102 | 103 | ```bash 104 | aplay -l # must list "sndrpihifiberry" 105 | ``` 106 | 107 | 108 | --- 109 | 110 | ## 3 · Install Snapcast 0.31 111 | 112 | ```bash 113 | cd /tmp 114 | wget https://github.com/badaix/snapcast/releases/download/v0.31.0/\ 115 | snapserver_0.31.0-1_arm64_bookworm.deb \ 116 | snapclient_0.31.0-1_arm64_bookworm.deb 117 | 118 | sudo apt install ./snapserver_* ./snapclient_* -y 119 | ``` 120 | 121 | --- 122 | 123 | ## 4 · Install Shairport‑Sync (AirPlay 1) 124 | 125 | ```bash 126 | sudo apt install shairport-sync -y # v4.3.x 127 | ``` 128 | 129 | > **Keep its systemd service disabled** – Snapserver will spawn its own instance. 130 | 131 | --- 132 | 133 | ## 5 · Configure Snapserver 134 | 135 | ```bash 136 | sudo nano /etc/snapserver.conf 137 | ``` 138 | 139 | ```ini 140 | [stream] 141 | source = airplay:///usr/bin/shairport-sync?name=AirPlay&port=5000 142 | # sampleformat = 44100:16:2 #(optional) 143 | # codec = flac #(optional) 144 | # buffer = 300 #(optional) # server buffer (ms) 145 | # chunk_ms = 26 #(optional) 146 | ``` 147 | 148 | --- 149 | 150 | ## 6 · Point Snapclient at the DAC 151 | 152 | ```bash 153 | sudo usermod -aG audio snapclient # grant ALSA access 154 | 155 | sudo tee /etc/snapclient.conf >/dev/null <<'EOF' 156 | [snapclient] 157 | host = localhost 158 | sound_device = hw:0,0 # change if card index differs 159 | # buffer = 80 # optional client buffer (ms) 160 | EOF 161 | ``` 162 | 163 | --- 164 | 165 | ## 7 · Start the services 166 | 167 | ```bash 168 | sudo systemctl enable --now snapserver snapclient 169 | ``` 170 | 171 | Live logs: 172 | 173 | ```bash 174 | journalctl -u snapserver -f # “… starting /usr/bin/shairport-sync …” 175 | journalctl -u snapclient -f # “… Connected to … hw:0,0 …” 176 | ``` 177 | 178 | --- 179 | 180 | ## 8 · Snapweb UI 181 | 182 | Open **[http://audiopi.local:1780](http://audiopi.local:1780)** 183 | 184 | * **Streams** – should list *AirPlay* 185 | * **Clients** – should list *audiopi* with live meters & volume 186 | 187 | --- 188 | 189 | ## 9 · AirPlay test 190 | 191 | * **macOS / appple music** → **AirPlay** 192 | * **iPhone / iPad** → apple music → **AirPlay** 193 | Snapweb flips to *playing* and audio starts after ≈ 0.4 s. 194 | 195 | --- 196 | 197 | ## 10 · Add more rooms 198 | 199 | On another Pi (e.g. Pi Zero 2 W + MiniAmp): 200 | 201 | ### 10.1 Flash & first boot 202 | 203 | *Imager settings* 204 | 205 | ``` 206 | OS : Raspberry Pi OS Lite (32‑bit, Bookworm) 207 | Hostname : pizero-mini # must be unique 208 | SSH : enabled 209 | Wi‑Fi : your credentials 210 | ``` 211 | 212 | ```bash 213 | ssh pi@pizero-mini.local 214 | sudo passwd pi 215 | sudo apt update && sudo apt full-upgrade -y 216 | ``` 217 | 218 | ### 10.2 Enable the MiniAmp overlay 219 | 220 | ```bash 221 | sudo nano /boot/firmware/config.txt 222 | # add: 223 | dtoverlay=hifiberry-dac # MiniAmp overlay 224 | ``` 225 | 226 | Reboot and confirm `aplay -l` shows **sndrpihifiberry**. 227 | 228 | ### 10.3 Install Snapclient 0.31 229 | 230 | ```bash 231 | cd /tmp 232 | wget https://github.com/badaix/snapcast/releases/download/v0.31.0/\ 233 | snapclient_0.31.0-1_armhf_bookworm.deb 234 | sudo apt install ./snapclient_* -y 235 | ``` 236 | 237 | ### 10.4 Create a dedicated config 238 | 239 | ```bash 240 | sudo usermod -aG audio snapclient 241 | 242 | sudo tee /etc/snapclient.conf >/dev/null <<'EOF' 243 | [snapclient] 244 | host = audiopi.local # master Pi 245 | sound_device = hw:0,0 # card index from `aplay -l` 246 | buffer = 120 # Wi‑Fi cushion (ms) 247 | EOF 248 | ``` 249 | 250 | ### 10.5 Enable & start 251 | 252 | ```bash 253 | sudo systemctl enable --now snapclient 254 | journalctl -u snapclient -f # look for “Connected to audiopi.local:1704 …” 255 | ``` 256 | 257 | ### 10.6 Join the group 258 | 259 | 1. Open **Snapweb → Clients** on the main Pi. 260 | 2. Drag **pizero-mini** onto the default group tile. 261 | 3. Adjust its volume slider — it plays in sync immediately. 262 | 263 | > Repeat for as many extra Pis as you like. Just give each one a **unique hostname** and point `host = audiopi.local` (or your server’s IP) in `/etc/snapclient.conf`. 264 | 265 | --- 266 | 267 | Happy listening! 🎶 268 | --------------------------------------------------------------------------------