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.Airplay Multiroom radio with the Raspberry Pi, no additional hardware needed.

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:

mkdir pifm
cd pifm
wget  http://www.icrobotoics.co.uk/wiki/images/c/c3/pifm.tar.gz
tar -xvf Pifm.tar.gz
cd ..

This:

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
cd perl-net-sdp 
perl Build.PL 
sudo ./Build
sudo ./Build test
sudo ./Build install 
cd ..

Letā€™s instal the final filesAirplay Multiroom radio with the Raspberry Pi, no additional hardware needed. schematic

git clone  https://github.com/hendrikw82/shairport.git
cd shairport
sudo make install
cd ..

This will install shairport.

Source: http://lifehacker.com/5978594/turn-a-raspberry-pi-ā€¦

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.

 

For more detail: Airplay Multiroom radio with the Raspberry Pi, no additional hardware needed.


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top