Skip to content

Commit 6e12f81

Browse files
committed
Comments for generation of Markov chains file
Signed-off-by: ncordon <nacho.cordon.castillo@gmail.com>
1 parent f098906 commit 6e12f81

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/sound/markov.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,21 @@ func midiLoad(f string) []int {
2727
return notes
2828
}
2929

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
3032
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
3138
type Markov map[int][]probability
3239

3340
// Returns a Markov chain
3441
func NewMarkov(f string) Markov {
3542
notes := midiLoad(f)
3643
chain := make(Transitions)
3744

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
4045
previous := -1
4146
for _, n := range notes {
4247
if previous != -1 {

0 commit comments

Comments
 (0)