There are many ways to turn your Raspberry Pi into a sound system. Here are some of the options I considered before arriving at my current setup.
The Raspberry Pi is a tiny, flexible, rather powerful single-board computer that can turn its hand to many applications. I’ve got one in the cellar logging the temperature and air humidity and, one of these days, plan to put together a weather station for the balcony. However, one use case I’ve had my eye on for a long time has been a wifi speaker.
As I found out, the options are very varied, which is great: with my Sonos speaker in the kitchen, if it doesn’t have a feature I want, there’s no way of adding it. If the software is unsupported or the logic board dies, then the speaker dies too. But all this flexibility can be overwhelming. The only way I could find out what was right for me was to dive in and try them all out. Hopefully, I’ll be able to save you some of the experimentation: in this article, I’ll give an overview of some options I considered, and in the future I’ll go into more detail about how I set them up.
Broadly, when choosing an approach, you need to decide how to get sound out of your Raspberry Pi and whether to go for a dedicated operating system distribution or install the individual pieces of software yourself.
How are you going to get sound out of your Raspberry Pi?
The Raspberry Pi doesn’t have very good onboard audio, but that’s not a problem. You can buy a digital audio converter (DAC) that connects via the GPIO pins (the bit of the Pi that looks like a bed of nails), or use an external USB sound card.
I’ve got two setups, both of which use the first variant: one with the HifiBerry DAC 2 Pro, and the other with the HifiBerry AMP 2. These have both worked very well so far and the hardware is easy to set up: you just push the DAC or amp onto the GPIO pins and connect the cables.
- If you have a hifi amplifier to connect your Pi to, then you need the DAC.
- If you have passive speakers (hifi speakers with no amp) then you’ll need one of the HifiBerry amps and a power supply.
The latter setup is quite elegant because it delivers hifi-quality sound and takes up very little space. If you’re buying speakers, don’t forget to order cables – just make sure they aren’t too thick because otherwise they won’t fit into the amp connectors.
(A few years ago, I briefly had a setup which used an external USB soundcard from Creative Labs and that worked too. I can’t remember how I set it up though!)
A Raspberry Pi 3B or Raspberry Pi 4B should work just fine. You can, apparently, use a cheaper Raspberry Pi Zero or ZeroW but this is best only for simple setups, say a wifi speaker without the ability to play back MP3 and other audio files.
Which software do you want to use?
A barebones system should, depending on what devices you already have, be able to play audio from your smartphone or other device via AirPlay or similar (afaik DLNA is the Android equivalent). For many people, this will be enough: you can then select, pause, play and skip tracks, find radio stations, change the volume etc. from your usual device. One detail that infuriates me about my Sonos speaker with Spotify connect is that you can’t change the speed that podcasts play at. With this setup, you can.
Additionally, you might want MPD, the Music Player Daemon. This is an open-source music service you install on your Pi, which plays your music and can be controlled via an MPD client. It’s rather complex to setup yourself unless you’re fine with a very outdated version (more later). I use Rigelian as an MPD client: it’s the most user-friendly one I could find and is regularly maintained.
Other options I haven’t explored yet are support for Spotify Connect (for which you need a premium account) and some means of playing audio over the wifi from an Android device, which might be useful for guests.
A dedicated distribution or do-it-yourself?
You have two main options to achieve the aforementioned setup.
One is to choose a purpose-built distribution and dedicate your whole Pi to being a sound system. Instead of installing an operating system, such as Raspberry Pi OS, and installing software on that, the audio system is the operating system. You just write it to an SD card (ideally using the excellent Raspberry Pi Imager), fire up your Pi, and with a bit of luck you’re good to go.
If it works and you’re happy with the setup, this is a great option because you don’t have much maintenance to worry about. You often get a web interface to administer your music with, which can be useful. If you use a HifiBerry device, HifiBerryOS is ideal. It has a beautiful web interface, is easy to set up and the support team responds very quickly to questions on their forum (even at weekends). It incorporates MPD and Shairplay-sync and offers Spotify Connect as well as DLNA out of the box.
However, it doesn’t let you store music on your SD card. While you can use a USB storage device, you can’t share this with the rest of the network. The ideal setup is to have a NAS on your network, where you store all your music, and connect to that. I found HifiBerryOS somewhat unpredictable when music wasn’t recognised supported formats are not documented anywhere. I tried Moode and a couple of others, but they didn’t work out of the box, or the interfaces were not to my taste, or both. That said, if you can alternatively ignore the interface and use an MPD client (which is an app on your smartphone or computer). If you’re playing audio from your phone via wifi or Spotify connect, then you don’t need to worry about where music is stored or what the interface is like.
If you want to use your Pi for anything else besides being a music player, or setup a Samba share to share your files across the network, then you’ll have to take the more involved approach. This is quite fiddly, but more rewarding. And let’s face it: if you have a Raspberry Pi it’s not because you eschew a bit of tinkering. Mostly, you have to be able to follow instructions very precisely, and have a good understanding of the Linux command line. This is necessary to install some programs from source and set the required options.
The setup I chose is:
- Raspberry Pi 3B with HifiBerry AMP in the spare bedroom; Raspberry Pi 4B with DAC2 Pro in the living room
- Raspberry Pi OS Lite (command line only)
- MPD (installed from source to get the latest version)
- Shairplay-sync for AirPlay support (also installed from source)
- I bought an IR receiver and use an old Apple remote control, which required me to write a bit of Python and do some research into recognising IR devices but it works (touch wood) now
I’ll go into more detail on how I set it up in later posts, so watch this space!