Getting Rid of iPods

I am removing iPods from my house. It's a general effort to move away from having constant listening in every room. Yeah, there are still the cell phones and iPads, but chipping away at what's listening reduces the attack surface and the set of things I have to remove if things go sideways.

I also love playing music though the house. Music in the bedroom is nice while I'm reading. Music in the office provides a nice background when I'm working. Music in the kitchen while preparing and eating meals complements the food.

Maybe Ikea bookshelf speakers

I have Home Assistant and a lot of ZigBee devices from Ikea.

I figured their bookshelf speakers, which support AirPlay 2, looked like a good choice.

However, it turns out the Ikea speakers are just Sonos speakers. The Ikea speakers require installation of Sonos software. I have concerns about Sonos.

All Open

I decided to do an "all open" AirPlay system.

I started with Raspberry Pi.

I found Shairport-Sync which is an open source AirPlay implementation.

I used some powered speakers with optical inputs (more on this later). There are plenty of reasonably priced sound bars, etc. that will take audio input and play it.

I found that the analog Raspberry Pi audo was less thank optimal, so I opted for Optical Audio.

Hardware

I have implemented the system on a Pi Zero WH, Pi 3, and a Pi 4.

For the audio, I got a TOSLINK Hat for the audio.

Setup

First, use the Raspberry Pi Imager to create the right SD card images.

When running the imager, make sure to choose "Use OS Customization" and within the customization screens, set hostname to the name of the device (e.g., "kitchensound"), username and password, configure the Wireless LAN, and on the "services" tab, make sure to enable SSH and put your SSH public key in.

I used the minimal images (no desktop) as the application is headless.

I imaged the micro SD card and inserted it into my Pi.

First boot takes a few minutes as the initial boot resizes the storage, etc.

Once you can ping <hostname>.local (e.g., ping kitchensound.local), you can ssh into the device: ssh dpp@kitchensound.local where "dpp" becomes the username you set in the above customization and the host is also the host you chose in the customization.

Log into your new device and make sure things are up to date:

sudo -i
apt update
apt upgrade

Next, ensure that the TOSLINK Hat is properly configured. Edit /boot/firmware/config.txt and add the line dtoverlay=hifiberry-digi and reboot.

Next, install packages to allow compilation of Shairport-sync:

sudo apt install --no-install-recommends build-essential git autoconf automake libtool \
    libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev \
    libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev uuid-dev libgcrypt-dev xxd

Next, clone and build shairport-sync:

git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync
git checkout tags/4.3.5 -b latest_stable # Check out a stable tag
autoreconf -fi
./configure --sysconfdir=/etc --with-alsa \
    --with-soxr --with-avahi --with-ssl=openssl --with-systemd --with-airplay-2
make
sudo make install

Install nqptpt

cd ~
git clone https://github.com/mikebrady/nqptp.git
cd nqptp
git checkout tags/1.2.4 -b latest_stable # Check out a stable tag
autoreconf -fi
./configure --with-systemd-startup
make
sudo make install
sudo systemctl enable nqptp
sudo systemctl start nqptp

Install SPS Alsa Explore:

cd ~
git clone https://github.com/mikebrady/sps-alsa-explore.git
cd sps-alsa-explore/
git checkout tags/1.2.1 -b latest_stable # Check out a stable tag
autoreconf -fi
./configure
make

Run sps-alsa-explore to get the TOSLINK device: ./sps-alsa-explore

> Device Full Name:    "hw:sndrpihifiberry"
  Short Name:          "hw:2"
  This device seems suitable for use with Shairport Sync.
  The following rate and format would be chosen by Shairport Sync in "auto" mode:
     Rate              Format
     44100             S24_LE

Open sudo vi /etc/shairport-sync.conf and ensure that the alsa = { output_device="<device_identified_by_sps-alsa-explore>"}:

// Back End Settings

// These are parameters for the "alsa" audio back end.
// For this section to be operative, Shairport Sync must be built with the following configuration flag:
// --with-alsa
alsa =
{
        output_device = "hw:sndrpihifiberry";

Enable systemd to manage Shairport:

sudo systemctl enable shairport-sync

Reboot.

Connect the device to a speaker via TOSLINK.

Open your iOS Music app and you should see your device listed among the AirPlay devices.

And, yay, you can play music to the device.