Replacing AirPlay with the Raspberry Pi

A number of years ago I decided to use AirPlay to stream audio through my condo. I picked the best solution for the time but had issues since day one. For a number of years I tolerated them, but I recently had enough. I have switched to a Linux-based solution using the Raspberry Pi and Snapcast. It works and sounds better, and uses open source software. It costs around the same, but potentially does more.

As soon as I began using AirPlay I realized that I would have to find my own ways of doing things. I have a lot of files in OGG Vorbis and FLAC formats, neither of which Apple supports. I also enjoy using the Music Player Daemon, and would far rather have used that than iTunes.

I wrote a simple article detailing how to play an MP3 stream. A few months later I wrote a more detailed article complete with shell script to make MPD work as an app running in Airfoil, a commercial product from Rogue Amoeba. This solution worked, but I always battled one thing or the other. My Apple TV would drop out. Sometimes sources would disconnect. It never ended.

One day I woke up to find that my Apple TV had updated its operating system. I felt pretty certain I had disabled automatic updates as everyone should. The update broke Airfoil and they did not have an immediate fix. I now had no audio for my analog stereo in the living room. I shuffled my Airport Expresses around, but I knew the end had drawn near.

I had such a great experience switching to Linux for my daily computing needs that I figured why not try it for whole house audio. I first considered PulseAudio over RTP, but read reports of mixed success and battles with network traffic. After a lot of searching and comparing I settled on Snapcast. The server simply takes raw PCM audio from a FIFO pipe and broadcasts it using FLAC. Clients then receive the synchronized stream and output it to an amplifier or speakers.

For hardware I used a Raspberry Pi. I ordered four, one for each of the AirPlay devices. I had one Apple TV and three Airport Expresses. The Pi has low quality audio, so I used the HiFiBerry. It took me a little to figure out which case to use. I recommend the stainless steel model. Better yet, just get the combo. As the tables below show, I ended up spending about the same abount of money for something with much more potential.

Cost of AirPlay Devices

Name Price Quantity Total
Apple TV 149.00 1 149.00
AirPort Express 99.00 3 297.00
Airfoil 29 1 29
Total     475.00

Cost of my Open Source Solution

Name Price Quantity Total
HifiBerry DAC+ Standard 28.90 3 86.70
HifiBerry DAC+ Pro 39.90 1 39.90
Raspberry Pi 39.90 4 159.60
Steel Case 24.90 4 99.60
SD Card (8 GB) 12.90 4 51.60
Power Supply 12.90 4 51.60
Total   489.00  

After a short amount of waiting my parts arrived. I installed the Snapcast server on my desktop. I installed the client on my desktop and on my Linux laptop to test it. I also installed the Android client on a tablet, and that came through in a pinch. The software worked flawlessly. To get MPD outputting to Snapcast I inserted the following in /etc/mpd.conf:

audio_output {
    type            "fifo"
    name            "Snapcast"
    path            "/tmp/snapfifo"
    format          "48000:16:2"
    mixer_type      "software"

When it comes to software I can solve any problem I need to, but when it comes to assembling hardware I feel like a bumbling fool. The blog claims you can do it in less than a minute, but it took a few attempts for me. The process involves connecting a board to each of the two parts of the case, then sliding them together and screwing everything into place. I eventually figured it out very late at night while rocking out to some eighties music. Truth to tell one still remains open to the elements, crudely connected to my beautiful boombox I’ve had since childhood. It seemed somehow fitting.

I installed the Snapcast client and everything went smoothly. The crown jewel came when I assembled the computer for my living room stereo using the HiFiBerry DAC+ Pro with its gold plated connectors. The lossless audio stream sounds stunning!

Now I have a little Linux powered computer in each area of my condo. I currently use them to stream audio everywhere, but they can do anything I can conceive of. This begins my journey to have an open source house. I wouldn’t want it any other way.