Music Hack Day 2012

Posted on Apr 23, 2013

Music Hack Day (MHD) is an international 24-hour event where programmers, designers and artists come together to conceptualize, build and demo the future of music. Software, hardware, mobile, web, instruments, art - anything goes as long as it’s music related.

Barbertron logo

Barbertron is the name of the software I worked on with a friend for London Music Hack Day 2012. It’s software that takes in audio and (tries) to make it sound like a barbershop quartet.

While I was working in London for my placement year in 2010 my friend Dan Horgan invited me to a hack day called London Music Hack Day. We had a great time hearing about music and tech with some talks during the day and then we made a pretty cool program the rest of the weekend. I was part of a team of 4 developers and the software we created, while not the best in terms of stability or polish was actually rather novel at the time. Nirtous Oxide outputs MIDI control signals by tracking object positions in the XY plane using chroma-key tracking. This means you can control sliders, XY planes and buttons in software like Ableton Live using a webcam and coloured paper instead of a costly MIDI controller.

Now I’m working in central London full time and so is my friend. When I saw there was going to be a London Music Hack Day in 2012 I made sure we both signed up and organised a trip to the pub to pre-plan ideas. The main one that stuck was “something to generate barbershop”, and this gave us the rough plan for the weekend.

The event in 2012 was held in the London Facebook offices which were excellent for hosting this kind of event. On the Saturday morning we all sat through presentations from the various sponsors of the event, showing off what APIs they had on offer and trying to inspire us to use them. Memorable presentations came from:

  • The Echo Nest, I heard about them at MHD 2010 and used their API as part of my final year project for university
  • Deezer A cool web based service similar to Spotify
  • Facebook had a nice demo on how to use their developer SDK
  • Twilio had an excellent demo on using their API to deal with phone calls and SMS messaging

While we had initially planned to create the Barbertron I was a little unsure and was worried that we’d never get it done in time or that what we would end up with wouldn’t be good enough to demo. I started a new project that was simpler, using the Facebook API to cross-reference places people check in and music they like to help classify places. After some initial feasibility testing we discovered the Barbertron idea may actually work, so I ditched my Facebook project and dedicated the next 20 or so hours remaining to the Barbertron.

The initial plan was to use Pure Data to take a live audio input, split it into 4 streams and pitch shift each stream by however many semitones needed to get a nice harmonised barbershop effect when the streams were all combined again. After some playing with Pure Data we had a patch that looked something like this:

Barbertron Pure Data patch

The Barbertron patch takes in MIDI notes, we used a MIDI keyboard, to control the pitches of each of the 4 “voices”. We took the semitones of each MIDI note from middle C as the change for each voice. We didn’t try and make it match pitches or do any natural chord patterns because with our singing voices we really needed individual control of each voice.

Barbertron generic pitch shifter patch

The generic pitch shifter patch is a slightly modified demonstration patch that comes with Pure Data (G09.pitchshift.pd) which we used to set the tone of each of the voices.

Once we had a working barbershop patch we started extending the project into something to demo. During the morning demos from the sponsors we saw how to use Twilio and Dan thought we could use it so that we could dial a number, sing a song and have the Barbertron turn it in to barbershop and call you back to play it. This was obviously an excellent idea so Dan set about using C++ and Libpd to automate the barbershopping process and I worked on setting up my NAS as a server to host it and using The Echo Nest to try and find the initial pitch of the recorded phone call.

After many hours and a very short break for sleep we had refined the Pure Data patches, set up my NAS as a git server, web server running python and compiling C++ projects and many other tasks resulting in a system overview like this:

Barbertron system overview

The whole process goes as follows:

  • Someone dials our Twilio number
  • Twilio records audio
  • Twilio sends the recorded audio file to my server
  • My server sends it to The Echo Nest for analysis
  • The Echo Nest tells my server how long the audio is and what pitch it thinks it was
  • Python then generates a control file for the MIDI notes to send and at what times for the barbershopping
  • Python calls a C++ program with the control file and the audio
  • The C++ program reads the audio and streams it into the Pure Data patch, signalling MIDI notes as specified in the control file
  • The C++ program saves the output from the Pure Data patch to a new audio file
  • Python uploads the new file to Soundcloud
  • Python asks Twilio to call the number back and play the barbershopped audio
  • Python also asks Twilio to text the number back with a link to the Soundcloud file

And that’s the Barbertron!

Due to our project starting with B we were the second the demo. We were working down to the last minute to get Twilio and Soundcloud working so had no time to practice the demo but it went surprisingly well. I did some talking and diagram pointing while Dan did the singing and keyboard controls to show off the effect which went excellently. We even managed to show off the phone version despite having to stall for time while waiting for it to call us back.

The git repository has almost 100 commits between 2 of us and only a couple of hundred lines of C++ and Python. The rest was all Pure Data and a little bit of showmanship from Dan.

Twilio gave us a Raspberry Pi as a prize for our use of their API in our project which was excellent. Afterwards we also had a few people come up to us saying how much they enjoyed the idea and wanting to find out more detail on how it worked.

After the event mentions of the Barbertron ended up on the NME blog, Wired and even a brief paragraph in the Ultimate Guitar news section.

In general we saw some great demos, wrote some cool code and had a great time. Bring on Music Hack Day 2013!