Silent Disco – Streaming Live Audio over WiFi

I’ve just finished building a Silent Disco over WiFi system for use in the Christchurch Body Festival – Silent Disco, giving guests the opportunity of using their own smartphone for receiving the audio signal rather than fragile (yet expensive) speciality headphones. In the process I have figured out a few things about WiFi, audio streaming and Linux in general

  • WiFi reconnection sucks
  • There’s no real way around it. WiFi is a two way communication, and even without encryption on less complex standards, there are still the overheads of introductory handshakes and assigning IP addresses. To handle a drop of connection less than a second, a buffer of several seconds is needed. Several seconds is an eternity in the audio world.

  • jQuery rocks my world
  • Literally. Rock music is playing in my world thanks to jQuery and jPlayer. Receiving audio streams on a modern device (iOS/Android smartphones, tablets, netbooks, laptops, computers) with an up-to-date browser wasn’t meant to be this easy. Reference the stream, $(“thePlayerObject”).jPlayer(“play”); and walk away. Yes, it is “play and walk away”. For multi-device happiness, throw a few various formats of streams at the user, and let jPlayer pick the most suitable one for the device.

  • PulseAudio has matured
  • No longer the buggy unfamiliar temperamental newborn child, PulseAudio on Linux has matured to the point of being able to do some really fun things. Sure, it’s not quite as versatile as JACK, but for shipping on a plain vanilla Long Term Support install of Ubuntu 12.04 it is vastly more capable than what 99% of users will throw at it. On the main SilentDisco computer that was responsible for capturing audio, converting it so a stream, hosting the webplayer front end and running the WiFi, the input side of the audio “card” was handled separately from the output side. This means I could record/stream a feed, and on the same computer open a browser and play the outputted stream – not a direct hardware mix of the incoming audio but instead the whole packaged product sans WiFi transmission in-between.

  • ThinkPads set the bar
  • There is not a laptop out there that compares to a ThinkPad. Some Mac users might raise points about how much shiny-er and unibody-er their units are, but putting aesthetic form over functionality when comparing workhorse tools is a severely flawed argument. ThinkPads a reliable, sturdy, hard working. The “nipple” allows use of a pointing device without moving your hands from the home row every single time, and the left/right “mouse” buttons are reachable from home row too. The hardware has great support across all OSes and is real – not emulated in software as too many modems, soundcards, WiFis and even graphics are.

  • Icecast Streaming is a horrible thing to Google for
  • The only thing worse for signal:noise ratio of “me too i needz halps for free plz” posts compared to the number of knowledgeable developers is PHP Forum software. I get that copying error messages into a forum post somewhere is often a good way to get solutions without spending much effort having to learn the fundamentals, but after a while there are so many many many posts that the fundamentals themselves become hard to find, compounding the problem. Once the trend begins, few threads are marked as Closed or Solved because people keep hitting their problem with the copypastehammer until it’s fixed and aren’t even sure which thread it was that had the answer, or if that thread alone was the solution. Queue the grumpy old man rant about Eternal September…..

    Codemonkey of Node.js, Django, PHP and all things HTML5 Solving tech challenges, one bit at a time.

    Posted in linux Tagged with: , , , , , , , , , , , , , , , , ,
    4 comments on “Silent Disco – Streaming Live Audio over WiFi
    1. Will Derrick says:

      Drats, I thought I’d come up with an ingenious and original idea with “smartphone silent disco”, but you’d beaten me it by months (and there’s supposedly suggestions in an Apple patent in 2011).

      I’m thinking of integrating the whole setup into a Raspberry Pi, with an external soundcard (because the integrated one is awful.) Do you have any advice or things to avoid other than what’s mentioned in the blog post? Did you find the difference in latency caused any issues for the clubbers?

      Apart from a slight difference in people jumping and tapping and stuff, I’m thinking it wouldn’t have too much of an impact.

      • Wulf Solter says:

        The latency issue is certainly an interesting one. When I reduced all buffers as much as possible (soundcard, icecast, HTTP/TCP and client device buffers) it was still ~100ms, but between server load spikes and intermittent WiFi connections doing reconnects/resends this caused audio drop outs far too often even under ideal circumstances. What I ended up doing was bumping server buffers (soundcard/icecast) up enough to be consistent, and adding about 1000ms of buffer on the client device. This is major massive latency in the audio world, and well out of sync with what an analogue soundsystem would be pumping out, so I then dialed in a matching delay on the analogue/PA side of things to keep it all in sync. If the DJ wants a booming foldback/monitor setup this obviously isn’t going to play nicely (it’s a silent disco!), but I personally prefer playing with IEM (in-ear monitors) or fully under acoustically well shielded headphones to save my hearing anyway so it wasn’t too much of an issue. A bit strange to see the crowd reacting almost 2 seconds after what I heard, but nobody but the DJ needs to know.

    2. Jakob says:

      Hey Wurlf,
      Great post, I found it a bit late. I have been trying to set up a silent disco device with a raspberry pi as base for quite some time now. RIght now I’m using Jack, darkice and icecast2 to stream to an open wlan, all on the pi, Audio comes in through a usb soundcard. But I can’t get the setup right so all clients are synched, there is a delay of several seconds between them. Any advice, or do you think you would have time sometime to share your setup in greater detail?


    3. aBe says:

      I was thinking of another approach for non-live DJing: we have a session. When people arrive, they can download the session from a minimal local web server (nodejs?).

      The only thing left is to send a sync signal every few seconds to start playing the right time.

      I guess I would need a way to sync the mobile clocks. I don’t know how they do it, but somehow tells you how much your time is off.

      Any comments on that approach (streaming only sync data instead of audio data)?

    Leave a Reply

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