HydraPlay – Open Source Multiroom Audio

Reading Time: 5 minutes

This article will describe why i created a new software called HydraPlay. HydraPlay is a user interface for a multiroom audio setup which consists of Raspberry Pis, Mopidy instances, Pulseaudio and Snapcast.

Why another UI for Mopidy?

A couple of weeks ago i found a youtube video of Ryan Danzel, who showed a very nice multiroorm audio solution based on snapcast. After long google investigations i finally found a piece of code at GitLab. I was not able to get it running, because i didn’t understand how the software communicates with snapcast, while the mopidy communication was done by MQTT. First i liked the idea of using MQTT, because this would make the communication more transparent related to port configurations of multiple Mopidy instance on a Raspberry Pi. At the end i came up with using JSONRPC as communication protocol. Snapcast and Mopidy are able to communicate over JSONRPC (2,3) while Mopidy delivers a JavaScript library with web socket support for it, Snapcast only speaks with native TCP sockets. Ouch…! So i needed another piece of software, it routes web socket connections to the TCP/IP interface of sncapcast. For this job the setup uses Websockify as Websocket-Proxy between Snapserver and HydraPlay.

How things are hooked up

Ryans UI code was based on JavaScript by using the react framework. During studying the code i learned a lot about MQTT and react.js. But at the end i decided to switch over to Angular 7. I also need to migrate the FabScan UI to Angular 7 one day, so this was a nice exercise for me to learn Angular 7. I ended up by using only the CSS and HTML parts of the original code. A big thanks you to Ryan Danzel for his great work!

Lets start with the Hardware Setup.

I used 3 Raspberry Pi’s for my initial setup. One of the Pi’s as server the others as audio clients. I have ceiling speakers installed at the ground floor of my house, so the wiring is centralised at the basement. That is the point where i installed the Raspberry Pi’s in a self printed mini rack found on Thingiverse.

For amplification of the audio signal i used Pimoronis phat beat.You can also use normal active speakers connected to the Raspberry Pis audio jack. I am using this HAT because, as i mentioned before, i am using passive wall/ceiling speakers. My solution is quite good for ambient music and listening to radio stations on Tune-In. For the Party mode i am planing to have a wireless Raspberry Pi Zero connected to my Teufel 5.1 surround system.

Finally everything is hooked up on some self build rails rails.

I know wiring looks a litte bit messy but it works…

Server Side Software Setup

I started with a clean Raspbian installation on a Raspberry Pi 3B+. I strictly recommend to use a Raspberry Pi 3B+ or the new Raspberry Pi 4 Model B here, because there will run a lot of services in parallel on the system. Every steam is represented by a Mopidy instance.

The Software Setup consists of Pulseaudio which will provide the audio sinks for the Snapcast Server. Snapcast Server is the Heartbeat of the project. It provides all the multiroom audio magic behind the scenes. I use multiple mopidy instances as audio stream provider. Each stream provider can provide audio from multiple audio sources, like spotify, tunein or local stored mp3s. There are a lot of plugins available to extend mopidy in a way that it can provide other possible sources.

You can find detailed installation Instructions on GitHub. Hopefully I will be able to create a bash script or even better a running docker configuration to make the basic setup easier for Linux newbies.

Client Side Software Setup

The software setup on the client side is straight forward. Just install a plain minimal Raspbian on the Raspberry Pi. If you are using the Pimoroni pHAT beat, like on the picture above, you need to install the pHat beat drivers. Simply follow the instructions on the „Getting Started“ Guide on the Pimoroni Blog.

Finally you need to install the Snapclient on the Client side Raspberry pi. Thats all. If all components are hooked up the setup should be able to run.

Testing the Setup

How to select a new stream/source for a player/zone.

Now you are able to connect to the player by pointing your Browser to the local IP address of your Snapcast Server and the port of the running HydraPlay daemon. (e.g. https://192.168.1.10:8080).

You should the the User Interface of HydraPlay, which shows as many audio players as clients are configured. If you click on the cover icon of a player, the media library will open. You are able to select a stream (source) to play on the selected player. Use the search to browse the library.

HydraPlay Media Library with TuneIn search results.

HydraPlay only support Tune-In by now. But it should be simple to integrate the Mopidy Spotify Plugin. I am using HydraPlay for a couple of month now and I can say that the basic setup is doing a good job.

I will do further development when I have the time or I need new features on HydraPlay. But if you are a programmer and you want to contribute to the project feel free to contact me on GitHub or leave just a comment here.

UPDATE: Spotify works out of the box, only the cover art work is not working, because the data structure in Mopidy differs from the one of TuneIn. There is already a branch where i am working on a Spotify integration on GitHub.

9 Gedanken zu “HydraPlay – Open Source Multiroom Audio

  1. Hi Mario,
    this is a great project! I bought a Pirate radio and until now only used the standard setup, but I thought it should be fairly easy to build up a multi-room solution with it. And: here it is 🙂
    I will try that out when I have time (which is always short;-)) and will give you feedback how it works…
    See you!
    -Kai

  2. Hi Mario, thanks for writting this article, and i like to try this Docker image. But i´m not able to download it,,“manifest unknown“ . I looking for this a verry long time and i think you have created what i need. Please let me know where i can download your docker image. Thanks Rg Frank

    • I just updated the code. There is a working Docker setup now! Unfortunately no ready to use image but instructions how you can build the image.

  3. Hey

    This is a super cool project! I am running a Snapcast and mopidy docker on my unraid server and want to deploy this to an Nginx container.

    I am wondering if you would be able to help me deploy this with existing services?

    I don’t know much about web development as I am a SQL developer but I have made done some web dev in the past

    Cheers
    Danny

  4. Even after reading up a bit on snapcast, I’m still unsure as to whether this would work for _any_ media? I.e. I’d like to play something (anything, MIDI file, TV show, Spotify, whatever) on the laptop and have a way of outputting that on any combination of Raspis I choose. Would this be the correct solution for that use case?

    • You can use it for any media which can be handled by mopidy. Have a look at the available mopidy extensions for more information.

      I just released a new version of HydraPlay. It is easier to use now.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Kommentare werden moderiert. Es kann etwas dauern, bis dein Kommentar angezeigt wird.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.