Gecko to music conversion using 3 bit tuples

I was driving home from work recently after a particularly stressful day when some random synapses fired in my brain (or perhaps just burned out from stress) and an idea formed.

Standard diatonic musical scales have eight notes, a power of 2 that can be represented by a 3 bits. We’re used to thinking of our data primarily in terms of 8 bit bytes. But any file on your computer is just a stream of bits and could be processed in 3 bit chunks rather than 8 bit chunks. So, I thought, that means every file on my hard disk is potentially a piece of music.

I was up late playing with the Perl pack and unpack functions and eventually cranked out a simple byte to note converter that will take any arbitrary file as input and produces MIDI note data as output. After re-attaching a somewhat disused Yamaha keyboard to my Linux box, I picked a file to test the program with. I started small with a 1478 byte plain text file that contained a Backus Naur diagram of the Ring Tone Text Transfer Language. The result, while a bit odd, could be described as music of sorts. With seeming success at hand, I looked for more interesting data.

Next, I took a 24Kb JPEG photo of Nimon, one of our Geckos, and converted it. The resulting music had a Danny Elfman-like urgency to it and was a bit of an improvement over the RTTTL composition. However, the MIDI file was 500Kb and creating it consumed nearly all available memory on my box. It was at this point that I realized the MIDI::Simple module that I’d grabbed from CPAN wasn’t really designed for stream use or for large volumes of data. For some reason it wants to hold the entire collection of notes in memory before writing the output.

More interesting though, was that the real Nimon seemed to take an interest in the music created from her image. She came out from under the hollow log she usually sleeps under and stood on top of it holding her head up in the air as if listening. Who knows what a Gecko hears – maybe she was just feeling the vibrations from the sounds and thought an insect was around that needed eating.

No data is lost in the conversion and it should be trivial to convert the MIDI file back into the the original data. In fact, since the music uses only one timbre and is not polyphonic, it shouldn’t be too hard to convert from the music itself back to the original data. It’s not an efficient data transfer medium, however. Music usually plays at around 96 or so beats per minute, each beat is just 3 bits of the original data. So a 24Kb JPEG becomes an 11 hour musical work!

Despite the inefficiency of music as a data storage or transfer mechanism, tradition says that when a new way of encoding data is found, one has to encode the decss.c file. I present decss.mid, an illegal circumvention device in C Major, Opus 3.

Leave a Reply

Your email address will not be published. Required fields are marked *