We have speakers in all the ground floor rooms of our house, all driven from the same amp. It’s neat but controlling the input requires going back to the amp.
Surrounded by iDevices too and with apps like iPlayer, Spotify and home share on iTunes, being able to throw audio to the speaker system had to be done. Que Airplay, however, this requires a nice Airplay amp or getting an AirPort. I then found out about Shairport, a program that emulates an AirPort’s Airplay function. With a Raspberry Pi kicking around, I had just found its new job.
Quite a lot has changed in the year since I did this and rather than try and add more updates to this, I have run through the process again and created a new tutorial.
Setting Up Arch ARM
I opted for the Arch Pi distribution for this, simply because it is my Linux of the moment and with no window manager, is perfect for a standalone device. The first thing you’re going to want to do is a system update with pacman (you’ll probably need to update pacman on first run so need to do this twice).
pacman -Syu
Next you’ll need to install the tools required to compile in Arch.
pacman -S kernel26-headers file base-devel abs
Then git to clone the Shairport repo.
pacman -S git
Shairport has a number of dependencies so we’ll install them and there dependencies too.
pacman -S avahi libao openssl perl-crypt-openssl-rsa perl-io-socket-inet6 perl-libwww
Finally, alsa is required to get sound output in Arch on the RPi. Install this and then load the sound driver using modprobe
.
pacman -S alsa-utils alsa-oss modprobe snd-bcm2835
Alsa mutes the channels by default so open the mixer and raise the volume to 0dB gain. Test the output using speaker-test
.
alsamixer speaker-test -c 2
I’m using the 3.5mm jack as an audio output and at this stage I failed to get audio. I realised that with the HDMI plugged in, audio was going through that and not through the jack (it doesn’t seem to do both at once). You need to disconnect the HDMI and reboot the RPi. If you’re connected via monitor and want 3.5mm jack, there is no option but to continue via ssh
or use the phono. I was doing it all via ssh
so it didn’t really matter. If you do reboot, don’t forget to reload drivers using modprobe
before testing again.
[ update: you can change output with using amixer cset numid=3 1
– tomsolari.id.au ]
If all is good, save the alsa levels.
alsactl store
And set the sound modules and new daemons to load at startup by editing /etc/rc.conf
vi /etc/rc.conf MODULES=(.. snd-bcm2835 ..) DAEMONS=(.. dbus avahi-daemon alsa ..)
Probably a good idea to reboot at this stage.
shutdown -r now
Make Shairport
Make a directory called Shairport in the home folder.
mkdir shairport
Now clone the repo, cd
into it and make
.
git clone https://github.com/albertz/shairport.git shairport cd shairport make
All being well, Shairport should have built and you can now run it with the name ‘AirPi’.
./shairport.pl -a AirPi
Create daemon
18/12/12 – This may not work now due to Arch builds now using systemd
. If it doesn’t, this comment thread has a solution.
Install the new build
make install
Shairport includes a sample init
file but it is not designed for Arch. Arch includes a template for creating new daemons in /usr/share/pacman/rc-script.proto, first copy to /etc/rc.d
cp /usr/share/pacman/rc-script.proto /etc/rc.d/shairport
Now edit the file using vi as mine below
#!/bin/bash daemon=shairport daemon_name=shairport.pl . /etc/rc.conf . /etc/rc.d/functions get_pid() { pidof -o %PPID $daemon_name } case "$1" in start) stat_busy "Starting $daemon" PID=$(get_pid) if [[ -z $PID ]]; then [[ -f /var/run/$daemon_name.pid ]] && rm -f /var/run/$daemon_name.pid # RUN $daemon_name -d -a AirPi # if [[ $? -gt 0 ]]; then stat_fail exit 1 else echo $(get_pid) > /var/run/$daemon_name.pid add_daemon $daemon_name stat_done fi else stat_fail exit 1 fi ;; stop) stat_busy "Stopping $daemon_name daemon" PID=$(get_pid) # KILL [[ -n $PID ]] && kill $PID &> /dev/null # if [[ $? -gt 0 ]]; then stat_fail exit 1 else rm -f /var/run/$daemon_name.pid &> /dev/null rm_daemon $daemon_name stat_done fi ;; restart) $0 stop sleep 3 $0 start ;; status) stat_busy "Checking $daemon_name status"; ck_status $daemon_name ;; *) echo "usage: $0 {start|stop|restart|status}" esac exit 0 # vim:set ts=2 sw=2 et:
Add shairport to the list of daemons in etc/rc.conf and you’re all good to go.
UPDATE 2:
I’ve since found a command to redistribute the Pi’s memory, providing less dropped audio (it doesn’t happen much anyway). By default, a certain amount is allocated to the GPU, since this is headless, we can remove that.
cd /boot mv start.elf orig-start.elf cp arm224_start.elf start.elf
UPDATE 3:
Shairport has been updated to support iOS and with it now depends on perl-net-sdp. This can be installed from the AUR using these instructions
83 replies on “AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi”
[…] my AirPi, I needed to make my Raspberry Pi wireless. Being the man of thrift that I am, I found the cheapest […]
Wish I had seen this before I bought a refurb AirPort Express. I guess by the time I bought WiFi for the Pi though I would have been out almost as much.
Great write up!
I see some typos.. “alsa-util” should be “alsa-utils” and “alsa-mixer” should be “alsamixer”.. Other than that, I got a lot of problems. First one is the /etc/rc.conf .. just does not seem to work, have to run the modprob command manualy. And I get errors while trying to run the “./shairport.pl -a AirPi” command after make. “Can’t locate Net/SDP.pm”. So I tried to run “cpan install Net::SDP”, but get an error “Couldn’t untar Net-SDP-0.07.tar
Package seems to come without Makefile.PL.” Any suggestions…
Thanks for the typo heads up, I’ve corrected those.
With regards to your problem, did you install the additional dependency (perl-net-sdp) from the AUR (Update 3) before running: https://aur.archlinux.org/packages/perl-net-sdp/ ? The fact the script can’t run at the moment is probably the reason the daemon isn’t working too.
Thanks, I got it running now. But still have problems with the /etc/rc.conf .. not working. Strange. Great writeup by the way 🙂
Ok. Got it working. Seems like they dont use the /etc/rc.conf anymore.
I ran.
“systemctl enable avahi-daemon”
Then I made a file “/etc/modprobe.d/default.conf”
and added
“services snd-bcm2835” to the file. Reboot. And now works as expected.
Thanks. It’s been a while since I built mine but having updated other Arch installations, have noticed some big changes.
You’re right,
systemd
is now used as a service manager. Looks like you can installinitscripts
as legacy support forrc.conf
but your method is better.https://www.archlinux.org/news/systemd-is-now-the-default-on-new-installations/
Oh.. the last part is wrong.
So. Instead of making the /etc/rc.conf, I ran the command
“systemctl enable avahi-daemon”
Then I made a file /etc/modules-load.d/snd-bcm2835.conf and added the “snd-bcm2835” to it.
Thanks.
Hi Guys,
I can’t seem to get shairport.pl to automatically start when booting up. I first tried the rc.conf ‘method’ which didn’t seem to work. Then I used Stain’s instructions and added daemon.. But i can’t seem to get shairport.pl to automatically start.. Am I doing something wrong?
When i manually start it through an ssh shell it works perfectly..
I know it’s an old post but I hope you guys can help me.
Thanks,
Rik
Hi Rik.
I’ve just gone through the process using the current Arch build so I can update this post – a lot has changed. Stain only explained adding Avahi to the boot list for systemd (you should need to bother with the snd-bcm2835 module part now as it auto loads).
With systemd you need to create a shairport.service file in /etc/systemd/system (
vi /etc/systemd/system/shairport.service
), containing the following:Finally, enable the service at startup:
systemctl enable shairport
This should solve your problem.
I’m having the same problem with “Couldn’t untar Net-SDP-0.07.tar”, but I can’t work out how you/he fixed it. How do I install the additional dependency?
You need to follow the steps on the Arch wiki, which explain installing from the AUR. In this case the ‘perl-net-spd’ package
Here’s the link: https://wiki.archlinux.org/index.php/Arch_User_Repository
The basic steps are:
1. download the package (
wget https://aur.archlinux.org/packages/pe/perl-net-sdp/perl-net-sdp.tar.gz
should work [you’ll needpacman -S wget
first])2. extract (
tar -zxzf perl-net-sdp.tar.gz
)3.
cd perl-net-sdp
4.
makepkg
5.
pacman -Syu
6.
pacman -U perl-net-sdp.pkg.tar.xz
And it should work. Hope that explains what you were after.
hello john! does this works to stream by airpi from iphone to car stereo? is there any possibility to adapt the programing for arduino? please excuse my ignorance. Bye
Yes you could do that with this and a RaspberryPi to make a airplay compatible car stereo. It’s something I considered myself but ending up just building a dock into my dashboard instead. Let me know if you do it.
It wouldn’t be possible with an Arduino, it doesn’t have the processing power. I was going to suggest you could try a bluetooth module and do it that way instead but the digital to analogue converter is too slow for music.
I am using this for my car stereo actually. I have a cheap car stereo with aux in, and USB… so I use the usb to power the Rasp, and the aux for the analog audio.. works like a charm.. I had to add a usb wifi thing, and sett it up as an Access Point. But there are guides for this. Good luck.
Here is a video of it in action. http://youtu.be/P2ASS4SWmG4
Great stuff; really tidy integration and nice car too!
Thanks. By tidy integration you mean you cant see the mess behind it 🙂 Integrated mess. Next part is to make a new(old) interface for the stereo itself, make it all look a bit more 1969.
[…] AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi From engineer.john-whittington.co.uk (via @mtaarao) – Today, 6:41 PM We have speakers in all the ground floor rooms of our house, all driven from the same amp. It’s neat but controlling the input requires going back to the amp. Surrounded by iDevices too and w… […]
Hello John!
Just started tinkering with Arch/Raspberry Pi, but your instructions got me safely through!
Now I can upgrade my old Marantz-Amp with “Airplay”…
Thank you very much for your write up!
Regards.
Thank You 1000 times! This is exactly what i was looking for: Shairport Daemon!
[…] Des enceintes AirPlay. […]
[…] Des enceintes AirPlay. […]
[…] Des enceintes AirPlay. […]
[…] My last AirPi post has been popular – and still is – but part of why of like Arch linux is that it is constantly updating so you must be hands on, learning a new part of the OS the hard way! […]
what is tadalafil 20mg
what is tadalafil 20mg
how to take viagra
how to take viagra
marley drug viagra
marley drug viagra
viagra on line
viagra on line
viagra online without prescription
buy real viagra online viagra online without prescription
how to make viagra
how to make viagra
effects of viagra
effects of viagra
cialis dosages
cialis dosages
buy cheap viagra online usa
viagra online buy buy cheap viagra online usa
cialis savings card
cialis savings card
how to get viagra in canada
lowest price generic viagra how to get viagra in canada
viagra in action
viagra in action
mandy flores viagra
mandy flores viagra
buy generic viagra soft tabs
buy sildenafil uk online buy generic viagra soft tabs
levitra for sale
levitra for sale
viagra 150 tablet
order female viagra viagra 150 tablet
cialis black
cialis black
teva 5343 vs viagra
teva 5343 vs viagra
cheap generic viagra uk
viagra tablet price in singapore cheap generic viagra uk
viagra results
viagra results
atorvastatin 10mgs
atorvastatin 10mgs
Trackbacking your entry…
viagra cost in australia
Trackbacking your entry…
where to buy viagra uk
cialis price
cialis price
viagra on sale
viagra on sale
levitra vs cialis
levitra vs cialis
cialis
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
best custom essay website
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
writing a dissertation proposal
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
common app essay help
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
best essay service
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
write my math paper
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
help writing a thesis statement
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
custom written research paper
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
phd thesis defense
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
canada cialis
canada cialis
buy online augmentin 875 mg
buy online augmentin 875 mg
cialis 30 day sample
cialis 30 day sample
what is female viagra
what is female viagra
viagra multiple cums
viagra multiple cums
keflex alcohol
keflex alcohol
cialis generic
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
order cialis
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
cialis cost
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
daily cialis
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
ciprofloxacin dangerous
ciprofloxacin dangerous
ditropan xl generic
ditropan xl generic
viagra over the counter walmart
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
how to take viagra
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
viagra or cialis
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
buy generic 100mg viagra online
AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi – John Whittington Engineer
caffeine and tizanidine
caffeine and tizanidine
aripiprazole side effects in women
aripiprazole side effects in women
allopurinol causing muscle damage
allopurinol causing muscle damage
amiodarone dosing
amiodarone dosing
how does amitriptyline help ic
how does amitriptyline help ic
amlodipine besylate and alcohol
amlodipine besylate and alcohol
amoxicillin gonorrhea
amoxicillin gonorrhea