Red Silico: Andy's blog - RPi en Multi-room audio with Raspberry Pi <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><h2> Introduction</h2> <p>In this article I will explain how to set up a multi-room audio streaming system based on Apple iDevices, cheap Raspberry Pi players and any computer (either Linux, Windows or Mac). You will be able to do the following:</p> <ol> <li> Send sound from any app on your iPhone or iPad to any speaker in your home.</li> <li> Use your iPhone or iPad to control synchronised multi-room music - without your mobile device needing to stay connected.</li> <li> Play music from your PC/server on your iPhone or iPad.</li> </ol> <p>You will need:</p> <ul> <li> One or more Raspberry Pi computers (in fact you can use any computer but this article covers the Pi). It will also work with an Airport Express or Apple TV.</li> <li> Powered speakers connected to the Pi&#39;s 3.5mm analog stereo jack.</li> <li> Either an ethernet connection or a <a href="">wifi adapter that will work with Raspbian</a> such as the Edimax EW-7811UN.</li> <li> Either a Windows/Mac computer running iTunes, or a Linux computer</li> <li> An iPhone/iPad with <a href=";mt=8">Apple&#39;s Remote app</a>.</li> </ul> <h2> Diagram</h2> <p><img alt="" src="/sites/default/files/pictures/pi-daap-airplay.png" style="width: 350px; height: 193px;" /></p> <h2> Server Setup</h2> <p>In this reciple, the server is on all the time, and is where you store all your music. The server uses a protocol called DAAP to provide information about your music library (Artists, albums, tracks, cover art etc) to your iDevice, and can be controlled by your iDevice to send music to AirPlay speakers.</p> <p>If you have a desktop PC or Mac then you can use that as your server, simply by having iTunes open. You need to setup iTunes to share your library and allow it to be controlled by your iPhone following <a href="">Apple&#39;s instructions</a>.</p> <p>If like me you don&#39;t have an always-on iTunes-capable computer (all mine are laptops), then you can use any cheap computer (including a Raspberry Pi) running Linux and DAAP software. I use an HP MicroServer, but a large number of NAS devices will run <em>forked-daapd</em> (the software I will use in this article) and Synology NAS devices come with <a href="">this functionality in their DSM software</a>.</p> <h3> Installing forked-daapd</h3> <p>There is a large amount of good information about the version I use from the author, so I shall not repeat it. See <a href="">his instructions</a>&nbsp;for installing and setting up the software on a Raspberry Pi (yes you can use a Pi for the server as well as the AirPlay speakers), but his <a href="">github project page</a> also has instructions for compiling it from source to use on any Linux distribution.</p> <p>The <a href="">README page</a> tells you how to set up your iDevice&#39;s Remote app to work with the server.</p> <p>You will also want to follow the instructions to configure <em>forked-daapd</em> to find your music files. This will invovle editing the <em>/etc/forked-daapd.conf</em> file</p> <h2> AirPlay speaker setup</h2> <p>The recipe here will work with Apple&#39;s own AirPort Express and Apple TV devices, as well as any third party AirPlay-compatible speakers you may own. You can also make your own AirPlay speakers using a Raspbery Pi running <em>shairport-sync</em>, as follows:</p> <h3> Install Raspian</h3> <p>Download the <a href="">latest Raspbian image</a>, and follow <a href="">Raspberry Pi&#39;s own instructions</a> to install it on an SD card. When you first boot up the Pi with a monitor and keyboard connected, you will be prompted to run the raspi-config tool. Run this as instructed (see the <a href="">guide</a>) to:</p> <ul> <li> Change the hostname of your Pi (e.g. call it &quot;bedroom&quot;).</li> <li> Expand the operating system to use all the available space on the SD card (otherwise you might run out of space).</li> <li> Change the password for the default user &quot;pi&quot;.</li> <li> Enable SSH (remote access).</li> <li> Force your audio to analog (you probably don&#39;t need to do this).</li> </ul> <h3> Update your Pi</h3> <p>Update the Raspberry Pi firmware to the latest version:</p> <pre> sudo rpi-update sudo reboot </pre> <p>After a reboot, update Raspbian:</p> <pre> sudo apt-get update sudo apt-get upgrade</pre> <h3> Setup Wifi</h3> <p>If you use a wired connection, you can skip this step.</p> <p>You will want to set up your USB adapter so that it automatically connects to your home Wifi network.</p> <p>First, check your hardware is working (drivers for popular adapters are installed in Raspbian by default):</p> <pre> ifconfig</pre> <p>If you see a paragraph about <em>wlan0</em>, your device is available. If not, look online for how to install the drivers.</p> <p>Edit the /etc/network/interfaces file:</p> <pre> sudo nano /etc/network/interfaces</pre> <p>You want it to look like this:</p> <pre> auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp auto wlan0 allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf wireless-power off iface default inet dhcp</pre> <p><span style="font-family: Arial, Verdana, sans-serif;">Next edit the wireless config file:</span></p> <pre> sudo nano /etc/wpa_supplicant/wpa_supplicant.conf</pre> <p>It should look like this:</p> <pre style="margin: 0px; font-size: 9px; font-family: Monaco;"> ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid=&quot;YOUR_NETWORK_NAME&quot; psk=&quot;YOUR_PASSWORD&quot; scan_ssid=1 } </pre> <h3> Log in via SSH</h3> <p>Once you have networking set up correctly, you can disconnect the keyboard and display and follow the remaining steps by logging into your Raspberry Pi from another computer via SSH. If you have a Pi model A or A+ and are using wifi you will likely have to do this because you only have one USB port - which you will need for your Wifi adapter.</p> <p>To connect via SSH, follow the Raspberry Pi Foundation&#39;s <a href="">instructions</a>.</p> <h3> Install AirPlay software</h3> <p>The popular <em>shairport</em> software emulates an AirPort Express on Linux, and it is this that receives audio from your iPhone or your server and sends it to your speakers. There are a few versions of shairport, I use a derivative called <em>shairport-sync.</em>&nbsp;it is a bit more responsive - music plays quicker and it responds to volume changes quicker - and will synchronise music playing in different rooms, which is great for multi-room audio. The disadvantage is that, unlike shairport, you will need to compile it from source.</p> <p>If you prefer to go the easy route with <em>shairport</em>, simply&nbsp;run:</p> <pre> sudo apt-get install libshairport1</pre> <p>To install <em>shairport-sync</em> instead, follow these steps:</p> <h4> 1. Install dependencies:</h4> <pre> sudo apt-get install <span>autoconf libtool libdaemon-dev libasound2-dev libpopt-dev libconfig-dev</span> sudo <span>apt-get install avahi-daemon libavahi-client-dev</span> sudo <span>apt-get install libssl-dev</span></pre> <h4> 2. Download the shairport-sync source:</h4> <pre> cd ~ git clone</pre> <h4> 3. Build and install:</h4> <pre> cd shairport-sync autoreconf -i -f ./configure --with-alsa --with-avahi --with-ssl=openssl make sudo make install</pre> <h3> Configure AirPlay software (optional)</h3> <p>This step <span>tells the software to use the hardware volume control on your Pi&#39;s internal sound card instead of the default, a lower quality software volume. It also sets the name that will be shown when you are choosing which speakers to send music to. It is not necessary, but recommended.</span></p> <p>Edit the startup script for your Pi. Depending which version you installed above, it will be either:</p> <pre> sudo nano <span>/etc/init.d/shairport</span></pre> <p>Or:</p> <pre> sudo nano <span>/etc/init.d/shairport-sync</span></pre> <p>Find the line that looks like this:</p> <pre> start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- -d || return 2</pre> <p>You will want to edit this line so it looks like this:</p> <pre> start-stop-daemon --start --quiet --pidfile <span>$PIDFILE</span> --exec <span>$DAEMON</span> -- <span>-d</span> -a <span>&quot;Kitchen&quot;</span> -- <span>-d</span> hw:0 -t hardware -c <span>&quot;PCM&quot;</span> <span>||</span> <span>return</span> 2</pre> <p>Obviously you would replace &quot;Kitchen&quot; with the name you want to use.</p> <p>Then update your system&#39;s init configuration to load the shairport daemon at startup:</p> <pre> sudo update-rc.d shairport-sync defaults</pre> <h3> Reboot to finish</h3> <p>From the command line:</p> <pre> sudo reboot</pre> <h2> Playing your iPhone&#39;s audio on a speaker</h2> <p>Once you have your AirPlay Pi up and running, you can test it by sending some music to it from your iPhone. In iOS 7 and 8, swiping up from the bottom of the screen brings up a dashboard with an &quot;AirPlay&quot; option. Tap it, select your Pi from the list. Sound from any app - such as Music or Podcasts or Spotify or YouTube - will be output on the Pi&#39;s speakers instead of the iPhone.</p> <p>You can see some screenshots of this process on Apple&#39;s <a href="">AirPlay support article</a>. Remember, your Raspberry is emulating an AirPort Express so the process is exactly the same.</p> <h2> Playing music from your server on your speaker(s)</h2> <p>If you have a lot of music, your iPhone probably can&#39;t store all of it. You can however use the Remote app to remotely control iTunes (or <em>forked-daapd</em>). You can use this to pipe music stored on your server to your speakers. This means:</p> <ol> <li> The music does not have to be on your iPhone.</li> <li> Music is sent directly from your server to the AirPlay speakers, so music will continue to play if you close the Remote app or turn your iPhone off.</li> <li> You can select multiple speakers at once, to play music in multiple rooms.</li> </ol> <h2> Playing music from your server on your iPhone/iPad</h2> <p>If your server is a PC or Mac running iTunes, you can simply enable the <a href="">Home Sharing</a> function to stream music from your server and play it on your iDevice in the Music app.</p> <p>Home Sharing replaces an earlier mechanism of doing this, and depends on your Apple ID which unfortunately means cannot be supported by forked-daapd. Therefore if you&#39;re using a Linux server you will have to use a different app like <a href="">Simple DAAP Client</a>.</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/taxonomy/term/366" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">RPi</a></li></ul></div> Fri, 16 Jan 2015 11:36:53 +0000 Andy Jenkinson 550 at Raspberry Pi round 1 <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>I came home last week to a <a href="">Raspberry Pi</a> waiting for me. Work, family visits and a bout of illnes means I only managed to take a peek, that is until yesterday evening. I rummaged around in the bits box for a &pound;1.50 HDMI cable, a micro USB cable and a wireless USB keyboard. Then I set about giving it a quick go.</p> <p>My initial plans for the RPi are to use it to take a look at how XBMC are doing these days, especially with respect to user experience etc. I am interested to find media streaming software with as close to a good consumer product feel as possible, with the right mix of features of course. With this in mind I chose to take a go at <a href="">OpenELEC</a>, whose devs have been hard at work porting the project to the ARM platform. I initially figured I would cross-compile it which would be easy enough, but there are frequent binary distributions so it was even easier. I partitioned the SD card and copied across the relevant files manually in less than 15 minutes, but there is actually a script to do all this automatically, assuming you&#39;re using Linux.</p> <p>First boot gave me a mount error for the SD card partitions, which I figured was due to an SD card incompatibility (I knew there were compatibility issues with the RPi already). However, a quick bit of research showed this issue was introduced with an update to the kernel in r11193. I copied across the previous version&#39;s kernel manually and, well, it worked! [Later releases have since had this issue resolved as of r11312].</p> <p>First impressions are that it works surprisingly well. Transitions are slow whilst the library is updating, but otherwise fine. Making selections does have some delay, but perfectly passable. Videos take a couple of seconds to start, and the HD videos I tried needed a good few seconds to catch up with the audio, but from then on are flawless. The one exception was a HD movie with a DTS soundtrack, which was jumpy. Could be that the bitrate is too much for the Pi to stream over the network, but it seems unlikely to me. Fast forward and rewind do not work, and neither do power controls from the UI. There are other issues, such as glacial media library changes (changing watched status for a film takes about 20 seconds!) but overall my impression is really quite good. XBMC itself is slick.</p> <p>The one mini project I had in mind was to get&nbsp;<a href="">HDMI-CEC</a> working (the protocol for automatic input switching, remote control via HDMI etc). This is useful since I was looking to avoid adding another remote to the drawer in the lounge... Imagine my surprise only to discover that someone had already had this idea, and basically completed it. Not only that, but it was incorporated into the OpenELEC RPi build already, so the only thing I had to do was turn on the web service API (which the module daemon uses to communicate with XBMC) in the settings. My Sony remote worked out of the box. There are issues around input hogging and occasionaly my TV gets confused about whether it is using the amp or its internal speakers, but it&#39;s 90% there.</p> <p>I now intend to take a look at offloading the media database from local SQlite to MySQL on my ReadyNAS Duo. The NAS isn&#39;t particularly powerful so not sure if this will improve performance or not, but it will at least make hacking the media library much easier! After that, I&#39;m thinking Skype integration... this could be too big a project though, and licensing issues could prevent distribution so some investigation is in order.</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/taxonomy/term/366" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">RPi</a></li><li class="taxonomy-term-reference-1" rel="dc:subject"><a href="/taxonomy/term/367" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">XBMC</a></li><li class="taxonomy-term-reference-2" rel="dc:subject"><a href="/taxonomy/term/368" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">OpenELEC</a></li></ul></div> Sat, 16 Jun 2012 11:00:15 +0000 Andy Jenkinson 544 at