drew diver // tired, since 1985

Raspberry Pi as an AirPlay Receiver

Wednesday, May 11, 2022 by Drew Diver

I recently purchased the IQaudio DAC+ to get “24‑bit 192kHz high-resolution digital audio” for use with ShairPort-Sync to have a nice AirPlay receiver alongside my turntable.

This took a few hours to get going because the unit is billed as plug and play which it definitely was not. My assumption is if you run the Raspbian desktop GUI you can select the audio source from the menu bar. For our use case we want the Raspbian Lite installer running headless.

Initial Pi Setup

Be sure to run the raspi-config wizard after installing the Raspbian Lite image to setup the correct locale, expand the file system to use the entire microSD card, set the correct timezone, etc.

Next we update our apt repo and install the necessary packages for ShairPort-Sync.

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install autoconf automake avahi-daemon build-essential git libasound2-dev libavahi-client-dev libconfig-dev libdaemon-dev libpopt-dev libssl-dev libtool xmltoman -y

ShairPort-Sync Install

Clone the ShairPort-Sync repo to the Pi and enter the directory.

git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync
autoreconf -i -f
./configure --with-alsa --with-avahi --with-ssl=openssl --with-systemd --with-metadata
make && sudo make install
sudo service shairport-sync start
sudo systemctl enable shairport-sync
cd ..
git clone https://github.com/mikebrady/shairport-sync-metadata-reader.git
cd shairport-sync-metadata-reader
autoreconf -i -f
./configure
make
sudo make install

DAC+ Setup

Via pinout.xyx the board communicates over I2C.

I believe this can be handled one of two ways, either uncomment dtparam=i2c_arm=on in the /boot/config.txt or via the raspi-config you can enable P5 I2C under the Interface Options.

From the DAC+ documentation, let’s adjust the /boot/config.txt settings.

We comment out the dtparam option to disable the built-in audio and add in our newly attached DAC+:

# Enable audio (loads snd_bcm2835)
# dtparam=audio=on
dtoverlay=iqaudio-dacplus

ShairPort-Sync Configuration

Here’s where it got tricky, I eventually found an unrelated forum post regarding an application called “Raspotify” with a similar issue. Adapting that idea and combing the ShairPort-Sync GitHub repo I discovered a similar conf file where I could manually enter the hardware info.

Run aplay -l

card 2: IQaudIODAC [IQaudIODAC], device 0: IQaudIO DAC HiFi pcm512x-hifi-0 [IQaudIO DAC HiFi pcm512x-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

So, card 2 at device 0.

Edit /usr/local/etc/shairport-sync.conf and find the alsa settings:

alsa = 
{
    output_device = "hw:2,0";
    mixer_control_name = "PCM";
    mixer_device = "hw:2";
}

Then run sudo systemctl reload shairport-sync for the changes to take effect.

filed under: airplay tutorial raspberry pi audio