File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -27,16 +27,21 @@ func midiLoad(f string) []int {
27
27
return notes
28
28
}
29
29
30
+ // Transitions will store for a state (note identifier in midi) the
31
+ // number of transitions to each other note, as observed in the midi file
30
32
type Transitions map [int ]map [int ]uint32
33
+ // A Markov chain is represented as a hash map with assigns state i -> [probability]
34
+ // where the probability contains the state we can transition to as Key and an integer Value.
35
+ // The array of probabilities is ordered increasingly by Value, where each value
36
+ // represents an interval ]Value for prev state, Value] where the length of that
37
+ // interval is proportional to the probability of going from i to Key
31
38
type Markov map [int ][]probability
32
39
33
40
// Returns a Markov chain
34
41
func NewMarkov (f string ) Markov {
35
42
notes := midiLoad (f )
36
43
chain := make (Transitions )
37
44
38
- // Parse the transitions, i.e. store for a state (note identifier in midi)
39
- // the number of transitions to each other note, as observed in the midi file
40
45
previous := - 1
41
46
for _ , n := range notes {
42
47
if previous != - 1 {
You can’t perform that action at this time.
0 commit comments