A config generator for a multizone audio system based on snapcast, Mopidy and MQTT.
Almost all media services run on a central media server.
Each media player is its own zone and there are also multiple (logical) "party zones" which group the real zones together. For more on logical zones see the snapcast-autoconfig README
The media server runs:
Snapserver is configured with:
The snapserver itself runs and manages the librespot
and shairport-sync
media services.
snapcast-autoconfig manages the snapcast groups (including, for the benefit of Iris, naming them!).
See BUILDING for notes on building some of these from sources.
/opt/librespot
Each media player runs:
http://<hostname>/
to http://<media-server>:66xx/iris
While snapcast meta streams are neat for auto-switching between audio services it's still confusing when, say, both a spotify and airplay stream attempt to play to the same zone. Instead, when one service starts playing we want the others (in the same zone) to pause.
To accomplish this each media service (mopidy, librespot, ...) is configured to notify via MQTT when playback starts.
See:
librespot --onevent librespot-event.sh...
Each media service (except librespot) can also be controlled via MQTT.
The idea for this came from hifiberry which implements control of concurrent playback streams via MPRIS.
~/.kodi/addons/
on the clientThe pausing of media streams is done by a simple MQTT service - though it could be implemented as:
For end-users only (per-service) soft-volume control is available.
Hardware volume levels are preset by snapcast-autoconfig.
Each snapclient is configured to use an alsa hardware mixer (if available).
While librespot
and shairport-sync
can both be configured to control a
hardware mixer the snapserver can't be, nor does it create a virtual mixer.
These requirements are sufficient to customize the configurations for your setup:
chevron
is a python implementation of the mustache templating language.
On first run if chevron
isn't found, make
will create a python virtual environment and install it for you.
The services are configured by generating systemd service files. Many of them are
template unit files
so that multiple instances can be started on a single host. (e.g. systemctl start mopidy@study
)
Configurations for each zone (and for all zones) are generated by merging the
config.json
data into the template files using chevron
.
You will need to adapt my existing json config for your purposes.
See also ALL_HOSTS
in the Makefile
.
:warning: This will overwrite ../snapserver.conf |
---|
make
All the services (except for nginx
) can be run and tested locally as an unprivileged user.
To install and run mopidy in a python venv you will need:
sudo apt-get install libspotify-dev
.venv/bin/pip install -r requirements.txt
Generate configs and start all services:
make dev
make dev-install # this will overwrite files in ~/.config/systemd/user!
# set `SYSTEMCTL_USER := --user` in the Makefile
make start
To start the services for just one zone:
# study only
make HOST=study start-host
Requirements: see #software.
:warning: This will overwrite /etc/snapserver.conf |
---|
On your production system, as root:
git clone https://github.com/markferry/multizone-audio.git /etc/multizone-audio
cd /etc/multizone-audio
git checkout $your_branch # your customizations
make live-install
For all client hosts:
git clone https://github.com/markferry/multizone-audio.git /etc/multizone-audio
cd /etc/multizone-audio
git checkout $your_branch # your customizations
Then run the client-specific-install make $os-$host-install
Where $os
is one of: debian
, dietpi
.
And $host
is a host defined in config.json
.
e.g.:
make dietpi-library-install