comparison yeti/em_onecolumn.yeti @ 23:990b8b8b7e25

Hardcode the ranges
author Chris Cannam
date Fri, 28 Mar 2014 15:38:07 +0000
parents 782b910394f3
children 0e8ee830b5ee
comparison
equal deleted inserted replaced
22:782b910394f3 23:990b8b8b7e25
30 if inRange ranges instrument note then 1 else 0 fi 30 if inRange ranges instrument note then 1 else 0 fi
31 done [0..notes-1]) 31 done [0..notes-1])
32 done instruments), 32 done instruments),
33 instruments = array instruments, 33 instruments = array instruments,
34 instCount = length instruments, 34 instCount = length instruments,
35 noteCount = notes,
35 templates = array 36 templates = array
36 (map do iname: 37 (map do iname:
37 m = templates[iname]; 38 m = templates[iname];
38 mat.fromColumns (map normalise (mat.asColumns m)) 39 mat.fromColumns (map normalise (mat.asColumns m))
39 done instruments), 40 done instruments),
73 performMaximisation data column q = 74 performMaximisation data column q =
74 (column = normalise column; 75 (column = normalise column;
75 76
76 pitches = vec.fromList 77 pitches = vec.fromList
77 (map do note: 78 (map do note:
78 fold do acc inst: 79 if note >= data.lowest and note <= data.highest then
79 { w, p, s } = distributionsFor data inst note; 80 fold do acc inst:
80 fold do acc bin: 81 { w, p, s } = distributionsFor data inst note;
81 acc + s * p * (vec.at w bin) * (vec.at q bin); 82 fold do acc bin:
82 done acc [0..vec.length column - 1] 83 acc + s * p * (vec.at w bin) * (vec.at q bin);
83 done epsilon [0..data.instCount-1]; 84 done acc [0..vec.length column - 1]
84 done [data.lowest .. data.highest]); 85 done epsilon [0..data.instCount-1];
86 else epsilon
87 fi
88 done [0..data.noteCount-1]);
85 pitches = vec.divideBy (vec.sum pitches) pitches; 89 pitches = vec.divideBy (vec.sum pitches) pitches;
86 90
87 sources = mat.fromColumns 91 sources = mat.fromColumns
88 (map do inst: vec.fromList 92 (map do inst: vec.fromList
89 (map do note: 93 (map do note:
91 { w, p, s } = distributionsFor data inst note; 95 { w, p, s } = distributionsFor data inst note;
92 fold do acc bin: 96 fold do acc bin:
93 acc + s * p * (vec.at w bin) * (vec.at q bin); 97 acc + s * p * (vec.at w bin) * (vec.at q bin);
94 done epsilon [0..vec.length column - 1] 98 done epsilon [0..vec.length column - 1]
95 fi; 99 fi;
96 done [data.lowest .. data.highest]) 100 done [0..data.noteCount-1])
97 done [0..data.instCount-1]); 101 done [0..data.instCount-1]);
98 102
99 sourceDenoms = fold do acc inst: 103 sourceDenoms = fold do acc inst:
100 vec.add [acc, (mat.getColumn inst sources)] 104 vec.add [acc, (mat.getColumn inst sources)]
101 done (vec.zeros (data.highest - data.lowest + 1)) [0..data.instCount-1]; 105 done (vec.zeros data.noteCount) [0..data.instCount-1];
102 106
103 sources = mat.fromColumns 107 sources = mat.fromColumns
104 (map do inst: 108 (map do inst:
105 vec.divide (mat.getColumn inst sources) sourceDenoms; 109 vec.divide (mat.getColumn inst sources) sourceDenoms;
106 done [0..data.instCount-1]); 110 done [0..data.instCount-1]);