
Apple Airplay on Raspberry Pi in 7 Easy Steps - 3chelon
https://appcodelabs.com/7-easy-steps-to-apple-airplay-on-raspberry-pi
======
tedd4u
At the risk of being a bit off topic … A lot of people interested in Airplay
will be looking at this post wondering how to use AirPlay with UPnP or
ChromeCast devices. shairport-sync [1] (used in the article) only works
directly with audio hardware, so won't work with Chromecast or UPnP compatible
systems. I've tried many many different open-source bridges and finally found
AirConnect [2] which is by far the most reliable, active and well-maintained
bridge. philippe44 responds to every issue filed (as far as I can tell). Works
great with my Sonos PLAY:1 & XBox.

[1] [https://github.com/mikebrady/shairport-
sync](https://github.com/mikebrady/shairport-sync) [2]
[https://github.com/philippe44/AirConnect](https://github.com/philippe44/AirConnect)

~~~
wyuenho
Thats exactly what I used. Highly recommend AirConnect.

------
ulzeraj
My beef with airplay and pretty much every other Zeroconf based service is
that they require weird stuff to work across subnets. Here I isolate every
“IOT” device specially the ones that potentially has a phone home capability
into a separate network. The wireless network is also segregated and routed.
To make everything Zeroconf/Bonjour work I have to create lots of SRV, PTR and
TXT records in my internal DNS which is a Samba4 AD. This document
[http://www.grouplogic.com/Knowledge/PDFUpload/Info/WanBonjou...](http://www.grouplogic.com/Knowledge/PDFUpload/Info/WanBonjour_1.pdf)
is great to setup the basics but you will have to find out the specific RR for
each type of service.

~~~
X-Istence
You could also set up Avahi or some other mDNS daemon to relay mDNS packets
across the two different networks, so long as you can route the UDP/IP from
one network to another you shouldn't need to create a whole bunch of TXT
records.

~~~
ulzeraj
Going DNS has its advantages like being a less broadcasty solution that can
work across VPNs. I've first implemented it some years ago when a client
wanted to share authenticated wireless AirPrint to wireless guests on his huge
school wireless network. The system is still working.

I guess another advantages of going DNS besides not having to broadcast
information is that you chose what you want to publish.

------
tonylemesmer
This guy must have been doing this at exactly the same time as me. I used
shairport-sync and whilst I eventually got it working last week it wasn't
plain sailing. Getting the service setup to start upon powerup was a real pain
in the ass. I've also had to move it onto a separate wifi network as an RPi
camera was hogging the bandwidth which caused audio dropouts on the shairplay-
sync server.

Also as many of you will probably comment, the Rpi audio out stage is awful.
I'm waiting for my Dad to return my USB soundcard so I can use that instead of
the headphone socket on the Pi.

~~~
rezeroed
How has it managed to escape me, immersed in tech every day for many years,
that there is such a thing as a USB soundcard? Crazy how things can slip
through the cracks, be so close yet missed.

~~~
tracker1
They're definitely useful. Also, even at the low end, often better than
onboard simply because they get so much less interference. There are also some
really nice higher end options if you ever want to do multi-channel
mixing/capture.

Aside: for anyone considering a hackintosh, USB audio is about your best bet
in this space.

------
amdavidson
I've been doing this for a couple years with a Zero (pre-W) and a pHAT DAC[0]
with great success.

It just runs and reliably shows me a Airplay device for my garage speakers. I
recommend it for people who have audio hardware lying around and don't want to
replace it with more expensive and worse sounding smart speakers.

0: [https://shop.pimoroni.com/products/phat-
dac](https://shop.pimoroni.com/products/phat-dac)

------
pantalaimon
It's a bit funny how the best way to stream audio between two Linux boxes is
Airplay with shairport on the server and the raop2 PulseAudio Plugin on the
Client. It integrates well into the Desktop too and is automatically
discovered!

It's funny because PulseAudio could do network streaming itself, but as it
still streams the uncompressed PCM stream afaik, it's pretty useless in
practice.

~~~
SSLy
We're using the PA PCM method in our student association. Works good enough.

~~~
pantalaimon
I reckon you have everything connected over Ethernet then?

~~~
SSLy
No, WiFi.

------
Reason077
You can also just buy an old Airport Express base station and repurpose it for
AirPlay. The old 802.11g ones can be found for about $10 or so and even have
an optical audio out.

~~~
nathancahill
I went this route. Nightmare. The installer software has been removed for Mac
and isn't available anywhere. Had to find a laptop running Windows 7 to get it
up and running. It also won't be compatible with modern routers. 1/10 can not
recommend.

~~~
rikkus
What do you mean by "won't be compatible with modern routers"? Are you
referring to the 802.11g? These devices had an ethernet port, IIRC. I'm sure I
remember plugging mine into my network and not using its built-in wifi.

~~~
nathancahill
Yes, they have an ethernet port, but the goal of such a device (for me, where
I don't have ethernet running to my speakers) is to stream music over wifi.

------
npunt
All the Airplay tutorials I've seen are about being a receiver for Airplay
signals from something like an iPhone. These boxes then plug into speakers for
output.

Does anyone know if there are tutorials on making an Airplay client that
instead sends audio & video to a receiver of some type (e.g. Apple TV)?

~~~
xdissent
This project can stream audio to an Apple TV and includes details about the
(now required) pairing protocol: [https://github.com/philippe44/RAOP-
Player](https://github.com/philippe44/RAOP-Player)

~~~
npunt
Thank you!

------
konradb
My understanding is that this is possible because at some point, the private
keys for the airplay encryption were found. Alas airplay 2 cannot be supported
unless the same thing happens, which is a shame.

~~~
Jonnax
What's the difference between airplay 1 and 2?

Is it quality?

~~~
pfranz
I couldn't quickly find a detailed breakdown, but here's a basic one:

\- Airplay doesn't offer multi-room audio; AirPlay 2 does

\- AirPlay lets you stream from any Apple device to your speakers or TV

\- AirPlay 2 lets you play from speakers over Wi-Fi, and it'll stay in sync

\- AirPlay 2 lets play different songs in different rooms with multiple
HomePods

If memory serves, the original AirPlay had much simpler goals. Stream music
from a single computer to a speaker over a local network. So it has
concessions like a constant 2 second lag, which happens if you press
pause/play. I vaguely remember other weird restrictions when playing with it
in the past (like one device at a time had to control a speaker).

AirPlay2 is a lot more complex adding the features mentioned above and better
handling the use-cases original AirPlay grew into.

[https://www.pocket-
lint.com/speakers/news/apple/144646-apple...](https://www.pocket-
lint.com/speakers/news/apple/144646-apple-airplay-2-vs-airplay-what-s-the-
difference)

~~~
bigiain
The big difference for me, is that I can select any combination or all of my
AirPlay2 devices from my phone, but I can only select a single airplay (1)
device and nothing else at the same time. (For me, that means my old AppleTV
can be selected, but nothing else at the same time, but any combination of my
three Airport Expresses can be selected.)

------
geekuillaume
If you want to do the same for Chromecast it's not possible yet. Google seems
to have locked down their API. There is some open-source projects that are
trying to reverse engineer it but the problem seems to be linked to crypto
keys used to authenticate real Chromecast devices:
[https://github.com/thibauts/node-
castv2/issues/2](https://github.com/thibauts/node-castv2/issues/2)

~~~
askvictor
And Google do security pretty well, so it's unlikely the certs will be leaked
or broken :( When the Chromecast first came out, the was an open source
receiver called leapcast which reverse engineered the DIAL protocol that the
YouTube app on many smart TVs of the day used, and the Chromecast protocol was
based on. But alas it doesn't work anymore.

------
knolan
The Raspberry Pi has awful noisy audio out. There are some nice Amps you can
get like the HiFi Berry. I set up a nice arrangement in my old lab with with
these.

~~~
cheeseprocedure
Another vote for the HiFiBerry. I’ve used their Digi+ board (which includes
optical-out) with a Pi3B running Volumio for a couple years and it’s been
fantastic.

~~~
dwater
I'm using a generic HiFiBerry clone that I got for $18 with a pi3b running
Volumio as well. I'm using a 240GB SSD in a USB enclosure as the drive, and a
cron job that keeps it synced with my fileserver. Only snag was finding a
power supply that could reliably provide enough power, I've settled on an
Apple ipad charger I had laying around. It's been great for a few months now.
Sound quality is very good.

~~~
tracker1
Good power adapter options for the Pi is definitely one of my bigger
complaints. Even determining a good one to get from Amazon is painful,
considering how many cheap/knockoff options are out there.

If a company could get the kit price under $40-50, I would definitely use them
for more one-off projects. Aside, I really wish that Docker for (Windows|Mac)
ran as a service without requiring login so I could run background linux
software with a little less friction. The linux on windows stuff is coming
along, but similarly lacking initd/systemd startup. And while I know that a
desktop os isn't a server, I've got a plenty powerful desktop that I have
always on, and would just assume not have another computer running.

------
mattkevan
Been running Shairport Sync on a Pi3 for the last couple of years. It works
great.

I've been adding more stuff to the Pi over time, so it's now a Plex server,
Home Assistant hub, Torrent box, Pi-hole and more.

------
depthcharge
I did the same thing a couple of weeks ago using a Raspberry Pi 3 B+. I have
it connected to a Cambridge Audio stereo amplifier through USB, since the
amplifier has an integrated DAC. I'm very pleased with it, and it was
surprisingly easy to get working.

~~~
3chelon
Nice idea. My amp is Cambridge Audio but it sadly does not have a DAC. If it
had, the setup would have been even simpler than it is.

------
kingosticks
Mike Brady has done a great job with this. The project also has a very
detailed readme, far beyond what most provide. Thanks Mike for all your
efforts.

I'm not sure this how-to article adds that much but I guess it's nice and
simple looking.

------
CameronBanga
Did the opposite a few months ago, and used a Raspberry Pi Zero to AirPlay
audio from my turntable to a HomePod. It was about as amazingly useless as one
would imagine, but fun none the less.

~~~
3chelon
Wow, I'd love to see a write-up of that.

------
philamonster
Pi MusicBox?

[http://www.pimusicbox.com/](http://www.pimusicbox.com/)

------
jrowley
If anyone is looking for multi room audio (like airplay 2), using raspberry
pies, this is the best solution I’ve seen - it is really impressive:

[https://www.reddit.com/r/homebridge/comments/8v3qb0/shairpor...](https://www.reddit.com/r/homebridge/comments/8v3qb0/shairport_sync_and_airplay_2_any_hope/e686gk1/)

If people have other suggestions for multi room audio I’d love to see them.

~~~
digitalsushi
Never discount the simplicity and reliability of a (legal) low power FM
transmitter.

~~~
jrowley
I attempted using an FM transmitter but I had 2 issues

1) I think my transmitter was a little noisy so that wasn’t desirable.

2) I didn’t have a nice FM receiver to test with, but didn’t want to purchase
one because I thought my transmitter was noisy. So a bit of a catch 22.

But FM would be great.

------
evanweaver
It's overkill to use a Raspberry Pi for this.

I made a dozen Airport adapters with the TP-Link WR710N which was $25 at the
time and connects to Wifi or ethernet. Add a USB soundcard ($10?) for powered
speakers or a Topping USB amp ($75?) for unpowered speakers. Install OpenWRT,
connect it to your network in client or bridge mode, install the built-in
shairport-sync package, and go.

Not sure what has replaced the WR710N but I'm sure you can still do this just
as cheaply.

~~~
3chelon
To be fair, a Pi Zero W costs less than £10, or the equivalent in dollars.

~~~
alias_neo
It does, sort of, but, if you want to do this seriously, as in, you want more
than one unit (I wan't ~5 to add to the open-source home security camera
software I'm writing), you can't buy more than one at a time unless you buy it
with headers attached (which I don't want), leaving you the alternative of
buying them individually and paying for delivery for each individual unit.

~~~
mikeash
Micro Center has them for $5 for the first unit, $15 for units 2-5, and $20
each after that. Still less than ideal but not too bad.

~~~
alias_neo
Seems like a better deal than we get here in the UK.

These £9 Pi's rarely go for less than £12-14 and if you can get more than one,
they won't be any cheaper.

------
tambourine_man
I love a good excuse to buy more RPis and have thought about doing something
like this.

However, I already have a cheap bluetooth dongle that I plugged my stereo to
via P2. Is there some advantage to this setup (beyond range)?

What I'm really considering is a web interface, with search, playlist etc and
a huge SDcard with all my music connected to a RPi. Currently all my music is
on my Mac and Apple Music Home Share is a bit flaky/slow at times.

~~~
scns
Check out mopidy.

------
snag
My take on this was :

1- Buy hardware (Raspberry + DAC + Amplifier)

2- Download and install Volumio (volumio.org) on SD card

3- Profit

~~~
jrgoj
What do you advise for a baseline DAC+Amplifier?

~~~
snag
My setups are pretty cheap as I did not want to put much money in it.

As for DACs, I have a €24 Hifiberry DAC+ and an inexpensive raspberry
compatible DAC out of Aliexpress (around €12) on my two different setups
(kitchen and living room). Both work well and deliver good enough signal (I am
not by anyway an "audiophile") I prefer the no-brand one from AE though as it
has an IR receiver I am using to control media playing.

As for amplifiers, any stereo amplifier would work, so I choose a Lepai
lp-2020a (€30 on amazon) in the kitchen. I have an old Marantz branded
amplifier for the living room.

------
roberttod
Nice! I'm trying to do it the other way around, record player into Raspberry
Pi, broadcast to my HomePod. Unfortunately the only way it works is to add a
laptop in between. If anyone has managed to get an AirPlay broadcast from
Linux I'd love to know how you did it!

~~~
amaccuish
Have a look on GitHub, there's quite a few projects. Pulseaudio can also
stream over Airplay 1 and 2.

------
msvan
I bought a Google Chromecast Audio. Spotify, Soundcloud and Pocket Casts
support it on iOS. I'm not actually sure what the officially Apple sanctioned
way of getting audio to my speakers is, but I haven't felt the need to find
out either.

~~~
jrowley
I had one of those devices and it worked great but now I just don’t want
google knowing my listening habits so have gotten rid of it.

------
shritesh
I use shairport-sync on my iMac to stream Overcast from the iPhone. There is a
huge latency and the connection drops out every once in a while. This should
have been a built in feature.

------
tracker1
While not an iOS user, it is definitely cool how many one off projects you can
create using Raspberry Pi. I do wish some of the full kits (case, power
adapter, micro sd) would come down in pricing slightly as it tends to bump up
towards more powerful, but less supported (and more difficult) options when
you consider the full system price.

~~~
heywire
Depending on the project, Raspberry Pi Zero W is often powerful enough. $5 on
sale at Microcenter, $4 for the case.

------
e1ven
This is a cool project, and I think it can be a good addition to an existing
home media server.

For the use-case they describe however (wiring up an existing home stereo) it
would probably be a lot easier and better supported to just buy an Airport
Express.

You can still buy them online for ~100, and they support Airplay2 as well,
which is much nicer for multi-room audio.

------
joshstrange
It appears this is Airplay 1 only (please correct me if I'm wrong) so this
will not be as nice as say, using an Airport Express but if you had this stuff
laying around it might be worth it.

------
Jnr
For those using Spotify premium for listening to music there are some open
source projects (like spotifyd) that replace the now deprecated spotify-
connect.

------
eddywebs
Does anyone have suggestions for the reverse? basically an analog input (turn
table/cassette) that can be streamed over wifi as digital output

~~~
cheeko1234
Not wifi, but you could get an aux to bluetooth adapter:

[https://www.amazon.com/GOgroove-BlueSENSE-Bluetooth-
Transmit...](https://www.amazon.com/GOgroove-BlueSENSE-Bluetooth-Transmitter-
Wireless/dp/B008GVETNE)

------
mikewhy
Should also mention this does not support video.

------
easymovet
These work too for $30
[https://www.amazon.com/dp/B01HFYZDNC/](https://www.amazon.com/dp/B01HFYZDNC/)
but it might be a security threat to have them on your LAN, I have no idea
what software they run.

