I spent the weekend at Music Hackday London, a 24-hour event where a bunch of developers, designers and artists get together to build cool music-related hacks.

I spent my time building a hipster robotic arm that stops you listening to any music it deems “too mainstream”, here’s what it looks like:

and my demo for Music Hack Day London:

The hipster-robot is a cheap robotic arm (currently £30 from Maplin, takes about 2-3 hours to build) controlled by a Raspberry Pi, which monitors the music playing from Spotify on your laptop. Play any artist currently in the top 100 artist “hot list” (the “top_hottt” API from The Echo Nest), such as Taylor Swift or Just Bieber, and the robot kicks into action, pressing the spacebar on your computer to stop the music playing.

The Parts

There are a few moving parts to this hack (literally!):

1) A laptop running a tiny webservice (using Sinatra) that returns the current artist and track name from Spotify. Those details are retrieved from Spotify using AppleScript.

2) A battery-powered robotic arm, connected to…

2) A Raspberry Pi. The Pi acts as the controller for the robotic arm, using a simple controller I wrote in Ruby (robotic-arm-driver on GitHub). A small Ruby app (hipster-robot on GitHub) runs on the Pi, polling the Spotify service running on the laptop.

The Code

The first challenge was to get the robot to do anything. I found an excellent post here which details the USB protocol for the robot, as well as some sample Ruby code to get the robot to rotate at it’s base. With these, I was able to write a simple controller for the robot arm.

Now I could control the arm, I needed to build a simple web-service which would run on my laptop, and return the artist and track name for the track currently playing on Spotify. This was a quick job – fire up a Sinatra app that uses a command-line interface to Spotify to retrieve and return the track details.

On the Raspberry Pi, I then created hipster-robot, a small Ruby app which does three things:

1) At startup, queries The Echo Nest API “top-hottt” to get a list of 100 “hottt” artists at the moment, e.g. Taylor Swift, Justin Bieber, etc.

2) Periodically calls the Spotify service running on my laptop (I would have preferred to use sockets/websockets for this, but I ran out of time), and then compares the current track playing on Spotify to the cached list of “hottt” artists.

3) If the artist is deemed “hottt”, then the hipster robot kicks into action to prevent you listening to such a mainstream artist. The app sends commands to the arm for it to lift up, rotate right, and press the spacebar on the laptop (which causes Spotify to pause the current track).

I had great fun mucking around with hardware this weekend. Robots rule!


Trackbacks for this post

  1. ‘Hipster Robot’ judges you for listening to popular music - The Strut
  2. Hack Day Recap: London Music Hack Day | Spotify Developer
  3. Robot-Sara – a recommendations robot | Aaron Randall