We Automated 12 Android Phones To Sing 'Appy Holidays To You [VIDEO]

With Holiday Season and the close of the fiscal year approaching, we brought in all of our remote workers to spend some time together. We had the obligatory corporate holiday party, a late-night LAN party, and countless, invaluable meetings that laid the foundation for software development projects in the new year.

Our VP of Engineering also arranged our first hackathon, in which we submitted ideas for programming projects that were tangentially related to our business. To participate, we were broken into teams and powered through our ideas and execution over two days. Some of our developers have been interacting with Android phones, but haven’t had a chance to play with them. Thus, I ended up on a team of three with the goal of getting multiple Android devices to sing in harmony. We’re happy to share the result of our efforts with this cheerful holiday video. See the original video here. Follow the conversation on Reddit here and here and on HackerNews here. So, how does it work? We went with a pretty quick-and-dirty approach, seeing as this was a two-day event. Having multiple devices sync musical notes in realtime was definitely out of the question, so we opted for seeing if we could coordinate the phones to begin playing their individuals parts of a song at the same time. Android devices are finicky and difficult to coordinate, many of their operations take varying amounts of time, even on identical devices. Simply pushing a song to each of them and telling them to play, results in some phones playing within a second while others can be up to four seconds behind. Here’s what we did: @classam wrote a python script which takes any MIDI file and distributes its separate instrumental parts onto an arbitrary number of tracks. It’s pretty neat: specify just two tracks, and half the parts of the song will be played on one track, and half on the other. If you specify more tracks than available parts, it copies the more significant parts onto the leftover tracks so every phone will feel like it’s a valued member of the choir. I wrote an Android app which runs on the phones. The app runs on each phone and listens on a socket. When it gets the ‘GO’ command over the USB cable, it plays the music file it’s been given. It also displays a musical visualization of the sound it’s playing so you can match up the phones to the sounds you hear. @etmillin wrote a javascript program which finds all the Android devices connected to a computer, gets a connection to the song App running on each one, and sends the ‘GO’ command to all of them at once. When you glue our three pieces together, the following happens:

  • A MIDI song gets broken into parts, one for each phone
  • The parts of the song get uploaded, one to each phone
  • The song-playing app gets started on all the phones
  • The ‘GO’ command gets sent to all the phones at once

Now they all play together! Other hackathon projects included experimenting with different types of network messaging solutions, devOps management tools, ECMAscript7, contributing to open source projects like Travis CI, and building hardware which displays the state of our continuous integration build. Be warned, we didn’t polish the code for this blog post but you can find it on github: https://github.com/classam/5rat -Jonah Stiennon, Ecosystems, Sauce Labs Want to work at Sauce Labs? Submit your resume! https://saucelabs.com/careers

Written by

Bill McGee

Topics

Mobile testingDevOps

Categories