Intro: Airplay Multiroom Radio With the Raspberry Pi, No Additional Hardware Needed.
Most ways to stream music to multiple sets of speakers cost more than it is worth. I don't think I have to say much about it, you probably wanted to do this in the past but it just seemed stupid to spend that much money on a separate dedicated system.
We are going to exploit the fact that the Raspberry Pi supports AirPlay (through shairport), and combine it with the 'hack' that allows the Raspberry Pi to transmit FM signals, turning your raspberry pi into a dedicated AirPlay server and FM transmitter.
Here is the best part, the requirements:
1x Raspberry Pi (any model except Pi 2)
1x Long wire (preferably around 2 feet in length)
1x FM radio (many speaker systems and nice alarm clocks have a built in FM radio).
Step 1: Hook Up a Wire for an Antenna
Hook up a wire to GPIO 4. This is the fourth pin down on the left side. The wire can be up to 30 inches long.
Step 2: Download PiFM
My assumptions is that you have setup your raspberry pi before. You can either SSH into it, or just do it with a monitor, mouse, and keyboard. For optimal performance from Airplay, I suggest having the Pi hooked up to the network with an Ethernet cord and the Pi not overclocked (this will mess with the FM radio if it is overclocked).
After you login to your raspberry pi, at a terminal window install PiFM:
tar -xvf Pifm.tar.gz cd ..
1. Makes a director named pifm
2. Makes the "Current Directory" pifm
3. 'Gets' the file at the link provided.
4. Essentially unzips this file.
Step 3: Make a FIFO File
FiFo stands for First-in First-out. This will act as a buffer, we are going to send music to this file, and as the music gets into the file it will be read by the PiFM program we just setup.
sudo mkfifo fmfifo
This will make a fifo file. That's all for this step.
Side note: For those more familiar, a higher performance option is to make a fifo in a tempfs folder, but this file will get lost after reboot. I would enjoy suggestions to improve this. This isn't necessary for now though.
Step 4: Install Shairport
Lets install shairport. This allows the Pi to act as a AirPlay Server, and receive music from our AirPlay compatible devices.
First, we need to update our raspberry pi. This will take up to 10 minutes.
sudo apt-get update
sudo apt-get upgrade
Lets now install all the necessary files for airplay:
sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl
Let us install a depedency.
git clone https://github.com/njh/perl-net-sdp.git
sudo ./Build test
sudo ./Build install
Let's instal the final files
git clone https://github.com/hendrikw82/shairport.git
sudo make install cd ..
This will install shairport.
Side note: There are newer versions of shairport, there are a variety of branches. It is hard to choose the best one but this one works, which is all I require. I recommend people taking a peak at shairport-sync if they want to use multiple raspberry Pi's instead of a central fm transmitting one (you'll get better audio quality with shairplay sync, but it costs more).
Step 5: Let's Run It!
Lets do the final steps! You may need to have two terminal windows open, one for each command as they tend to 'take over' the window.
sudo ./shairport/shairport -a "NameOfServer" -o pipe /fmfifo
sudo ./pifm/pifm fmfifo 107.9 96000 2
The first step creates a server, which you can change the name of. The name is what you see when you connect with your compatible device.
The next step sets the frequency. I have it set to 107.9, but use an empty radio station in your area. After you run both steps, tell your iOS device to play music to "NameOfServer" and you should hear the music on the radio station you chose.
Side note: A sample rate of 96000 should work for current devices. If the music sounds too high pitched or too low/slow, you may need to change the sample rate. In this example, I was streaming from my phone on iOS 8. In the past I use to use a sample rate of 44100, but for whatever reason I had to use 96000 this time. If the music sound slow, use a higher number. If it is too fast, use a lower number. Sampling rates are commonly one of the following rates: 96000, 88200, 48000, 44100, and 32000. You'll probably use 96000 or 44100 for most systems, I think it is an Airplay/iOS version related number.
Step 6: Final Notes
You'll have to run the last two commands every time you reboot to start the radio again.
The raspberry Pi FM transmitter is very noisy and does not follow regulations, which is why I never looked at a method to start automatically. Use it sparingly. Don't use it around airports. Only use it when you need to, and make sure the station goes back to static when you are done.