Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Hacking a Raspberry Pi into a wireless airplay speaker (jordanburgess.com)
144 points by jordn on Dec 28, 2012 | hide | past | favorite | 73 comments



Did this hack myself a month or two ago - I go the XBMC route (openElec) on the Pi with Airfoil for Windows to stream Spotify. That combination is finicky - sometimes requires one or two connects. When spotify releases a libspotify compiled for the right ARM architecture (something about floating point?) I'm going to run http://www.mopidy.com/

The disadvantage of the headphone port of the Raspberry Pi is that it used to put out absolutely awful sound, but that may have improved. Using shairport also has bugs - the audio output from the script sometimes has pops and after about 10 or 20 minutes will randomly disconnect.


A tip to avoid the headphone port: Either use the HDMI port or try a usb soundcard http://elinux.org/RPi_VerifiedPeripherals#USB_Sound_Cards


Yeah, should've clarified that - XBMC comes up on HDMI now and audio is routed through my TV to play music.


That's really cool! I want to play around with getting this to play music directly from the internet somehow. I tried XBMC at first but I didn't like how much input it needed to get going and how flaky the results were.

You're right that the headphone port is (still) pretty crappy. I've got the model B 512MB revision and I still hear a lot of static.


Have you heard of despotify? As long as you have a premium account, it's a 3rd party library with a CLI interface that works well on the Pi.


Tried it, but when I got my Pi it wouldn't install - something about having a different version of the OS/firmware. Might have to try that again though


Why would you do this rather than buy an Airport Express? The cost of the Raspberry Pi, wifi adapter and a basic USB soundcard add up to as much as the real thing, but you spend hours configuring software and end up with a flakey solution. It's great that you can do this, but why not save time and money by buying the real thing? You also get bit perfect optical output and a pretty decent wireless router.


If you already have the ingredients to do this, then it may be a cheaper solution.

My RaspberryPi has been a few things since I bought it (a print server, a file server, a web server) but I never really settled on anything and for the past couple of months it has sat in a drawer.

I've now just re-purposed it as an Airplay speaker in less than an hour for no extra cost.

I will probably purchase a smaller USB WiFi dongle (@£8.99 on Amazon) but even including the cost of the Raspberry Pi (~£34 total), that's less than half the cost of an Airport Express (£80).

On top of that, who doesn't like to tinker?


Hacking ones own solution has benefits: control over the technology, freedom from proprietary interests, ability to enhance the behavior, configuration and customization, integration with other technologies, knowledge of how to build other things later..., etc

Oh, and if I get bored, I can always reuse the hardware for something else.

Probably the same reason why I garden instead of buying from the grocery store, or why I grind my own meat for my burgers. Sometimes, if you want it done right, you have to do it yourself.


Because we're a bunch of programmers that like creating our own solutions to things; it's rewarding in more ways than saving time and money.


I assume because this thing can do more. It can also download movies, and show them on your TV, to name something.


Came here to say just this. I never understand these like "money saving hacks" that cost very close to what an actual, legitimate product intended for this purpose would cost, with a ton of work, and less reliability.


Well, it's not called "Hacker" News for nothing. CNet is over there.

Anyways, apart from AirPlay (AirPort Express), my RPi is performing XBMC / media center capabilities (Apple TV), streaming network backup (Time Capsule), motion-activated security camera, software-defined radio and X10 home automation. I will shortly be interfacing the GPIO to an SSR and thermocouple so I can use it as a PID for beer brewing and smoking fish. For $35 and 2w of power, that's pretty good.


"Well, it's not called "Hacker" News for nothing. CNet is over there."

Cool diss, hope it made you feel better about yourself I guess? Anyway, I simply pointed out that the author framed this as a cost saving tool when it really isn't. Say its a fun hack and I have no problem, but to call this thing a moneysaving hack when it doesnt save a whole lot of money and produces a lower quality device. But hey, your one line diss sounds better so why bother with logic.


For brewing the beer it should be fine. Be careful with the fish though you'll want quicker responses so you'll probably not want it doing all of the other things at once. I've thought about using an Avr or a pic for that before so that it can be much more responsive as a paid controller.


Any chance of a few links to look into the various things you've done with the RPi? Thinking of getting one in the new year and some of those projects sound really interesting.


I run Shairport + brutfir for room correction, that setup replaced my old Airport Express and sounds a lot better.


A note for those attempting to use Ethernet to Airplay mirror:

Your router must allow multicasting between WLAN and Ethernet clients, otherwise your Pi won't show up to iDevices connected via WiFi.

If this is a problem for you (as it was for me) your only solution is attaching a WiFi adapter to your Pi. The consensus for best support, lowest power and tiny footprint is Edimax EW-7811UN (http://www.amazon.co.uk/gp/product/B003MTTJOY).

I just grabbed an old Linksys WUSB54GS that I had laying around and it played nicely with the Raspberry Pi with little to not effort.


That's http://www.amazon.com/dp/B005CLMJLU for our friends on the other side of the pond.


What a coincidence. I did the exact same thing yesterday, following the instructions here: http://trouch.com/2012/08/03/airpi-airplay-audio-with-raspbe.... You really need a USB soundcard for this to be usable though, unfortunately.


What about HDMI audio output? For those of us who already have a decent, digital A/V receiver?


I have XBMC with graphics + sound running over HDMI to my TV, no issues with sound at all.


This looks like a neat hack. I might attempt something similar at some point.

Somewhat relevant, since many people here are talking about using a USB sound card: I have heard good things [1] about using this hub/dock combo with a Raspberry Pi [2]. Might be overkill for this project but it would give you an all-in-one connection dock for more multi-purpose projects.

[1] http://www.trilug.org/pipermail/trilug/Week-of-Mon-20120903/... [2] http://www.microbarn.com/details.aspx?rid=102750


Cool hack. There's real demand for a reasonably priced Airport Express alternative, but it's a shame that the RasPi's DAC isn't up to scratch for HiFi use.

You suggest we follow you on Twitter, yet protect your tweets...


Bugger, i forgot the 'b' on the url. Thanks for telling me, I wouldn't have caught that otherwise. I'm http://twitter.com/jordnb

And I agree. I expect someone could kickstart a little electronics add on to do exactly that - a reasonable wireless DAC to airplay to. But thoughts on it would be that with all the required components still I'd be difficult to undercut Apple's airport express still.


Looks cool! Anyone know any of this for Android? At least for Samsung Note. I want to try to wirelessly stream audio from my Note to my Logitech Z2300.


You could get a small little Bluetooth A2DP reciever and stream over bluetooth: http://www.amazon.com/Belkin-F8Z492TTP-Bluetooth-Music-Recei... There's also ways to stream from Android to Airplay receivers - just search for Airstream in the play store.


I use doubletwist player with Airsync to play against AirPlay targets like this, if that's interesting to you.

Costs a little money though.


Is there a way to stream music from a Linux machine to multiple destinations?

Currently I have a notebook with Mint connected to my stereo system for all my music needs. It works nice.

I would love to have the music play in multiple rooms simultaneously. Is it possible? Money is not an issue. I could buy whatever equipment is needed. But I did not hear about any solution yet.


I'm not certain it will work but you might look into the Logitech Media Server http://www.mysqueezebox.com/download with SoftSqueeze clients http://softsqueeze.sourceforge.net/

While intended for use with Squeezebox hardware clients, I suspect you could get an all-software linux client-based synchronized setup working with it. The Squeezebox software is all known for being hackable.

There is some concern about Logitech killing off the Squeezebox ecosystem, but the source for much (all?) of this is available and the community remains active.


Wow, I never heard about squeezebox. Sounds very good! I only want the server to be my linux box. The clients can be whatever. I will probably try both: build my own clients with softsqueeze and order some squeezebox radios as clients and see what happens. Nice! Thanks!


You could try doing it with pulseaudio. It's nice because then you can stream everything that plays on a specific machine. Everything that's required is that the program has pulseaudio support which most music playing programs should have. I'm not sure how well it works with multiple destination though.


I know this is possible with Linux. At my previous job one of the developers used to pipe his music stream to the broadcast address on our LAN. I don't remember much about the exact protocols involved, but I'm sure it's possible. Even better, do multicast, since broadcast is out in IPv6.


Synchronizing the clients is the hard part.


Ah. Is that the magic that AirPlay takes care of? Interesting problem...


Airplay doesn't really do this. The sound is often slightly out of sync but it's enough to be really irritating if you can hear two of them. The best solution I know of for perfectly synchronized wireless sound is Sonos (quite expensive, but I love it)


Squeezebox is not perfectly synchronized?


Invest in a multi-room stereo system.


Are there any good wireless ones?


i used to use logitech/squeeze, but recently switched (it's dying, as far as i can tell, and certainly wouldn't run on the latest opensuse) to audioengine D2 - http://audioengineusa.com/Store/Audioengine-D2

it's more expensive (i think), and less flexible than the logitech solution, but it's also (much) simpler, (much) more reliable, and better sounding (imho - i did some comparison tests and the DAC sounds similar to a decent "budget audiophile" DAC I own, and, incidentally, significantly better than the audioengine D1).

the D2 sender plugs into your computer and works just like a USB soundcard. each D2 receiver (you can have up to 3) receives wifi from the sender and outputs either digital or good quality analogue. the data transmits as 24/96 (ie decent quality) and there's a volume control on the sender that adjusts the output after the DAC (so you don't lose resolution).

then i just use whatever player i want (currently mpd, so i can have network and web clients - i am thinking of buying a small tablet to control the web client).

tldr - the D2 is a "done right" hardware solution, that sounds good, but it's not particularly cheap.

more of my rambling - http://acooke.org/cute/AudioEngin0.html

also, see this previous HN thread - http://news.ycombinator.com/item?id=4736980

ps if anyone wants to buy my (discontinued and unsupported) logitech hardware for a nominal amount i think i still have it. a duet and a boom. but i'm in chile, so i imagine shipping costs elsewhere are significant.

pps i have not used sonos, but i heard that there's some limit about the number of tracks or amount of metadata they can handle. if you have a lot of music i would check before buying anything. as far as i know, the sonos is more like logitech - it's a "system" that manages your music, while the D2 is more like a wireless soundcard (or wireless wire, with optional DAC). i prefer the latter because it means i can play around with other "audiophile" hardware on the audio end, and other software on the computer end, but that's just my taste.


Yes, Sonos makes nice wireless systems. Search for "Play:5" or "BU250" models, for example.


I read about Sonos a couple of times, but never understood what it is about. Now I did it again. Same result. I dont get it.

When I buy the Play:5 - what do I get? Where will I put my mp3s? Can they stay on my Linux box? Do I have to transfer them to a special device? It looks like Sonos uses its own wireless transfer mechanism. Why do I have to connect it to my router?


> When I buy the Play:5 - what do I get?

You get one Play:5 device. I would guess you need several of those to equip different rooms.

> Where will I put my mp3s? Can they stay on my Linux box?

Your mp3s can reside on any machine as long as they are reachable via CIFS/SMB protocol.

> Do I have to transfer them to a special device?

No. You only need a so called "Sonos Controller"- a small piece of software available for Windows/Mac/iOS/Android - where you actually manage your Sonos network: define your SMB share folders, create your playlists, search, stuff like that...

> It looks like Sonos uses its own wireless transfer mechanism. Why do I have to connect it to my router?

Yes Sonos does not really use 802.11 as we know it. It uses its own protocol called SonosNET (a kind of Spanning Tree Protocol) to create a wireless mesh network. So at least one Sonos device must be connected to a wired network to act as a wireless AP to allow other Sonos devices to connect to the network and use standard internet services (DHCP, DNS, etc...).

Does that make sense?


> Does that make sense?

Honestly, it sounds overly complicated and I still dont understand the basic principle.

Why not just put a music player program on my computer that streams the song into my existing network and have speakers that connect to the network and play it?

You say "You get one Play:5 device". So what is that? Why cant I just buy "speakers" that play whats send to them over the network?

You say "CIFS/SMB". Well, I could make my files available that way. But somehow it feels wrong. Will the song that is played then be streamed to some central device and from there to the speakers? Seems like twice as much streaming as necessary.

You say "Windows/Mac/iOS/Android". So I would have to bring one of my tablets into the game. ANOTHER machine in the mix.

You say "at least one Sonos device must be connected to a wired network" and I still dont understand why. I would understand it if you said "to access your files". Even thought I would prefer it to just swallow an usb stick so I dont have to fiddle with my existing IT. But you say "to act as a wireless AP to allow other Sonos devices to connect to the network and use standard internet services" and I wonder why do they have to? I want the "other devices" just to be speakers and play music.

The Squeezebox thing makes more sense to me.


Icecast? http://www.icecast.org/download.php

I can't imagine this being hard. Just generate a stream and play it on other computers, even VLC can do it.


Seems not to support synchronization of multiple clients.


You get that for free if your network is good. In college, we'd wire up half a dozen rooms to the same icecast server. The server itself could not participate, but there was no lag between the clients (all on the same network switch).


Ah, you want them to all be playing in sync? That might be a bit harder, then.


There is a problem with the instructions though; when you get to the:

'Installing Perl Net-SDP'

Section, and type in the third line of code, after git clone, you get this error message: http://pastebin.com/MSrqYYKq

Saying to Contact the author, because there are files missing.

I have contacted the author, and Jordan too.

Does anyone know how to get around this?


Thanks for bringing this up. I'd messed up the instructions for that bit and placed the sudo command in the wrong place.Updated it now. For anyone stuck this is the updated instructions work:

  pi@raspberrypi ~ $ git clone https://github.com/njh/perl-net-sdp.git perl-net-sdp
  pi@raspberrypi ~ $ cd perl-net-sdp
  pi@raspberrypi ~/perl-net-sdp $ perl Build.PL
  pi@raspberrypi ~/perl-net-sdp $ sudo ./Build
  pi@raspberrypi ~/perl-net-sdp $ sudo ./Build test
  pi@raspberrypi ~/perl-net-sdp $ sudo ./Build install
  pi@raspberrypi ~/perl-net-sdp $ cd ..


The missing files aren't stopping you, it's the last line "mkdir _build: Permission denied".

To get around it I just ran the build as root ;)


Ah yeah, thank you!

I have everything 'working' now, although it's quite glitchy, making loads of static sounds. After a few restarts etc. it is playing okay now, I don't want stop playing it incase it doesn't work again!


I hadn't realized the Airplay keys had been cracked. Last time I looked for something like this they hadn't. I've already bought an extra airport express, but I kinda just want to build this for fun. I'm seeing lots of complaints about the PIs dac. How bad is it?


> I'm seeing lots of complaints about the PIs dac. How bad is it?

It doesn't really have a DAC at all - it has two PWM peripherals and a filter wired up to the audio jack to generate stereo audio.


I think they have been for a while. Rogue Amoeba has offered Airfoil with support for acting like an Airplay speaker for a while now.


>How bad is it?

Very bad. You won't be happy with it, I promise.


Does anyone know of a good standalone speaker that this hack could be paired with to make an airplay speaker for smallish spaces? E.g. not a home's main living area where you'd want to use a higher powered stereo system, but perhaps a bedroom or office.


Personally, I'd recommend these. Incredible bang for your buck. http://www.parts-express.com/pe/showdetl.cfm?partnumber=300-...

You'll need an amp. http://www.parts-express.com/pe/showdetl.cfm?partnumber=300-...

To run from the headphone port you'd just use a simple male 3.5mm male to RCA(red/white) male.

I imagine the headphone port quality is terrible and the post mentions it. Apparently this is a cheap USB compatible option http://www.meritline.com/usb-sound-adapter-channel-volume-co...

This entire setup should run you well under $100 and sound great.


I run this exact setup in my home office and it's great.

I've been wanting to try the Topping amps; this one with an integrated USB DAC looks interesting: http://www.parts-express.com/pe/showdetl.cfm?partnumber=310-...


I use this setup in my living room. I don't think you could hope for more for the money. That little amp is powerful and can even run on AA batteries (8 of them).


Audioengine A2: http://audioengineusa.com/Store/Audioengine-A2

Or A5+ for a bigger sound at a higher prize and in a bigger box.


I have used M-Audio AV 40s, and have liked the results. They're compact, well built, and sound good.

Amazon link, no affiliate: http://www.amazon.com/M-Audio-Studiophile-Powered-Monitor-Sp...


Am i right in thinking that all usb speakers have their own sound card on board? I have a pair of logitech z120 I want to try out with this (and then maybe hook it all up to a battery to make it completely wireless) but i've left them at uni and can't try it out yet.


Yes, the signal over USB is digital, and the speakers have a DAC and an amplifier.


Look at the Pro Audio USB Monitor space - Alesis and Samson have good sounding powered nearfield speakers that are cheap by audiophile standards.

edit Samson not Samsung


Awesome, Going to try this with my Pi.

I presume that it'll work with the HDMI out into my AV receiver well without the distortion from lack of on-board DAC?


hdmi works too and has a much better audio quality than the headphone jacket. There are occasional interferences but this could also be caused by shairport or the network connection ( my guess is network ).


Better over hardwire than WiFi? Or just the how the Pi handles the info on-board?


sorry for the confusion, the problems were load related as a process in the bg was running wild. Runs pretty smooth over both ethernet & wlan now.


Nice, a low cost a version of the airport express is exactly what the market needs. I wonder why no company has done it so far?


I assume it's because Apple wants to license it, which costs money and they might not allow it


Just trying this now but when I try to run perl Build.PL. I get Build: command not found

Any ideas?


High time i bought the Pi i guess...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: