Airplay with Shairport on Raspberry Pi

The fun I had with this one!

The goal: to get Airplay working on my Raspberry Pi.

The rationale: turns out that my HP Microserver (N40L) doesn’t support the hardware extensions needed to pass-through a USB sound-card to VMWare ESXi 5.5, in order for it, in turn, to pass that to the VMs.  So, my goal of having a Windows VM running iTunes, Spotify etc. and playing that through a long (15m) 3.5mm cable in a #8 fencing wire approach to extending my media upstairs has come up short.  Ha, ha.

So, my backup plan?  I have a Raspberry Pi sitting right beside the Microserver (with a very long HDMI cable for extending same said video media upstairs).  Maybe I could use that, I thought.

The plan: the Raspberry Pi is running RaspBMC (an awesome distro), and I thought it worthwhile to use a USB soundcard (specifically, a Creative Sound Blaster USB stick) to improve on the not-so-flash audio that comes out of the native 3.5mm jack.

Enter Shairport – a port of Airplay that can run on a Pi.

This site has most of the instructions needed to download and compile the Shairport source, including the additional instructions when using Raspbmc as a base.

From there, the gotchas I uncovered:

  1. The SoundBlaster seemed to have dramas with rubbish sound when the analog input (default) was selected, but no problems when what ALSA identifies as the S/PDIF input.  So, to use that, I had to create a /etc/asound.conf file that contains the line pcm.!default front:U0x41e0x30d3 and nothing else.  The U0x… is the identifier of the SoundBlaster that I got from using the aplay -L command, along with the iec958 which is the identifier of the S/PDIF input.
  2. I found I didn’t need to have the options snd-usb-audio nrpacks=1 line in the /etc/modprobe.d/alsa-base.conf file, so that’s good.
  3. Still some noise coming through the soundcard, so I used alsamixer and alsactl store 0 to mute and save the changes to the Mic input.
  4. The final key to getting rid of the noise as best I could was to add the line dwc_otg.speed=1 to the /boot/cmdline.txt file which, I think, slows down the USB ports to cut back noise.

What a drama! But now I have it (mostly) sorted and stable, and receiving pretty good sound from a VM with a hi-fi virtual audio cable and AirFoil.

Not too bad.

Advertisements