Build your own multiroom audio system with raspberry pis – A beginner friendly tutorial

The goal of this article is to give a beginner friendly tutorial how to set up your own multiroom audio system and to explain some basic advantages and limitations of the setup.

If you google how to build a DIY multiroom audio system, you’ll quickly find out that there are many different options available. After a bit of research I decided to use snapcast, because it is reliable and actively supported (open source). It has Spotify support too!

What you’ll need

  • Raspberry Pis for every room (any generation works, but one of them should be a Pi 2 or newer)
  • Raspbian on every Pi with terminal access, either by connecting a display and input or via SSH (Tutorial)
  • And of course, speakers for every room

Snapcast works with a server-client principle. You need one pi with the server software, called snapserver, and every Pi needs the client software, called snapclient. The server instance can be hosted on a pi which is also a client. I recommended running the server on a Pi 2 or newer with a solid connection to your router (preferably via LAN or if via WLAN nearby), otherwise you might have some audio stutters every few minutes.

Install the client software on every Pi

You first need to find the download URL of the latest release. Go to https://github.com/badaix/snapcast/releases/latest and save the link location for the package called something like “snapclient_x.x.x_armhf.deb”.

Open up a terminal on the pi (e.g. via SSH). To download the package to your pi, you can use the command “wget ” followed by the URL. Then you have to install the downloaded package by using “sudo dpkg -i ” followed by the name of the package, which currently has this format: “snapclient_x.x.x_armhf.deb” (its name is at the end of the URL too). If the installation fails with an error that dependencies are missing, you have to install those with the command “sudo apt-get -f install“. As of writing it looks like this:

 
wget https://github.com/badaix/snapcast/releases/download/v0.14.0/snapclient_0.14.0_armhf.deb
sudo dpkg -i snapclient_0.14.0_armhf.deb 
sudo apt-get -f install

Repeat those commands for every pi you want to connect speakers to.

Install the server software

This is very similar to installing the client software, so I’m shortening this a bit. Find the package download URL again by visiting the same URL as above but this time selecting the package called something like “snapserver_x.x.x_armhf.deb”. Download and install it using the same commands. Currently it looks like this:

 
wget https://github.com/badaix/snapcast/releases/download/v0.14.0/snapserver_0.14.0_armhf.deb
sudo dpkg -i snapserver_0.14.0_armhf.deb 
sudo apt-get -f install 

You only have to do this on one pi, the “server” pi.

Configure your audio sources

Here’s a link to the official snapcast docs how to do it. The most interesting inputs for me are

  • Spotify, which works by using the library librespot and needs a spotify premium account. I’ve made a section below how to install it, which goes a bit more in depth than the docs.
  • Mopidy, which calls itself an “extensible music server” and supports multiple audio inputs, e.g. local files, spotify (premium), podcasts and more. Here’s how to setup mopidy on your “server” pi. You can find out how to configure it to work with snapcast in the above mentioned docs.
  • Apple Airplay, it allows you to stream with your Apple devices.

Spotify

What the “librespot” library does is basically tricking Spotify into thinking your raspi is a Spotify speaker. Because of this, it is a bit unstable every few days. I wrote more about that in the conclusions section below.

The easiest way to get it up and running is to use raspotify, which is just a wrapper that makes the installation easier on raspis. If you followed the steps there and now enter “librespot” in your terminal and it doesn’t return “command not found”, it’s successfully installed. You now have to configure it so it uses the snapserver as its output. Enter the file “/etc/default/snapserver” with a editor of your choice, e.g. “sudo nano /etc/default/snapserver” and modify the line starting with “SNAPSERVER_OPTS=” that it looks like the following:

 
SNAPSERVER_OPTS="-s spotify:///librespot?name=Spotify&devicename=Home"

If you want multiple inputs, just add them like this: SNAPSERVER_OPTS=”-s spotify:///librespot?name=Spotify&devicename=Home -s airplay:///shairport-sync?name=Airplay”

Restart the snapserver service with “sudo service snapserver restart“. Open your spotify app (you have to be in the same network) and you should see a new device called “Home” (feel free to modify the name above). If you start streaming music, it should start to play on every speaker after a few seconds!

Control snapcast

Snapcast has a really handy android app, which allows you to select the current input source and set the volume for each room. Especially handy if you quickly want to mute one room.

If you’ve set Mopidy up, you can install the Mopidy-Iris frontend, which has inbuilt support for controlling snapcast too. And least but not least, there is a integration for Home Assistant, if you’ve got it running.

Here is a list of all clients

My conclusions after four months of usage

As I love music I’m running snapcast nearly 10 hours a day. I have five rooms with different raspberry generations (1-3) and different speakers. I’m mostly using librespot as the input source and rarely mopidy.

What I dislike most is that librespot crashes from time to time; rarely multiple times a day, but at least once a week. This can be a bit annoying as I have to restart the playback or sometimes the snapserver itself. Great thing is the people behind it are quick to respond to issues and librespot is constantly improving. A list of reported issues is on GitHub.

Three times in the four months I had the problem that suddenly all speakers played a very loud noise, which gave me an adrenaline rush while sprinting to the raspberry running the snapserver and pulling the plug. I am unsure what caused this and it only happened while music already was playing (so not in the middle of the night), but this surely reduces the WAF.

But those are probably minor complaints in view of my power usage. After all I’m really satisified with the setup because snapcast per se works reliable and it’s completely free. It’s furthermore astounishing how synchronous the audio output is. If I walk from room to room I’m unable to hear a delay between the speakers.

If you’ve got a question about the setup or if you want to give me some other input, feel free to leave it below!

Optional: Make snapcast log librespot’s output

This section is more advanced, I’m just including it because I struggled for some time to find a solution to this. This is relevant if you’re running librespot with snapcast and want to log why librespot crashed. Snapcast does not log this by default if it’s run as a daemon, which is why I edited the service file. It is located under “/lib/systemd/system/snapserver.service”. Modify the lines starting with “ExecStart” and “Type” to look like the following:

 
Type=simple
ExecStart=/usr/bin/snapserver $USER_OPTS $SNAPSERVER_OPTS

It is not the most beautiful workaround, but now you can see librespot’s output with journalctl.

2 comments

  1. Good write up. Tried getting it to work last winter with Shairport, but had problems configuring Shairport to snapcast in the snapserver and forcing the audio output over the HDMI. Could force a wav or mp3, but was only having parts play and Hulk Smash won.

    Gonna rain all weekend, maybe I’ll give it another shot.

Leave a Reply

Your email address will not be published. Required fields are marked *