locxter.net

Build your own multi-room sound system with Snapcast

2023-04-13

By now, everyone should have seen multi-room sound systems (like Sonos makes them) and understood that they are pretty damn cool. However, they also are mighty expensive - especially if you already have good speakers around your house - and usually lock you into a proprietary ecosystem, which makes them quite a hard pill to swallow. Thankfully, we can build our own, fully open source and configurable multi-room sound system with Snapcast for a fraction of the cost...

Snapcast is flexible multi-room audio player that is based on a client-server architecture, where a single or multiple audio signals are fed to the server, which synchronizes all clients and forwards the audio to them based on audio stream groups. Audio sources can be Line-In, AirPlay and Spotify directly or more advanced music servers like MPD and Mopidy , which intern support playback of local and streamed music from different sources. While the the server should run on Linux (possibly a low-power Raspberry Pi), clients are available for all major systems including Windows , Android and even iOS (although paid). This makes the system very flexible/extensible and allows for repurposing of abandoned hardware like outdated smartphones or laptops as cheap clients (although possibly with the caveat of security).

Personally, I was only searching for quick, temporary solution to stream audio from my laptop to several bluetooth speakers, which is why I went with the simplest solution possible. Here's what I did:

  1. I installed the server on my laptop via sudo apt install snapserver and disabled my firewall with sudo ufw disable for testing purposes (otherwise open the ports 1704 and 1705).
  2. I installed the client on two Android phones, one Windows PC and one other Linux laptop via the links from above and sudo apt install snapclient respectively.
  3. I disabled the the daemons with sudo systemctl disable snapserver.service and sudo systemctl disable snapclient.service respectively.
  4. I added the required PulseAudio pipe sink to the server with pacmd load-module module-pipe-sink file=/tmp/snapfifo sink_name=Snapcast format=s16le rate=48000 && pacmd update-sink-proplist Snapcast device.description=Snapcast and started Snapcast via snapserver .
  5. I started all the clients and connected them to the server via the automatic search or by manually entering the IP address of my laptop.
  6. I connected the clients via Bluetooth to their dedicated speakers and played some nice tunes from my laptop throughout the whole house.
  7. Afterwards, I simply stopped the clients and server, deleted the pipe sink via pacmd unload-module module-pipe-sink and re-enabled my firewall with sudo ufw enable .

Honestly, I was quite surpised how easy it was to get everything up and running as well as how stable the whole system worked. I never experienced any dropouts and the latency compensation also performed very well. This excellent performance in a somewhat shitty setup is also why I write this article, as I am just overall very impressed by this system. If you want to run Snapcast in any kind of permanent installation though, I would highly recommend you to take a deeper look at their GitHub as well as Mopidy for a more sophisticated setup. If you have any personal experiences with Snapcast, feel free to let me know about them in the comments below...

RSS feed