Right. The idea sounds complex enough to be fun toying with. Actually, this little experiment in front of you is an attempt to translate a simple midi-like notation of a melody into a mathematically definable function, defined in a continious world. Still don't have a slight idea what am I talking about?
Allright, a little introduction then.
A simple melody, like the catcy main riff of a well-known pop song may be usually represented in two different ways:
- the classiy way (using audio signals, storing them on different media). Basicly we have to record a live performance of the tune.
- the MIDI way, where we transmit event messages, such as the pitch and intensity of musical notes to play, control signals for parameters such as volume, vibrato and panning, cues, and clock signals to set the tempo. It is what early phones used for ringtones (polyphonic ringtones, remember?)
Even if it looks like ther is no other option, there actually is another one. Let's compare the melody representation techniques above with the image representation ones. The first one would equal a chemically produced photograph (the old, non-digital ones), taken by a clasic analog camera. The second would equal raster image, such are the ones made by taking a photo with a digital camera or by printing anything with a domestic printer.
'But wait a minute, thats not all!' you'll say. There are vector images, too. The ones represented with mathematical functions, bezier curves and other numerical ingredients. The ones you can zoom in and not loose a sharp edge.
Now we find out, we can do the same with music. Only, as you might have already guessed, it turns out to be completely unuseful, as transitions, from a certain tone to a higher or a lower one, aren't really continuous and would even sound really bad, if they were.
But, useful or not, why wouldn't we play with this idea and see, what comes out?
On to the workBasicly, what we want to do, is write a mathematical function, whitc accepts time as input and returns a tone of a certain pitch.
What we want to do firs, is assign numeric values to different tone pitches. We can do this easly this way:
| D | Eb | E | F | F# | G | G# | A | A# | H | C | C# |
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
...and the number 2,25 for example represents a tone somewhere between E and F.
Then what we need is a set of values we know we want to hear. Let's say we want one loop of the riff from Smoke on the Water to last 32 time units. Then these values would be:
{1,0},{3,3},{5,5},{8,0},{10,3},{12,6},{13,5},{17,0},{19,3},{21,5},{24,3},{26,0}
To construct a function, going through the points listed above, we can use polynomial interpolation (this is the simplest solution).
For those who never heard of this term before (majority, I persume :> ), a quick explanation from wikipedia:
To do this, we can use a computer program like Mathematica (or Matlab):
InterpolatingPolynomial[{{1,0},{3,3},{5,5},{8,0},{10,3},{12,6},{13,5},{17,0},{19,3},{21,5},{24,3},{26,0}},t]
results in
So, whenever you see a polynomial similar to the one above, you can now say: "Oooh, I know this one! It's the Smoke on the Water polynomial!" (sarcasm)
Let's see our masterpiece now:
Ok, about it being a masterpiece.. It confirms what we previously told - it is unuseful. :)
Let's (just for the fun) se, what Smoke on the Water sounds like, when we play our function for all the 32 time units:
Yeah, pritty useless.