Skip to content

Turning sea levels into music with CSV to MIDI


Data sonification describes the process by which data is translated into sound. There’s a variety of reasons this might be worthwhile, from purely artistic or aesthetic purposes to its potential as an assistive technology for the visually impaired. I like to think of it as synesthesia: it allows us to experience information in a different modality than it was originally expressed.

There’s no one-size-fits-all way to design a data sonification algorithm—it’s highly dependent on the structure of the data you’re working with and the type of sound you’re trying to create. Since comma-separated values (CSV) are a common way of storing numerical datasets and MIDI is the standard for representing melodic information, it struck me that a tool that could convert between the two formats would come in handy as a generative composition tool. So back in 2018, I made one.

csv-to-midi is what I ended up building. Originally built with Vue, it allows users to load a CSV dataset, select which columns determine the note, velocity, and timing, and generate a MIDI file in the desired key. Each note in the MIDI corresponds with a row in the input CSV file. The underlying algorithm is pretty simple: it uses the min and max values in the note column to rescale each element to an integer value. This value is then used as an index into an ordered array containing all the valid MIDI notes for the user’s chosen octave, range, key, and scale. The calculation for velocity is even simpler—it rescales the values in the velocity column from the range [min, max] to [1, 100], which is the range of valid velocity values for MIDI notes.

I had an opportunitiy in 2018 to put the tool to use for an art project called Bait/Switch modeled on exquisite corpse, where a sequence of artists contribute works in response to one another. The piece I responded to had a nautical feel, so I decided to use several decades of sea level data from the University of Hawaii Sea Level Center to generate a musical sequence to use in an ambient composition. You can listen to it (and read a bit more exposition) here. The source for csv-to-midi is also available on GitHub.