I always wanted to have an audio multiroom, which would allow me to play the same music in all rooms, but also provide the ability to control each room separately (on/off, volume, etc.). Obviously, I could buy one of the existing systems like Denon Heos, but then I would need to remove/sell my old audio equipment, which is working perfectly fine. I could also buy Chromecast Audio and create an audio group - but it seemed like a “too easy” solution. Fortunately, one of the presentations from this year code.talks conference gave me the inspiration and direction for building my own multiroom system, based on Raspberry Pi devices.
I started with some requirements:
- use current audio devices (with line input),
- Spotify as the main source of music, but not the only one,
- control everything from an Android device (and desktop app),
- relatively cheap.
Broadcasting software
After some research and testing, I think that Snapcast is currently the best solution for this use case. Here is why:
- open source
- easy setup and configuration
- Raspberry Pi support
- Android app as a controller
Music source software
Although you can connect many players to Snapcast, I chose to use Mopidy. Such combination was already tested pretty well by other geeks. Mopidy is also quite new open source software with a vibrant community. It supports not only Spotify but also Soundcloud, Google Play and mp3/flac files. Integration with Snapcast is just a matter of one line in the configuration.
Overall solution
After some struggling, the overall solutions looks like below:
One Raspberry Pi is working as a Snapserver and Snapclient at the same time, with Mopidy service for music management. The other Pi’s are simple clients, that could be added/removed dynamically, they just need to be in the same network.
Problems
Of course, not everything works like in the tutorials. I want to share some of my findings, maybe it can save your time.Raspberry Pi sound output quality
With Raspberry Pi you usually have 2 audio outputs: HDMI and mini jack. You can easily switch between them thanks to raspi-config, but the jack output has some problems with sound quality. So after installing the Raspbian system, I strongly recommend putting a magic line `audio_pwm_mode=2` to `/boot/config.txt` file. This way you will not waste a lot of time with wondering why audio stream with 48000Hz sampling sounds like music played from a megaphone.Raspberry Pi time synchronization
If you notice a strange behaviour with losing sound stream on Snapclient devices, this is probably because of time synchronization mechanism on Raspbian system. In my case after Raspberry Pi boot, I was losing the sound stream for about 1 minute, after restarting the device. It’s the `Systemd-timesyncd` service caused it. This problem is a known issue with a few workarounds:- don’t reboot Pi too often :),
- change the time synchronisation service to something else (maybe ntpd) with more gentle time sync mechanism - not tested,
- turn off time synchronization service.
Troubleshooting
I suppose it is obvious, but in case of any problems check one thing at a time: start with Mopidy, then check Snapserver using only a single wave file as a source and then Snapclients. In most cases, service logs are enough to see what is going on, so don’t forget about the `journalctl` command.User interface
As usual with open-source, the biggest problem was with the UI. It must be useful not only for geeks, but for normal human beings as well. At this point I tested 2 mobile apps:- Mopidy Mobile
- MPDroid.
Brak komentarzy:
Prześlij komentarz