Music Feature
Music is compose by lots of note.
The feature of note is frequece and length.
Markov Chain
The idea tech of Markov Chain is that, the next state (to us,it’s music note) is decided by the previous N states, only.
That means:
the next note’s freq is decided by the previous’s.
the next note’s length is decided by the previous’s.
Machine Learning
First, learn the trans probability throught lots of music sample.
Then, we got the probability from Freq A to Freq B, From length 1/2 to 1/4
Last, generate note by probability, random. Create music file according to the note data.
Code
The lib “pysynth.py” for gen music through two arg (freq and length)
The key program “MarkovBuilder.py” for TransArray&GenerateNote
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
Main Program “MarkovMusic.py”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
code src:
http://github.com/jcbozonier/MarkovMusic/tree/master
Strategy 1
If Target is the food, choose the shortest path
Strategy 2
If Target is the tail, choose the longest path
code src:
https://github.com/Hawstein/snake-ai