MIDI Generator: Build a Fractal Melody
A Fractal Melody Generator Tool For L-System Math
Three notes at the piano, in isolation, bum, bum, bum. The sounds hang in the air. They are complete in themselves. But they carry the seed of something in them, the beginning, the hush before dawn. At present, they stay small but have the potential to become mighty symphonies; like seeds, they are not destined to stay small. They remain an axiom (the starting set), the beginning point of a system. We showed this in our little seed music tool.
But, of course, in real life, complexity grows. Our little notes are the start of something big, scripted before they even begin. Their fate is determined by immutable rules. Each note is bounded by an inborn nature; we call it grammar in L-systems. Each note is not thought of as sequential, but as equally important at all times.
They hang, but not for long. The implicit rules fire, and all notes transform, as much as can be crammed in growth-wise. It is simple too: the same rules apply to all the notes at once, and they transform in identical ways. They wait for a trigger to bring them to life. This is where our fractal melody generator comes into play.
What Happens Next
In our tool, Ornament turns each note into four notes. It goes up one note and then back, a little flourish, baroque-like. That is the first step, but it does not stop there. Those notes become more notes, following the identical rules. Our Bach would run out of fingers, but this is generated music, and the notes form fractal-like iterations.
This explosion of notes comes in layers, or iterations, and the slider in our tool sets the value; we call this depth. At depth one the notes follow the rule once, at depth two twice, at depth three thrice. The complexity of notes increases exponentially, but the same rule is applied many times. Our tool only has room for three; after that there would be too many notes, and it would just be a muddy sound mess.
This is such a muddy mess that even at three iterations, it is a jumble. Notes are set by mathematics, and there is no ear in mathematics to ensure that beauty remains. The rules push notes in and out of scales, and even onto pitches that fall between the keys. Scale snap brings it all back to pleasant sound. After an iteration rule is applied, the tool reshapes it into scale values; the structure does not change, only the housing that holds them. Turn it on and off to see the effect.
The result is an at times beautiful composition. Download it as a MIDI file to your computer to work with it further.
L-SYSTEM COMPOSER
Write a short motif. Choose a grammar — a rewrite rule. Each iteration unfolds your idea recursively, the way a fern repeats its own shape at every scale.
The L-System Fractal Melody Generator
The MIDI fractal melody generator composer works differently from our other music players. Here, you bring your own idea, a note, a short phrase, whatever comes to mind, and hand it to the system to elaborate.
Start by clicking notes on the piano keyboard. Each note you click appears as a chip in the strip above the keyboard, showing its name and duration. Click a chip to remove it.
Choose your note duration before you click: eighth, quarter, dotted quarter, half, or whole. The REST button adds silence for the currently selected duration. Three to five notes make a good starting motif. Too many and the elaboration becomes unwieldy quickly.
Notes to Fractal
Once you have a motif, choose a grammar from the five cards. Each card shows a small diagram of what the rule does, a gold input note on the left and the green output notes on the right.
Ornament adds a quick decorative flourish and returns home. Sequence builds a rising run of three. Inversion mirrors the note above and below itself. Echo sends it back quieter. Branch forks three ways, like a tree dividing. The description on each card tells you the character of the rule in plain language.
Set the depth slider. Start at one and listen. Move to two and listen again. Three is where it gets dense; the original motif is still inside, fractal layers deep, but harder to hear. The scale snap dropdown pulls all the elaborated notes into a chosen musical key after the rule fires; turn it off to hear raw mathematics, turn it on for harmony.
Hit Play and watch the piano roll. The yellow line moves through the sequence as it plays, and the active note lights gold. When something strikes you as worth keeping, hit Export MIDI.