Markov Made Music
Starting with an image but failed…
I started by implementing a Markov chain for image generation but I got some bug when generating an image. My finding is that updating each pixel took too much time and my program just froze. I saw other people did it in python which I thought could be faster than Javascript since it has a lot of libraries support pixels manipulation.
Markov on Music Notation
Then I switched to exploring generate music using the Markov chain. There is a way to note music using just numbers which are called Numbered System. It was invented by a French musician and popularized in China. I remember every song I learn from school is using this notation.
Note: C D E F G A B
Solfège: do ré mi fa sol la si
Notation: 1 2 3 4 5 6 7Whole note: 1 - - -
Half note: 1 -
Quarter note: 1 Dotted quarter: 1·
Eighth note: 1 Dotted eighth: 1·
Sixteenth note:1 Dotted sixteenth:1.
It used bar || or | to mark the end of each small section.
4/4 > >
Clap: | X X X X X | X X X X 0 X X ||
I wrote down the twinkle twinkle in this form and used Markov to generated new music.
|1 1 5 5 | 6 6 5 - | 4 4 3 2 | 2 2 1 - | 5 5 4 4 | 3 3 2 - | 5 5 4 4 | 3 3 2 - | 1 1 5 5 | 6 6 5 -| 4 4 3 3| 2 2 1 - |1 1 5 5 | 6 6 5 - | 4 4 3 2 | 2 2 1 - | 5 5 4 4 | 3 3 2 - | 5 5 4 4 | 3 3 2 - | 1 1 5 5 | 6 6 5 -| 4 4 3 3| 2 2 1 - ||
In return I had something below:
|1 1 5 5 | 6 6 5 - | 5 5 4 4 3 2 | 2 2 1 - | 5 5 4 4 3 3 2 - | 5 5 4 4 3 2 - | 4 4 3 3 2 | 2 2 1 - | 4 4 3 2 - |1 1 5 5 4 4 3 2 | 2 2 1 - | 5 5 4 4 3 3| 2 2 1 - | 5 5 4 4 3 3 2 - | 5 5 4 4 3 3 2 - | 5 5 | 6 6 5 - | 4 4 3 2 - | 1 1 5 5 | 6 6 5 -| 4 4 3 2 - ||
I played it using my limited piano skills and I can hear there are some bars from twinkle twinkle.