Recycling your old speaker system into an Airplay-enabled device

I have this old beast in my bathroom, with an iPod dock (old connector), radio antenna (which doesn’t receive inside the appartment), and (luckily) a jack input, that I plug into every morning.

The thing can’t seem to die, and is quite powerful, so instead of trashing it, I’ll turn it into a connected speaker.


This is where all our money will go. We want something cheap, small but powerful, with wifi capabilities. The obvious choice will be… the Raspberry Pi Zero W, for 10€.

You will also need a micro SD card, the Samsung Evo + (32GB, more than enough) for something like 8€, achieves a really great performance-price ratio, but others could do (Sandisk, Samsung Pro, …), you can find benchmarks here.

However, as great as this board is, they removed the jack output compared to the classic Raspberry boards, so we will need to add it.

You could obviously use a Raspberry Pi 3 or 4 instead, but they feel too big to me.

I see 4 possibilities :

  • HDMI to Jack dongle. Just buy the thing for a few bucks, plug it in, done. Unfortunately, it means you will probably have a big dongle hanging out of your raspberry.
  • USB DAC dongle, can be expensive.
  • The Raspberry PWM pins. You will have to add your own audio filter to it, which can be done for quite cheap.
  • An I2S audio pi hat, I personally chose Pimoroni PHat DAC, but there are many others. This one costs 15€. Adafruit’s I2S board (which looks a lot like Pimoroni’s) costs only 10$, so it could be a good alternative.

You will also need a micro-USB power supply, which should amount for less than 10€, maybe 0 if you have an old phone charger lying around.

So we end up with a bill of about 40€, shipping not included.

The PHat will have to be soldered to the board, I will post pictures when this is done.


We are going to use :

  • A classic Raspbian (lite), the standard Raspberry distribution
  • Shairport-sync, some software that implements a receiver for the Airplay protocol.

Preparing your Raspbian image

Download the image “Raspbian Buster Lite” from the RaspberryPi download page, unzip the .zip file, and write it to your microSD card.

wget ""
dd if=2019-09-26-raspbian-buster-lite.img of=/dev/mmcblk0 bs=32M

Before booting on our system, we are going to pre-configure the wifi, and enable the SSH server so we can connect to the Pi when it starts (remember, we have no keyboard plugged in).

mkdir /mnt/raspboot
mount /dev/mmcblk0p1 /mnt/raspboot

# enable the wifi, adjust country, ssid and psk accordingly
cat <<EOF>/mnt/raspboot/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

# enable SSH
touch /mnt/raspboot/ssh

umount /mnt/raspboot


Now you are ready to boot, put the card in the Pi and power it up, it should connect to your wifi network.

Find the IP and SSH into it, or if you have Avahi/Bonjour enabled, you should be able to just use the raspberrypi.local hostname :

# default password is raspberrypi
ssh pi@raspberrypi.local
# change it to something better as soon as you connect
# change the network/airplay name of your board
cat "airplay-myroom" | sudo tee /etc/hostname

PHat DAC setup

First, I want to setup the audio driver for the PHat DAC, the installation is a one-liner, as explained on Pimoroni’s tutorial :

curl | bash

Building the software

It’s time to build the software. As we only have to build 2 small packages, we will compile on the Raspberry itself, but if we had more, we would probably cross-compile on a real computer.

First, install the dependencies. If you don’t want to use convolution, you can remove libsndfile-dev.

sudo apt update
sudo apt upgrade
sudo apt install -y  \
  git autoconf libtool libpopt-dev libconfig-dev \
  libssl-dev libavahi-client-dev libasound2-dev  \

Next we are going to build ALAC, the Apple Lossless Audio Codec, as this is a dependency of shairport-sync, and unfortunately it is not provided in Raspbian packages.

cd ~/
git clone
cd alac
autoreconf -fi
./configure && make && sudo make install
# that way shairport-sync will be able to find the library
sudo ldconfig

Getting closer, now we build shairport-sync

cd ~/
git clone
cd shairport-sync
autoreconf -fi
# here we are enabling:
# - systemd, as raspbian uses this boot system and not SystemV
# - alsa, as raspbian does not use PulseAudio by default
# - openssl, the other option is mbedtls
# - the ALAC codec
# - convolution, not required, but can be useful to apply effects
# - avahi, to be discoverable on the network
./configure --with-alsa --with-avahi \
            --with-ssl=openssl --with-apple-alac \
            --with-convolution --with-systemd
make && sudo make install
# copy the config to /etc
sudo cp scripts/shairport-sync.conf /etc/
# start shairport-sync
sudo systemctl start shairport-sync
# enable on boot shairport-sync
sudo systemctl start shairport-sync
Speaker is now ready!
Well, it works!

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: