How to stream audio from iOS or Windows to Raspberry Pi
Few months ago I was searching on internet about how to stream every audio from my laptop, to my Raspberry Pi which was connected to my home speakers.
I just wanted to listen Youtube from my laptop directly on speakers, without any jack cable connected to it (wirelessly). So, after few days of searching, I finally found how to do it and I think it worth to write the steps here, for newbies, or for any others who want to do the same thing and don’t know what to search for.
What do you need?
Of course you will need a Raspberry Pi as receiver and as audio streamer, you will need an iOS device (iPad, iPhone) or a laptop with Windows 7+.
How is working?
You will have to use the Apple AirPlay protocol to stream audio from iOS/Windows 7+. The Raspberry Pi will act as an AirPlay Audio Receiver. Apple iPhone, iPad and iPod are supporting this protocol by default, so you won’t have to install anything on your device(s). For Windows you can install TuneBlade, but I’m sure that there are some other softwares that will stream every sound from Windows to RPi via AirProtocol.
Connect your speakers to Raspberry Pi.
Adjust the volume on your RPi using the alsamixer.
Make sure that your iOS device(s), Laptop and RPi are connected to the same network (Your home network).
If everything is ok we can start. We will need to install an AirPlay receiver on Raspberry Pi. We will use Shairport.
# Update Raspberry OS
sudo apt-get update
sudo apt-get upgrade
# Install additional packages needed for Shairport
sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl libasound2-dev libpulse-dev
# Download Shairport
sudo git clone https://github.com/abrasive/shairport.git
# Configure/Build Shairport
cd shairport && ./configure
sudo make install
sudo cp scripts/debian/init.d/shairport /etc/init.d/shairport
sudo chmod a+x shairport
sudo update-rc.d shairport defaults
sudo useradd -g audio shairport
If you want to add a custom name the AirPlayer, just edit AP_NAME line from /etc/init.d/shairport file.
sudo nano /etc/init.d/shairport
# Find the following line and edit it
Now we can run shairport as a service. It will start at every boot up.
sudo service shairport start
If you have an iOS device you will be able to see the Shairport receiver in Airplay device list.
Just select RaspHiFi and then go to Youtube or some different app to play any music. It should stream the sound to your speakers!
If you want to stream sound from Windows, you can use a software which will generate a Virtual Audio Adapter, that will capture any audio from PC and stream it via the AirPlay protocol to any available receivers (Raspberry Pi in our case).
I use TuneBlade (Trial version) and I can say that is working pretty good. There is a delay in transmission but if you are just listening to music, it shouldn’t bother you much.
I hope this will be usefull for you! If you need any help please leave a comment on this post, or you can write on our Facebook Page.