Synchronised multiroom audio for a home LAN: MPD writes PCM into a FIFO, Snapserver re-encodes it to FLAC and streams it to Snapcast clients.
The server stack lives in stellwerk/ and runs as two containers on a
Synology NAS. The clients are Raspberry Pis with HiFiBerry boards running nothing
but snapclient.
this PC ─ PCM over TCP :4953 ─┐
▼
NAS (docker compose)
├─ mpd ─────► /fifo/mpd ──► snapserver ──► FLAC over LAN
└─ snapserver │
▼
Zone 1: Zero W + Digi2 Pro
Zone 2: Zero + DAC+ Zero
Zone 3: Pi 3 + Amp2
Two live inputs by default: the MPD Library (a FIFO) and a PC source
(any machine streaming PCM to TCP 4953). A meta stream, Auto, follows
whichever is playing — a PC cast wins, MPD is the fallback. A third leg,
Qobuz (the qbzd daemon), is kept in the tree but dormant; see
Sending this PC's audio and
docs/dual-qbzd.md.
Full build instructions, including the per-Pi client runbook, are in
snapcast-build-plan.md.
Snapserver listens on TCP 4953 and waits; stream PCM to it from this machine with the helper:
SNAP_HOST=nas.local stellwerk/clients/pc-to-snapcast.sh # or localhost, for a local testIt captures the default sink's monitor (everything you hear) as s16le/48000/2
— exactly the 48000:16:2 wire format — via PipeWire/PulseAudio parec piped to
ncat. To stream a single app, route it to a null sink and point SOURCE at
that sink's .monitor. Snapserver buffers ~800 ms, so PC audio lands ~0.8 s
late: fine for music, expect lip-sync drift on video.
stellwerk/
├── compose.yaml the stack — image tags only, no build context
├── compose.build.yaml PC only, adds the build context for mpd
├── .env site-specific values (MUSIC_DIR, tags, TZ)
├── mpd/
│ ├── Dockerfile alpine + mpd + mpc + tini
│ ├── .dockerignore
│ └── mpd.conf mounted at /config, not baked into the image
└── snapserver/
└── snapserver.conf mounted at /etc/snapserver.conf
The whole directory is self-contained: Compose resolves every relative path
against compose.yaml, so stellwerk/ can be copied anywhere as one unit.
A Snapcast pipe carries a single immutable sample format. If MPD's output format is unset it writes each file's native rate, the byte stream changes shape mid-playlist, and a 96 kHz track on a 48 kHz stream plays at half speed an octave down.
48000:16:2 must appear identically in three places:
| Where | Setting |
|---|---|
stellwerk/mpd/mpd.conf |
audio_output { format "48000:16:2" } |
stellwerk/snapserver/snapserver.conf |
source = ...&sampleformat=48000:16:2 |
| each Pi | snapclient prints the format on connect — check it |
.env cannot set this: both config files are static and do not expand
environment variables.
cd stellwerk
docker compose -f compose.yaml -f compose.build.yaml build mpd
docker compose up -dmpd is the only image built here. snapserver is referenced upstream by its
fully-qualified name, so up pulls it on its own — there is nothing to retag.
.env ships pointing MUSIC_DIR at ../test_music_ogg so this works out of the
box. Snapweb comes up on http://localhost:1780.
The mpd image build fails deliberately if the Alpine mpd package lacks the
soxr resampler — without it MPD silently ignores samplerate_converter and falls
back to its mediocre internal converter, which you would not notice by ear for
months. If it fails, switch the base to debian:trixie-slim.
Both mpd and snapserver are built here and shipped as files — there is no
official Snapcast image, so snapserver is our self-built stellwerk/snapserver,
not a registry pull (see stellwerk/snapserver/Dockerfile for why). Nothing on
the NAS is pulled. qbzd is dormant and not shipped at all. Both sides are x86_64
(DS216+ is a Celeron N3050), so no --platform juggling is needed.
compose.yaml has no build: key, so the NAS never builds. If an image was not
loaded first you get pull access denied for stellwerk/mpd (or .../snapserver)
— that reads like an auth failure but only means the load step was skipped.
# PC
cd stellwerk
docker save stellwerk/mpd:1.0 stellwerk/snapserver:1.0 | gzip > images-1.0.tar.gz
scp -r . admin@nas.local:/volume1/docker/stellwerk/
# NAS
ssh admin@nas.local
sudo -i
cd /volume1/docker/stellwerk
gunzip -c images-1.0.tar.gz | docker load
sed -i 's|^MUSIC_DIR=.*|MUSIC_DIR=/volume1/music|' .env
docker compose version && docker compose config # Container Manager ships an
docker compose up -d # older Compose than a desktopNo SSH needed.
- PC:
docker save -o stellwerk-images-1.0.tar stellwerk/mpd:1.0 stellwerk/snapserver:1.0, andzip -r stellwerk-config.zip stellwerkfrom the repo root. Zip rather than uploading files one by one —.envis a dotfile and survives the round trip that way. - Container Manager → Image → Add → Add From File: upload the
.tardirectly from the browser. Confirm both land asstellwerk/mpd:1.0andstellwerk/snapserver:1.0; the tags must matchcompose.yamlexactly. Do this before the project exists. - File Station: upload
stellwerk-config.zipinto thedockershared folder, right-click → Extract here, giving/volume1/docker/stellwerk/. - File Station: right-click
.env→ Open with Text Editor → setMUSIC_DIR=/volume1/music. Do this before starting the project; the shipped value points at the repo's test files and does not exist on the NAS. - Container Manager → Project → Create: name it
stellwerk, path/volume1/docker/stellwerk, let it detect the existing compose file. If it insists ondocker-compose.yml, renamecompose.yamlin File Station — the content is identical either way. - Start it. Both images come from the files you loaded; nothing is pulled.
compose.build.yaml and mpd/.dockerignore ride along unused either way. They
are PC files and the NAS never builds.
Both images are self-built, so an image change is the same file round trip for
either one — there is no registry to pull a new tag from. The example below is
for mpd; swap mpd/MPD_TAG for snapserver/SNAPSERVER_TAG to update that one
instead.
# PC
docker build -t stellwerk/mpd:1.1 ./mpd
docker save stellwerk/mpd:1.1 | gzip > mpd-1.1.tar.gz
scp mpd-1.1.tar.gz admin@nas.local:/volume1/docker/stellwerk/
# NAS
gunzip -c mpd-1.1.tar.gz | docker load
sed -i 's|^MPD_TAG=.*|MPD_TAG=1.1|' .env
docker compose up -d
docker image pruneConfig-only changes need none of this. mpd.conf and snapserver.conf are
mounted, not baked in, so edit and restart:
docker compose restart mpddocker compose ps
docker compose logs -f mpd
docker compose exec mpd mpc update
docker compose exec mpd mpc stats
docker compose exec snapserver snapserver --version
docker compose downBoth containers run as their images' own unprivileged users — there is no uid
matching, no PUID/PGID, and no permission-fixup entrypoint. Two consequences
worth knowing:
- Music must be readable by the container's
mpduser. On the NAS that means the music share needs to be world-readable (chmod -R o+rX /volume1/music), or MPD will report 0 songs aftermpc update. - The FIFO is created by snapserver, which runs as its own user. If
docker compose logs mpdshows a permission error on/fifo/mpd, give snapserver the sameuser:as mpd, orchmod 666the pipe.
| Symptom | Check |
|---|---|
mpc stats shows 0 songs |
MUSIC_DIR in .env; music readable by the mpd user |
| FIFO missing | mode=create on the snapserver source, not on both sides |
| Audio wrong speed or pitch | the three 48000:16:2 strings disagree |
| Snapweb empty | snapserver.conf not mounted — docker compose exec snapserver cat /etc/snapserver.conf |
| Port already in use | another DSM service on 1780; drop network_mode: host and remap |
pull access denied for stellwerk/mpd |
image never loaded on the NAS |
Snapserver uses network_mode: host. DSM already runs avahi and will contend on
5353; if discovery misbehaves, drop host mode, publish 1704/1705/1780 explicitly,
and hardcode the NAS IP in each client's SNAPCLIENT_OPTS — which the client
setup in the build plan does anyway.
Snapcast's protocol is stable across minor versions, but pin the server rather
than tracking latest, and install a matching client .deb on each Pi. Check
what is actually running with docker compose exec snapserver snapserver --version.