Wednesday, 26 December 2012

Pandora on Raspberry Pi

It's pretty hot today so we're trying to reduce the number of powered on devices in the house (less heat produced = less work the air conditioning has to do). I normally switch on the HTPC to play music through Pandora, but that's a hundred or so watts heating up the living room!

Since I have a Raspberry Pi hooked up and recording mains power consumption and temperature data in my house (more posts on that stuff to follow), I thought it could do a little more work and play music too.

So here's a quick set of instructions on how to get Pandora working on a Raspberry Pi using Pianobar (a command line Pandora client).

Equipment needed:

  • Raspberry Pi
  • USB Sound Adaptor
I'm using a USB Sound Adaptor because the onboard Raspberry Pi sound makes thumps whenever the audio is switched off (I guess they're powering off the audio part of the SOC when it's not being used). The thumps are pretty annoying, and the easiest solution is to plug in an extra sound adaptor which doesn't have this problem.


Install Pianobar

Log into the pi and run "sudo apt-get install pianobar".

Configure alsa's modprobe order so the usb soundcard appears as the primary sound card

Edit /etc/modprobe.d/alsa-base.conf and change the lines that say:
# Keep snd-usb-audio from beeing loaded as first soundcard
options snd-usb-audio index=-2

# load usb audio first
options snd-usb-audio index=0

Reboot your Raspberry Pi.

Create the Pianobar Configuration File

Log in as the "pi" user, and create the directory "~/.config/pianobar" if it doesn't already exist. Create a file in that directory called "config" and write the contents if the config file described on this page into it:

Don't forget to update the config file with your username and password (or command to decrypt your password from a key store). You will also need to update the tls_fingerprint setting with Pandora's current TLS fingerprint (they seem to change this from time to time). The contributed script here will fetch the fingerprint from Pandora's tuner:

Getting Started

Run "pianobar" as the pi user and it should start up and ask you which station to play! You might want to install screen or a similar to so you can background the pianobar process.

1 comment:

  1. Thanks. I followed your guide to make this work on my Pi!