From parties at friends' houses to presentations at work, we've all been caught short by lack of speakers more than once. For groups of people, your laptop speakers simply don't cut it, but why can't you use the power of all those smartphones lying around the room?
What it does
Amplify allows you to play audio from one source across all your tablets, laptops and smartphones at once. It syncs the timestamp on every device so audio is played in sync: it sounds like one single speaker using a swarm of internet-connected devices.
How we built it
We built the server from the ground up in C#, running on a Windows Azure instance. The controller and receivers are all web-based: this means they can run on any device. The main controller uses WebSockets and the Web Audio APIs to transmit source input data to the web server, where it is processed and sent (again, via WebSockets) to all of the receivers currently online. In order to make sure that all of the devices play the same audio at the same time, we synchronise the time clocks via a JS script that accounts for average latency and any minor discrepancies in time.
Challenges we ran into
The main challenge was live-streaming the audio to multiple devices whilst making sure every device played the same waveform at exactly the same time. We found a low-latency solution to this via use of binary data and WebSockets: we built a JSON API spec to configure devices, then used PCM data via WebSockets to transmit the audio itself.
Accomplishments that we're proud of
Getting it to work! Also, working with iOS's Web Audio API implementation was complicated: we had to find a workaround to make media play, as it is muted by default.
What we learned
Don't use audio and networking at a hackathon! But, seriously: we learnt a lot about how non-JSON data can be transmitted in near real-time using Web Sockets, and how audio is processed and stored on a day-to-day basis.
What's next for Amplify
We intend to keep developing the app on the side, and hopefully shore it up a bit to make it work on a larger scale!