byte2note
Byte2note is a tiny Perl program that will convert any file
(binary or text) into a MIDI file in which each note represents a 3
bit tuple of the original file. The resulting MIDI file should
resemble music played on a standard 8 note diatonic scale.
Interestingly, the conversion is completely reversible in theory,
allowing the resulting melody to be converted back into the original
data. (the reverse conversion is left as an exercise for the bored
hacker.)
byte2note-1.0.tar.gz [9Kb]
Theory
Most data, while intended for use as 8 bit bytes, is stored as a
continous string of bits in one form or another:
01101010 11001010 01011110
To convert those bits into music, the first step is to break
the string of bits up into 3 bit tuples:
011 010 101 100 101 001 011 110
Each of the 3 bit tuples is then evaluated as a numerical value
from 0 to 7.
3 2 5 4 5 1 3 6
These values are then mapped onto a diatonic scale at a starting
point specified by the user.
F E A G A D F B
Finally the notes are output in the form of MIDI data and can
be sent to any standard MIDI device.
Examples
My first test of byte2note was on a short text
file containing a Backus Naur diagram of the Ring Tone Text
Transfer Language (RTTTL) used to encode cell phone ringtones. Susan
describes the resulting music as a deranged
Christmas carol.
But you're not limited to text files. This is a photograph of
Nimon, a leopard gecko that lives in our house. The photo was
scanned and is stored in JPEG format.
The resulting MIDI file is an urgent
piece reminiscent of Danny Elfman. Not only might this one
actually pass for real music but the real Nimon was quite
fascinated by the sound (or vibration?) of it.
And, of course, no experiment in data conversion can be called
complete until the infamous decss source
code has been tried. We'll call the result
decss.mid, an illegal circumvention device
in C Major, Opus 3. While it isn't too bad, I recommend consulting
a lawyer before listening to it.
Oh, and in case you were wondering, the background music on this
web page is this web page.
Future Development
As the examples reveal, the current output, while reasonably
music-like, tends to be a bit monotonous. If time allows more
hacking on this, I'd like to add a variety of features to make
the output more music like while still preserving the original
data in a recoverable way. Possible features include:
- Varied note durations
- Rests
- Rythm
- Melodies that span multiple octaves
- Polyphony (this one is unlikely as it seems to me it would
impair the ability to convert the music back to data from the
sound only
Links to other odd music generation software
- Automatous Monk - A Java program that maps cellular automaton evolution into jMusic scores that can be played and saved as MIDI files.
License: All software on this page is
Free Software
licensed under the
GNU GPL.
|