Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


Most viewed posts


Subscribe to RSS feed


Preconfigured Airplay speaker (Shairport) – Downloadable Raspberry Pi image

Stanislav KhromovStanislav Khromov

Update 2013-08-31
New image available for download with updates of Shairport, raspi kernel and better startup/watchdog scripts.

This is a preconfigured Raspberry Pi Debian build with Shairport. – Thread on Raspberry Pi forums

Write the image to a SD card (4GB or larger), plug in speakers and network, and an AirPlay-capable player will show up on your network once you boot the Pi up.

Build instructions
Detailed build instructions can be found here

Latest version:
2013-08-31

Download:
Mirror 1

Release notes
2013-08-31 – Updated of Shairport, raspi kernel and better startup/watchdog scripts.
2013-04-21 – First release

Login

Username: pi
Password: raspberry

Misc
Tested with Airfoil (PC/Mac) and Honey Player (Android).
Additional testing welcome. (In particular actual iOS devices!)
More stable builds will be available shortly.

Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
LinkedIn
Twitter
WordPress.org Profile
Visit my other blog

Comments 38
  • Lawrence
    Posted on

    Lawrence Lawrence

    Reply Author

    I built these following instructions elsewhere on the net but messed up the build when I tried to add a password and a USB soundcard.

    Found your image and downlaoding image now – Thanks 0- will save a bit of time!

    Is there instructions for adding a password and USB soundcard anywhere for this build?

    This is the soundcard – http://www.ebay.co.uk/itm/USB-External-3D-5-1-Channel-Audio-PC-Sound-Card-Adapter-/160612635510?pt=UK_Computing_ComputerComponents_SoundCards&hash=item2565425376

    Thanks.


    • Stanislav Khromov
      Posted on

      Stanislav Khromov Stanislav Khromov

      Reply Author

      The image should provide you with a good starting point.

      This build uses built-in audio, perhaps this tutorial may be helpful to you:
      http://amiexp.blogspot.se/2013/01/respberry-pi-with-shairport-and-usb.html

      The provided image boots to console, and you need a username and password (pi/raspberry) to log in.


      • Lawrence
        Posted on

        Lawrence Lawrence

        Reply Author

        thanks,

        I’ve editied etc/init.d/shairplay to change the broadcast name using JOE – that works fine but struggling with the syntax for the password..

        I’ve seen that switches for starting shairplay include

        -p, –password=secret Sets password

        but not sure the format the line

        user/local/bin/shairport -d -a “$NAME”

        I’ve tried

        user/local/bin/shairport -d -p 1234 -a “$NAME”

        can you help?

        Thanks


        • Phillip
          Posted on

          Phillip Phillip

          Reply Author

          Hi.
          Any progress on setting the password? I think I have to add a line in /etc/defaults/shairport were I changed AP_NAME – but I don’t know the syntax…
          Thanks for any hints
          Phil


  • Transient Gadfly
    Posted on

    Transient Gadfly Transient Gadfly

    Reply Author

    Hey, I’m trying to connect to my shairport pi via airfoil on Mac (tried 10.6.8 and 10.7.2)–in both instances Airfoil fails to connect and responds “could not parse response from remote server”. I’ve run shairport from the command line on the pi with “-vvvv” and I get the following output:

    Listening for connections.
    Established under name '4E502B554875@Shairport on jen'
    received request: OPTIONS * RTSP/1.0
    User-Agent: Airfoil/4.7.5 (Macintosh; N; Intel)
    CSeq: 1
    DACP-ID: 5B555495C449D615
    Apple-Challenge: 1a9jyDbkBBxncxsxohipvw
    Client-Instance: 8F2E848E0541200D
    Active-Remote: 3449327014
    sending response: RTSP/1.0 200 OK
    Apple-Response: rljNiXC1X86wKmTrpMVvU6k2JTW7MrJxf86tgoB18yISDcYF2utKKwEU3rE6tk5+BnV/Odz3bmxxzqQhXyOnnbV8h4neLsIO7EX4CHvWu21hR55SBks/qmf9jKqVRxyUQvShr8xs5c0E+4kwZbuPr0lPIGA2CdmdtpKVr2Lj20yGf9HPFK95o+7MUkMkKu08VcqyI/p0/Xb8d+J+8BIebYStGsANxO/VQnsAWnM0Bwm5QojE6blTYL143VqzbF0t0RdQoAz3Uf212mUleX+PQFKibvENv324fZytaIeC2VoLhw0Uyc6+dV6P1IOLh+hRzDHqkIfslwFnvo3j6fNC5g
    CSeq: 1
    Audio-Jack-Status: connected; type=analog
    Public: ANNOUNCE, SETUP, RECORD, PAUSE, FLUSH, TEARDOWN, OPTIONS, GET_PARAMETER, SET_PARAMETER
    received request: ANNOUNCE rtsp://192.168.0.3/3452057820 RTSP/1.0
    Client-computer-name: moss
    Client-instance-identifier: E063AC4C-78DD-4AC4-9CCD-96907D9A2D27
    Active-Remote: 3449327014
    DACP-ID: 5B555495C449D615
    User-Agent: Airfoil/4.7.5 (Macintosh; N; Intel)
    Client-Instance: 8F2E848E0541200D
    Content-Type: application/sdp
    Content-Length: 571
    CSeq: 1
    sending response: RTSP/1.0 200 OK
    CSeq: 1
    Audio-Jack-Status: connected; type=analog
    received request: TEARDOWN rtsp://192.168.0.3/3452057820 RTSP/1.0
    User-Agent: Airfoil/4.7.5 (Macintosh; N; Intel)
    CSeq: 1
    DACP-ID: 5B555495C449D615
    Client-Instance: 8F2E848E0541200D
    Active-Remote: 3449327014
    sending response: RTSP/1.0 400 Error
    CSeq: 1
    Audio-Jack-Status: connected; type=analog
    RTSP connection closed

    Any insight as to what might be wrong here? Thanks.


    • Stanislav Khromov
      Posted on

      Stanislav Khromov Stanislav Khromov

      Reply Author

      Hey Transient,

      There seems to be a bug report regarding this on the Shairport issue tracker. You can find the issue here:
      github.com/abrasive/shairport/issues/213 Issues have been removed from the GitHub project.

      This image is running the latest 1.0-dev version of Shairport. (As of today)


    • Juan Diego
      Posted on

      Juan Diego Juan Diego

      Reply Author

      I’m getting this same error on Airfoil for Mac (2.7.x). In addition, right before the Pi prompts the login/password dialogue I get a [FAIL] message startpar: service(s) returned failure: avahi-fix.sh … failed!. Everything works like a charm with iTunes for Mac or the stock Music app for iOS.

      (If someone is having problems with the audio output I suggest trying no to use HDMI for audio output (just connect your headphones/speakers). Otherwise run amixer cset numid=3
      where n is 0=auto, 1=headphones/speakers, 2=hdmi)


      • Stanislav Khromov
        Posted on

        Stanislav Khromov Stanislav Khromov

        Reply Author

        Hey Juan,

        Is this with the downloaded image without modifications?
        Avahi-daemon failing is usually a sign of network connectivity issues (for example Wi-fi that hasn’t connected yet.)

        You might have some luck checking for possible causes to the error in:
        /var/log/messages

        What is the issue with HDMI audio out?


        • Juan Diego
          Posted on

          Juan Diego Juan Diego

          Reply Author

          Yeah, my downloaded file is exactly from this link: https://snippets.khromov.se/files/shairport-configured-latest.tar.gz

          And I obtain local IP before that message of avahi-fix.sh failed. Once in the command line, to ping/curl google.com, for example, works OK. I’m gonna check /var/log/messages anyway. That avahi thing can cause some kind of future error? Cause right now I get nice sound and all but the Pi keeps displaying packet-related errors only while playing music I send from my iPod or Mac.

          And about HDMI, the first time I tried to use Shairport I got no sound at all (neither using the aplay command). That was because the Pi generally does not output sound via HDMI so I tried Shairport without the HDMI plugged in and everything worked fine. Then I fixed the issue by presetting the audio output to sound card which ends at the 3.5mm audio jack. I ran amixer cset numid=3 1 on CLI.


  • Josh
    Posted on

    Josh Josh

    Reply Author

    If I unplug the pi, and plug it back in, it completely stops working. I have tried everything I can think of. I then must reformat the sd card to get it working again. I would love to be able to unplug the pi and move it to a different speaker without having to reformat the card every time or plugging in a screen and keyboard. Any Ideas??

    thanks,

    -Josh


  • Benny Kjølhede
    Posted on

    Benny Kjølhede Benny Kjølhede

    Reply Author

    Hej Guys. I can´t get my image on to my sd card useing disktools on my mac. It says all kinds of errors. Do you have any ideas what might be wrong ? And is there a other way i can copy the image over ?


  • Marc
    Posted on

    Marc Marc

    Reply Author

    Hi Stan or any other expert,

    Thanks for this work, it has been very useful … so far.

    I’m trying to change the name of the Airplay network. The off-the-shelf one is “AirPi” when using your preconfigured image. I would like to change to something like “Living Room”.

    I’ve checked the shairport file in /etc/init.d/ however there are no mention of “AirPi” :(

    Can you help?

    thanks
    marc


  • Thomas Pujolle
    Posted on

    Thomas Pujolle Thomas Pujolle

    Reply Author

    Hey there,

    I believe you want to edit the shairport file, which is here:

    /etc/init.d/shairport

    You ‘ll be able to find the name of the speakers there :)

    Now that I’m here, maybe of you can help me! I’m trying to get the most out of my RPi, mainly some high quality music! I’ve set everything so far, and I think it could be much better!

    I’m using Spotify (Deezer, Grooveshark like) to play music, and even though the sound quality is perfect using a jack on my speakers, some frequencies don’t seem this smooth as I listen to what I play.

    Has anyone figured out how to improve this quality? I’m not using the “ready to go” image, I’ve setup everything myself. Do you think using the OS image would work better?

    Thanks guys :)


    • Stanislav Khromov
      Posted on

      Stanislav Khromov Stanislav Khromov

      Reply Author

      Hi Thomas,

      You can improve the audio quality by using a USB DAC instead of the built-in raspi output.

      This article is a good starting point: http://www.raspyfi.com/the-right-usb-dac-for-your-raspberry-pi/

      As for improving the quality on your existing setup, the only thing I can suggest is running rpi-update. This will update the kernel, and sometimes that results in improved audio quality.

      You can get rpi-update here: https://github.com/Hexxeh/rpi-update

      Cheers!


    • Marc
      Posted on

      Marc Marc

      Reply Author

      Thanks Thomas

      Actually within /etc/init.d/shairport the name is set as
      NAME=My Shairport

      although the one shown on my iphone and ipad is “AirPi”

      I would like to change AirPi into “Living Room” for instance … but seems shairport is not the right place?

      anyone can help? thanks
      marc


      • Marc
        Posted on

        Marc Marc

        Reply Author

        Actually, I found the solution!

        In the case of using the ready to go image the file to edit in order to change the Airplay network name is

        /etc/default/shairport

        and NOT

        /etc/init.d/shairport


        • Marco Buongiovanni
          Posted on

          Marco Buongiovanni Marco Buongiovanni

          Reply Author

          Ciao, io ho localizzato il file corretto /etc/default/shairport ma io non sono in grado di modificarlo perché il sistema mi dica che non ho le autorizzazioni e non sono il proprietario del file.
          Ho provato a cambiare i permessi con chmod comando ma ho avuto lo stesso messaggio.

          Suggerimenti?
          Marco


        • Marco Buongiovanni
          Posted on

          Marco Buongiovanni Marco Buongiovanni

          Reply Author

          Hi, I have localized the correct file /etc/default/shairport but I’m not able to modify it because system tell me I haven’t permissions and I’m not the proprietary of the file.
          I tryed to change permissions with chmod command but I got the same message.

          Suggestions?
          Marco


          • Stanislav Khromov
            Posted on

            Stanislav Khromov Stanislav Khromov

            Reply Author

            Hey Marco,

            You need to be root to change configuration scripts.

            Run this command before editing

            sudo su
            

  • Thomas Pujolle
    Posted on

    Thomas Pujolle Thomas Pujolle

    Reply Author

    Hi again,

    Has anyone of you encountered some stability issue with the image? When I’m on SSH it appears that the connection gets randomly cut (host is down, I can read). It happens very often, with no particular reason.

    Anyone?


    • Stanislav Khromov
      Posted on

      Stanislav Khromov Stanislav Khromov

      Reply Author

      Hi Thomas,

      That usually happens when there is insufficient power supply to the Pi. The image is configured to use stock 700mhz, with no overclock.

      • Did you overclock the Pi after installing the image?
      • Do you have adequate power supply?

      Here is a great post on Raspi power supply issues:
      http://forum.stmlabs.com/showthread.php?tid=3918


  • jnew
    Posted on

    jnew jnew

    Reply Author

    I am having a problem when I try to run shairport over wifi. Everything loads properly and “AirPi” shows up on my phone. I connect and push play and it works great. It plays without problems for 30-45 seconds and then stops. It will usually cut in and out a little and then eventually crash. If I unhook the wifi dongle and use a LAN connection, I can play music all day without problems. I tried doing the load from Raspbian on my own and had this problem. In researching the issue I found your load and tried it. It worked like a charm but I still have the wifi issue.

    I am currently testing the setup and the pi is about 2 feet away from my wireless router. The link quality on the pi says perfect (100).

    I bought the pi as a set with the wifi dongle and it looks pretty cheap, but it worked out of the box. I am wondering if I should try another wifi dongle but before I do, I would like your advice.

    Thanks in advance!


  • Dan Henderson
    Posted on

    Dan Henderson Dan Henderson

    Reply Author

    Hi there,

    Thanks for this. I tried it and it works straight away with my Galaxy S4 on 4.3, Galaxy Note 10.1 on 4.2 and IPhone4s on IOS7. There is a few seconds lag in between pause, volume change commands and the output changing, but I’m guessing that’s just how it is?

    The one thing I wanted to ask though, is that the playback is a bit glitchy on my devices so it crackles a bit and sometimes goes intermittent. I’ve updated using apt-get update and upgrade and also rpi-update. Is there anything else I should do? My wifi is a fair speed and there’s not alot connected to it.

    Thanks for any help, and thanks for building this!

    Dan


    • Stanislav Khromov
      Posted on

      Stanislav Khromov Stanislav Khromov

      Reply Author

      Hi Dan,

      Happy that most of it is working for you.

      Is there any particular device you are having an issue with? I know that I started having some issues with iOS 7 devices, but the android ones work great. Is that also the case for you?


      • Dan Henderson
        Posted on

        Dan Henderson Dan Henderson

        Reply Author

        Hi,

        I’ve just done some more testing (on both my rpis to check) and the android devices have a longer lag between playing and skipping tracks etc (the iphone seems to be pretty fast now!)

        But both have the same problem with a slight crackling all through playback, almost like the noise you get when you pull selotape(!) but quieter and intermittent.

        I’m using a usb soundcard (fairly cheap one) so it might be that, although I’ve had good sound out of it before. I can’t think what else to do to try and sort it out. Any thoughts would be much appreciated!

        Hope it doesn;t sound like a complaint though…this is awesome!

        Thanks,

        Dan


        • Dan Henderson
          Posted on

          Dan Henderson Dan Henderson

          Reply Author

          Just to say I’ve switched to wired internet to make sure the wifi isn;t the culprit but same thing.


        • Stanislav Khromov
          Posted on

          Stanislav Khromov Stanislav Khromov

          Reply Author

          Did you try the built-in audio jack?

          I actually compared the built-in jack with a cheapo USB sound card and the built-in one sounded better.

          Another option you could try is compiling a later version of Shairport, as per these instructions:

          https://snippets.khromov.se/raspberry-pi-shairport-build-instructions/

          During the git clone, check out the “master” branch instead of “1.0-dev”, the master one seems newer.

          So you would do it like this:

          git clone -b master git://github.com/abrasive/shairport.git
          

          Hope that helps.


  • Alessandro
    Posted on

    Alessandro Alessandro

    Reply Author

    Hello,
    I installed shairport following all the procedures of your site and it works well. But I would like to start shairport by the demon (/etc/init.d/shairport) using the default file /etc/default/shairport with a name that includes spaces such as:
    “Air Pi of Alexander”
    I have tried in various ways, but I could not, can you tell me how I can do and give me a solution.
    Thank you.


  • NPLDK
    Posted on

    NPLDK NPLDK

    Reply Author

    Hi

    My pi is working perfect using airplay using shairport

    I have one question

    How can i get a 5vdc signal when using airplay
    High when playing music on airplay
    Low when not playing music on airplay

    Best regards
    NPL


  • Carlo
    Posted on

    Carlo Carlo

    Reply Author

    Hi,
    very great tutorial…
    I have two questions:
    1) It seems that it is not working with Android phones (Andorid > 4.2) is it possible ?
    2) If i want to execute some actions (execute a bash script) when a device connects/disconnects where do I have modify your scripts ?
    Thank you!
    Carlo.