Playing your music in every room of your house in sync, wouldn't that be nice? A multi-room audio system makes this possible. No wires are needed, because the music can be distributed via wifi. Just tap on your phone to play your favorite song. There are many whole home audio systems available today, like the well-known audio system Sonos.
I already had audio setups in my living room, kitchen and hobby room. Each setup consisting of a GNU/Linux computer, an amplifier and speakers. But these where stand-alone audio setups that could not play in sync.
Then I discovered Snapcast. With this software in conjunction with the Music Player Daemon (MPD), you can build your own multi-room audio player. In my case there was no need to buy extra hardware. And wow, this is fun! And it works great!
On this page you can read about how I set up my whole home audio system. In case you want to build one yourself, I hope you will find some useful information here.
Note: MPD and Snapcast (Snapserver and Snapclient) can run on Windows too, but this project is only about MPD and Snapcast on GNU/Linux.
All my music is stored on my server. This computer is running 24/7. See also my NAS project. You can use any GNU/Linux computer to serve your music. I will refer to this computer as the server.
The music on the server is played by the Music Player Daemon (MPD). MPD sends the audio to the Snapserver. In the default configuration of MPD, the audio is sent to the internal sound card. We will use this for testing.
The Snapserver streams the audio from MPD to the different Snapclients over the home network (LAN). At the same time it assures that the clients are synchronized, so that the audio is played in sync.
The music you hear comes from the Snapclients. I use these clients on my Linux Mint desktop computers (in different rooms) and on my laptop. The Snapclient runs in the background and just plays all the audio that the Snapserver is streaming.
With the MPD client you can control what music is playing. Just browse the MPD music library and choose what you want to hear. Listen to a single track, a playlist, an album or your complete music collection. There are several MPD clients that run on your computer (GNU/Linux, Windows 10 and macOS) or on your smartphone.
Snapweb lets you control the volume of each Snapclient. In other words: with Snapweb you can control the audio levels in the different rooms of your home. It is a web-app so it runs on all devices with an internet browser.
Home network (LAN)
The music is streamed over the home network or Local Area Network (LAN). The home network is also used for the communication between the different clients and servers mentioned above. So every device of your multi-room audio system must be connected to the home network, either with a network cable or via wifi.
The easiest way to install the Music Player Daemon (MPD) is by using your package manager. But it is also possible to build MPD from source. Check the MPD website for instructions. Install MPD on the server.
How to configure MPD (works on Debian 10)
The location and name of the MPD configuration file is /etc/mpd.conf. Only change the information below. You need to be root to do this.
# Files and directories
# Comment out the next line to solve client connection problem
# bind_to_address "localhost"
# Set output of MPD to input of Snapserver
name "my pipe"
# Test audio output
name "My ALSA Device"
device "hw:0,0" # I had to change this to "hw:1,0"
After saving, restart MPD on the command line as root. On Debian-based systems type:
# systemctl restart mpd.service
Now it is time to test if MPD is working. You can use any MPD client for testing. Below you find some tests, using the command line client MPC. MPC only runs on GNU/Linux.
How to test MPD with MPC
Run the tests below as a regular user. The output as it should be, is shown under each command.
Test if you can connect to MPD:
$ mpc -h <server-name>
volume:100% repeat: off random: off single: off consume: off
Update the MPD music database:
$ mpc -h <server-name> update
Updating DB (#1) ...
volume:100% repeat: off random: off single: off consume: off
Add all your music to the MPD queue:
$ mpc -h <server-name> add /
Now you can play your music. To test this, connect speakers or a headphone to the sound output of the server. Then type:
There are several MPD clients. You can find an overview of MPD clients on the MPD website. To connect to MPD you need to configure the name of the server where MPD is running. How that is done, depends on which MPD client you use.
There are MPD clients for your computer: GNU/Linux, Windows 10 and macOS but also for smart phones: Android, iOS and Ubuntu Touch.
On my GNU/Linux computers I use mpdevil. See the screen shot below (click to enlarge).
If you have an Android phone you can use M.A.L.P. or MPDroid to control your multi-room audio player. See the screen shot below (click to enlarge). You can install these apps from Google Play or even better from the free software "app store" F-Droid.
I installed the Snapclient on my Linux Mint computers using the package manager. The Snapclient was started automatically by systemd during boot. But I got no sound. I tried several outputs, using the -s option, with no result. Running the Snapclient as a regular user, worked for me.
How to auto start Snapclient as regular user (works on Mint 20)
M.A.L.P. can show the album cover of the album that is playing. It uses MusicBrainz or Last.fm to fetch the album art. But M.A.L.P. can also show the album art from your own collection.
How to show your own album art with M.A.L.P.
Your music collection including your album art must be available via a web server (how to do this is outside the scope of this web page).
In the M.A.L.P. Profiles settings, enable: Prefer HTTP cover files.
And enter the cover path like this:
If you do not specify the name of the album covers, M.A.L.P. wil search for files with name: cover, Cover, folder and Folder, with extension: jpg, JPG, jpeg, JPEG, png and PNG.
Problem with encoded slashes
The %d part of the URLs that M.A.L.P. uses to fetch the album covers, contain encoded slashes (this means / is encoded as %2F). In my web server setup encoded slashes were not supported and my album art was not found. To solve this problem, I added the following to the VirtualHost configuration of Apache: