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.
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... is great to setup the basics but you will have to find out the specific RR for each type of service.
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.
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.
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.
Absolutely. I'm the article author and yes, adding a DAC is definitely recommended because the output from the audio jack is terrible.
I'm intending to do a follow-up article on this, but so far I've tried IQAudIO Pi-DAC+ with an RPi 3A+ and HifiBerry DAC+ Zero on a Zero W. I was extremely surprised by the good quality of the HifiBerry.
I noticed the writeup has your output set at +4db. That implies it’s substantially overdriving the output, which will cause obvious distortion. I have a rpi plugged into my high-end-ish stereo for other reasons, and find the output to be more than good enough.
If you’re complaining about audiophile nuances like warmth and presence, and also using 24-bit, high sample rate audio files, then fine, but if you’re encountering obvious distortion or buzzing then something’s wrong with your setup.
(Thanks for writing this up, by the way; it didn’t occur to me that I could set up an AirPlay server with stuff I have laying around.)
[edit: I forgot that I’m using hdmi audio. Still, the +4db thing is a red flag]
HDMI audio from the Pi is fine. It’s analogue audio from the 3.5mm TRRS connector where the sound quality is poor, quiet and hissy.
I first discovered how bad it was building a bespoke car stereo out of a Raspberry Pi 1 - and ended up buying a USB DAC because of it. But it seems to still be an issue even in the later boards because emulation forums are often talking about using HDMI or an addon board for RGB+Stereo if your display doesn’t support HDMI.
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.
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.
Note these are often called by other names ('soundcard' is not very descriptive to me because they look nothing like the PCI cards you're imagining installing in your desktop PC). A 'USB audio adapter' or 'USB DAC' are the same thing.
I made a Shairport server for 6 audio zones years ago on an ancient desktop computer and multiple PCI sound cards. After it died, it was hard to migrate to a single Raspberry Pi due to the USB audio cards devices scrambling on each boot (so the kitchen may become the living room, etc.).
Shairport-sync also has small audio glitches, and I ended buying an airport express. Certainly cheaper than buying a raspberry pi and good DAC. The airport express DAC is very good.
And a recent-ish firmware update for them enabled AirPlay2, so I can now stream to all three of my Airport Expresses in sync from my phone or iPad. I was quite pleasantly surprised by Apple still providing useful software updates to hardware they no longer sell (I'm guessing the probably won't push an AirPlay2 update =for my original AppleTV though, since they'd prefer I upgrade it to a newer one which they're still selling...)
I mean, you say "new" but it's been around for over a year. And it's a huge improvement. Are all the people here complaining about audio quality, complaining about this improved driver or the original poor driver? My ears are not great but I find the new one very usable with an amp; it's not great with headphones but that's hardly surprising.
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.
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.
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.
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.
Yep. I was fortunate to have an old iLamp that can't handle the current version of the Airport Utility software, which doesn't support the older Airport Express (Mine are branded "AirMac," because I bought them in Japan) base stations.
You can get Airport Expresses on Goodwill for $5 to $10, but you need an old machine to set it up.
The current version of Airport Utility will see them in an extended network, and plot them on the network graph, but can't be used for configuration.
There is (was?) a workaround to get the old Airport Utility management software to still work. But in the end I gave I and just replaced that old one with one of the more recent ones. (If anyone in Sydney .au wants the old one, shout out...)
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.
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.
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)?
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.
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.
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.)
In addition to the other features mentioned, I believe AirPlay 2 supports more media formats and more precise control over playback, and more metadata about the media playing.
I wonder if there was a way to answer that without editorializing. There's nothing stopping someone from coming up with an open source streaming platform, it just won't be embedded in iOS.
I feel like you editorialized kevin_b_er. Obviously they were talking about Apple preventing this software with working with the new airplay system. Where were they saying it's impossible to come up open source streaming protocol?
Airplay 2 haas reduced latency and improved quality. You can also stream to multiple Airplay 2 devices from iOS while iTunes on a Mac/PC can stream to multiple Airplay 1 devices.
In a nutshell, AirPlay 2 decouples the media and the control streams.
This makes play/pause etc instant (rather than waiting for the 3 second buffer to run out) and makes it much easier to do multi-speaker audio as they're all listening to the same media stream.
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
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.
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.
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.
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.
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.
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.
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.
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.
I'm still using squeezebox and really like the original hardware, plus home made receivers using pi's; it's a fully open source media system - something that doesn't seem to exist in today's landscape of vendor lock in.
Nonetheless, it's showing its age somewhat, and is harder to get streaming services working on it (e.g. YouTube, play music) in part due to its open nature (also, it's written in Perl...)
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.
I'm a big fan of RasPis, but people _always_ understate the real costs.
That TPLink wifi router comes in a case with a (probably shitty but working) power supply and cable, and inbuilt flash memory.
A Pi Zero costs ten quid, but you need to add a case, a power supply, and a micro SD Card. But worst for me, is that they still limit you to buying one at a time, so if your decide "Hell yeah! 5 room wi-fi streamed audio sounds _Awesome!_" You're not only up for fifty quid for the Pi Zeros, but you're gonna spend at something like twice that much again for 5 half-decent power supplies, USB cables for the power supplies, SD cards, and cases, and then you're up for 5 lots of shipping charges because they aren't allowed to sell you 5 Pi Zeros in one order... All of a sudden that "fifty quid project!" has become a £150+ one in five seperate deliveries...
(And unless you don't care too much about the audio quality, both the Pi Zero and the TPLink router will need a better external DAC anyway...)
If you just want one, and you're the sort of person who has usb power supplies, cables, sd cards kicking around doing nothing, and you're not too fussed about having a nice case, sure, you can just order one ten quid Pi Zero plus 3 quid for shipping.
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.
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.
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.
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!
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.
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.
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.
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.
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.
For those using Spotify premium for listening to music there are some open source projects (like spotifyd) that replace the now deprecated spotify-connect.
These work too for $30 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.
[1] https://github.com/mikebrady/shairport-sync [2] https://github.com/philippe44/AirConnect