Raspberry Pi is an awesome little single board computer – and it’s cheapness (under $50 with power, wifi, case, sdcard) and extensibility is making it a favorite for hobbyists that are doing all sorts of awesome things with it. In my case, I wanted to create series of AirPlay connected speakers throughout my house along with a lot of other automation.
Long story short, this simple task made me it’s bitch for 2 hours (most of it going back and forth between the living room and master bedroom, connecting/disconnecting everything back and forth). It’s January 2016 and I’m building a Sharport enabled speaker on Raspbian Jessie.
1. Streaming music to my Raspberry was choppy, sound was dropping out.
2. Sound level was way too low, even though both iPhone and amp were maxed out.
3. After adjusting the sound level the sound card disappeared after reboot.
If you’ve run into any of those, scroll down to the next block. There is an excellent guide on how to build this little beast at Make: Magazine but just in case that link dies here are the steps in a nutshell once you get your Raspberry Pi configured to your liking:
Yeah, I know, I know. Anyhow, let it rip:
apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl
git clone https://github.com/njh/perl-net-sdp.git perl-net-sdp
git clone https://github.com/hendrikw82/shairport.git
cp shairport.init.sample /etc/init.d/shairport
chmod a+x /etc/init.d/shairport
update-rc.d shairport defaults
./shairport.pl -a AirPlayPi
At this point you should be able to see it on your iPhone and stream to it. It will be very quiet.
DAEMON_ARGS=”-w $PIDFILE -a AirPlayPi”
Reboot and enjoy. If you’ve run into my problems, read on:
Streaming music to my Raspberry was choppy, sound was dropping out.
No idea how to fix this, other than to overclock it using sudo raspi-config; It worked for me, modest overclock without overvolting did the trick for me. Your mileage may vary.
Sound level was way too low, even though both iPhone and amp were maxed out.
Apparently this is a precaution with Raspberry Pi and the output is intentionally set rather low. First to force the audio output to the 3.5mm jack run:
sudo amixer cset numid=3 1
Now, run sudo alsamix and turn up the volume to 100 (hint: press up). It will be effective immediately.
After adjusting the sound level the sound card disappeared after reboot.
Steps above basically stopped my system from loading the sound card module after the reboot. Don’t know why but according to a little bit of Googling this happens often because drivers are experimental, etc. You’ll have to force it to probe for the specific driver on boot. Just add the driver name to the bottom of the /etc/modules file and it will load it up every time it boots. If you just want it for this session run sudo modprobe snd_bcm2836
sudo nano /etc/modules
According to the forums, the sound card that comes with the Raspberry (Broadcom 2836) is not the greatest and many recommend a USB enabled on. Again, this is a matter of taste. I spent about 10 minutes on Amazon going through reviews and it seems that even the cheapest $4 USB card is better than the onboard one. Some people recommend SoundBlaster X-Fi Go ($40) and others are using an I2S PiHat DAC+ topper card so you don’t have to go through USB decoding – not sure what they are listening to but it sounds serious.
If you’re running Raspberry Pi 2, your module is snd_bcm2836. If you’re running anything earlier than that, the module you’re looking for is snd_bcm2835.
As for why this? Why not Sonos? Why not Airport Express (I have two) when it’s $50 on eBay? etc, etc. We have a mix of devices, services, large collection on the NAS that we’d like to be able to stream all over the house on-demand and selectively so DIY is what sold it. That and the ability to do a lot more with the Raspberry when there is one in every room in the house.