top of page
Writer's pictureDinushki De Livera

TRANSLATING MUSIC INTO DATA

Updated: Dec 7, 2022

In 2019 I created the "Firebird Suite; Infernal Dance" visualization for the IronViz feeder themed “music”.

The intention of this visualization was to give music a new dimension and perspective by making it pleasing to the eye as much as it is to the ear.

One of the highlights of this viz was the animation that enabled the user to watch the notes being played while listening to the music and seeing the instruments behind the sounds helping to bring the story and composition to life.


Before I start, I cannot take full credit for this method by any means. I had an immense amount of help from my guru/mentor/boss Jeff Shaffer who is not only a Tableau Zen Master but also an incredible musician! This is another one of his genius doings, that I used in my work.


Without further ado…


How did I translate the music into data?

This process was actually quite easy and not nearly as time consuming as expected.


Step 1: Find a MIDI file of a song you have in mind. I picked the Infernal Dance from the Firebird Suite because it had the perfect balance of tempo, pitches and energy. Also, after listening to a couple of other recommendations, this was my favorite!

MIDI stands for Musical Instrument Digital Interface, which makes perfect sense for our use case. This file has all of the critical information we need. We just need to find one and then access that information.


How to find a MIDI file? Typically googling the song name and “MIDI file” behind it should give you a good start but a couple of places you can also look at are ; https://www.midiworld.com and https://bitmidi.com .


After you have found your song in a midi file, download it and give it a listen to make sure you picked the correct one. It will download like a regular mp3/mp4 track.


Step 2: Let's head to R! If you have not used R, don’t let this intimidate you. We are only going to use six simple lines of code. Yep, that’s it!

  • To start off, we need to install a package in R called tuneR”. This package is the secret sauce that is going to take our MIDI file and spit out the data behind it.

Our first two lines of R code will read:

This will install the package and load the library.

  • Next, we bring in the MIDI file from the file location and read it using the next two lines of code.

My MIDI file was stored on my local C drive in a folder named Firebird, you will replace that with your path and filename.


You’re almost done!!


Now your music has been converted into data. This includes the notes played, instruments, tempo, timing, etc.

But where is it??

  • To be able to export the information into a table and pull it into Tableau we are going to run the next two lines of code.


Note – including "row.names=FALSE" is very important. If you do not include this, then a row ID will be included and the field names will be offset by one column. I made this mistake early and it was very confusing and cost me a ton of time.


Here we are writing the results into two text files that will be stored in a location of your choice. In my case, I put them into the same folder I had the MIDI file in.


The results? Lets start with Text2: This file is going to contain most of the data you need.


Time: Start time Length: Length Track: Track Number Channel: Channel Number Note: Note Notename: Name of Note Velocity: Velocity of Note


Text1also has some great information but the key piece of data from this file is the Instrument Name. This could be extracted using the field "ParameterMetaSystem", which can be done in Tableau.


Left join Text1 to Text2 using "Track" from Text2 and the below calculated field for Text1.


Annnnd… that’s it!


You should have a text file in the location you chose above and you are simply able to import that into Tableau and Viz away!


If you have any questions please feel free to reach out to me on twitter @deevizable or LinkedIn




1,266 views

Recent Posts

See All

Comments


bottom of page