AirPlay can transmit audio and video files, such as movies, series, sports, cartoons, music, etc., from any Apple device via AirPlay/AirPlay 2 using an internet connection. Since there are numerous AirPlay 2 compatible speakers out there in the market, listening to songs over it from iOS or Mac is made easy. For those unaware, you can even use Raspberry Pi as an AirPlay receiver by using Shairport Sync, an open-source software. By having the Raspberry Pi and inputting a few codes, you can build an AirPlay Receiver server for your speaker.
Once you build the Raspberry Pi AirPlay 2 receiver server to your speakers, you can AirPlay any songs from your iOS or any AirPlay 2 compatible devices to your speakers.
Things You Need to Set Up Raspberry Pi AirPlay 2 Receiver on your Speakers
- Raspberry Pi
- Uninterrupted Power Supply
- Micro SD Card
- WIFI or Ethernet connection
- Speakers
- AirPlay-compatible devices such as iPhone, iPad, iPod, etc.
How to Set Up a Raspberry Pi AirPlay Receiver
Make sure you update the Raspberry Pi. With that, setting up your Raspberry Pi AirPlay Receiver on your speaker is straightforward.
1. To update the Raspbian OS on the Raspberry Pi, open the Terminal, and check for updates using the below commands to upgrade the software.
sudo apt update
sudo apt upgrade
2. Once you have checked the above updates, you must install several additional packages by following the commands below.
sudo apt install autoconf libtool libdaemon-dev libasound2-dev libpopt-dev libconfig-dev
sudo apt install avahi-daemon libavahi-client-dev
sudo apt install libssl-dev
3. Now, you need to get the Shairport sync source to your Raspberry Pi to allow it to sync among multiple rooms of audio streams from iOS devices or third-party AirPlay sources. First, run the below command to clone the Shairport-Sync repository.
cd ~
git clone https://github.com/mikebrady/shairport-sync.git
4. Now, you must build and install the Shairport software to your Raspberry Pi. Before installing the software, you must configure the system under the Shairport-sync folder. To do so, run the below commands on the Raspberry Pi to set up the basic config file and built system to utilize the ALSA audio backend, the Avahi network, and to use OpenSSL for encryption.
cd shairport-sync
autoreconf -i -f
./configure --with-alsa --with-avahi --with-ssl=openssl --with-systemd --with-metadata
5. After the configuration, you need to input the below commands into your Raspberry Pi to install the Shirport-sync to the device.
make
sudo make install
6. After the installation, you need to enter the below commands to enable the Shairport software to start automatically.
sudo systemctl enable shairport-sync
7. To Start Up the Shairport Software, you must run the below command.
sudo service shairport-sync start
Once the Shairport Software has been started, you can play the audio files from any AirPlay-compatible device to your speaker.
How to Improve the Audio Output with Raspberry Pi Receiver Setup
You can do the following on the Raspberry Pi AirPlay 2 receiver to improve your speaker’s audio output.
1. Update the Raspberry Pi’s firmware by inputting the following command on the terminal.
sudo rpi-update
2. Remove the SD card and power off your Raspberry Pi upon successful firmware update. Now insert the SD card into a reader connected to your computer to change the Raspberry Pi’s boot config file. On the SD card, you can get the config file at the file location /boot/config.txt.
Go to the file location, open it, and modify the config file by adding the below new line and save it.
audio_pwm_mode=2
3. Now place the SD card back into the Rasberry Pi and input the below command into the terminal to set the analog jack as the main audio out.
amixer cset numid=3 1
4. Next to that, modify the Shairport db range to improve the Raspberry Pi AirPlay device. You can edit the content by changing it in the configuration file.
To change the Configuration file, you can input the below commands into the terminal.
sudo nano /usr/local/etc/shairport-sync.conf
5. Within the file, make the below changes by inputting the below codes into the terminal. Once the changes below have been made, to save the file, press CTRL + X, press Y, and finally give ENTER.
Find
// volume_range_db = 60 ;
Replace with
volume_range_db = 30;
6. Once all the above changes have been made, you can restart the Raspberry Pi by running the below command to get the improved audio output.
sudo reboot
How to Improve the Raspberry Pi AirPlay Receivers WIFI Performance
While hearing the songs, if you get an interpretation, it may spoil the whole song’s output towards your feeling or emotion. Hence you can follow the below steps o improve the AirPlay Recrivers WIFI performance.
1. Modify the network interface file to disable the Raspberry Pi’s WLAN adaptor power management. To do so, open the file and input the following command in the terminal.
sudo nano /etc/network/interfaces
2. Then, you need to modify the interface within the file by adding the below-following text to input the Raspberry Pi not to manage its wireless power and will not turn off the saving power.
Once you have made the below changes to save the file, press CTRL + X, press Y, and finally give ENTER.
Find
iface wlan0 inet manual
Add Below
wireless-power off
3. Once all the above changes have been made to the file, restart the Raspberry Pi by inputting the below command into the terminal.
sudo reboot
Why Not Use the 3.5MM Audio Out with Raspberry Pi AirPlay?
Since AirPlay already gives the best audio than Bluetooth, using the 3.5mm audio output built into the Raspberry Pi is not advisable. Using it will diminish the audio quality before it gets to the speakers. Apart from this, using an HDMI audio output is also the best option to be used on the receivers.
FAQ
Yes. You shall use the above setup procedure to use AirPlay on your Raspberry Pi 3.