Bit.ly held another Hackathon last night, with the intent of playing around with the data available from 1.USA.gov’s developer resources. We were given JSON data representing which government URLs were being visiting, along with user-agents, location, time and other relevant information.
At first I was more interesting in spending my time on a completely unrelated project – writing OCaml bindings to libsmf, a Standard MIDI File library. My efforts can be found on the OCaml smf library page or on my github.
Soon, however, I started to look around at other people’s projects and decided I should participate. Since I was working on a MIDI library, I decided that the perfect project for me would be to translate the data into MIDI. Using the Yojson library to parse the data and OCaml Portmidi (another MIDI library I work on) to generate MIDI events, I created a simple program that hashed the URL to determine which note to play, and hashed the user-agent to determine how long to play the note.
In order to better share this with other people, I went back to working on the smf library and added in the functionality to allow writing MIDI data to a file. Once that was complete, I added that into my Bit.ly project and created a MIDI file. Using timidity I converted it to an mp3 so I could share it with the internet!