Mercurial > hg > silvet
comparison yeti/em_onecolumn.yeti @ 24:0e8ee830b5ee
Normalise source distributions row-wise (per note)
author | Chris Cannam |
---|---|
date | Mon, 31 Mar 2014 12:46:24 +0100 |
parents | 990b8b8b7e25 |
children | 80f02ff5d37a |
comparison
equal
deleted
inserted
replaced
23:990b8b8b7e25 | 24:0e8ee830b5ee |
---|---|
20 (instruments = sort (keys ranges); | 20 (instruments = sort (keys ranges); |
21 { | 21 { |
22 pitches = // z in the original. 1 per note | 22 pitches = // z in the original. 1 per note |
23 normalise (vec.randoms notes), | 23 normalise (vec.randoms notes), |
24 sources = // u in the original. 1 per note-instrument | 24 sources = // u in the original. 1 per note-instrument |
25 //!!! should this be normalised across instruments? i.e. row-wise | 25 mat.fromRows |
26 mat.fromColumns | 26 (map do note: |
27 (map do instrument: | 27 normalise |
28 vec.fromList | 28 (vec.fromList |
29 (map do note: | 29 (map do instrument: |
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 instruments)) |
32 done instruments), | 32 done [0..notes-1]), |
33 instruments = array instruments, | 33 instruments = array instruments, |
34 instCount = length instruments, | 34 instCount = length instruments, |
35 noteCount = notes, | 35 noteCount = notes, |
36 templates = array | 36 templates = array |
37 (map do iname: | 37 (map do iname: |
86 else epsilon | 86 else epsilon |
87 fi | 87 fi |
88 done [0..data.noteCount-1]); | 88 done [0..data.noteCount-1]); |
89 pitches = vec.divideBy (vec.sum pitches) pitches; | 89 pitches = vec.divideBy (vec.sum pitches) pitches; |
90 | 90 |
91 sources = mat.fromColumns | 91 sources = mat.fromRows |
92 (map do inst: vec.fromList | 92 (map do note: vec.fromList |
93 (map do note: | 93 (map do inst: |
94 if not inRange data.ranges inst note then epsilon else | 94 if not inRange data.ranges inst note then epsilon else |
95 { w, p, s } = distributionsFor data inst note; | 95 { w, p, s } = distributionsFor data inst note; |
96 fold do acc bin: | 96 fold do acc bin: |
97 acc + s * p * (vec.at w bin) * (vec.at q bin); | 97 acc + s * p * (vec.at w bin) * (vec.at q bin); |
98 done epsilon [0..vec.length column - 1] | 98 done epsilon [0..vec.length column - 1] |
99 fi; | 99 fi; |
100 done [0..data.noteCount-1]) | 100 done [0..data.instCount-1]) |
101 done [0..data.instCount-1]); | 101 done [0..data.noteCount-1]); |
102 | 102 |
103 sourceDenoms = fold do acc inst: | 103 sourceDenoms = fold do acc inst: |
104 vec.add [acc, (mat.getColumn inst sources)] | 104 vec.add [acc, (mat.getColumn inst sources)] |
105 done (vec.zeros data.noteCount) [0..data.instCount-1]; | 105 done (vec.zeros data.noteCount) [0..data.instCount-1]; |
106 | 106 |
107 sources = mat.fromColumns | 107 //!!! shouldn't this normalisation be the other way? (rows, not columns) |
108 /* sources = mat.fromColumns | |
108 (map do inst: | 109 (map do inst: |
109 vec.divide (mat.getColumn inst sources) sourceDenoms; | 110 vec.divide (mat.getColumn inst sources) sourceDenoms; |
110 done [0..data.instCount-1]); | 111 done [0..data.instCount-1]); |
111 | 112 */ |
113 sources = mat.fromRows | |
114 (map do note: | |
115 vec.divide (mat.getRow note sources) sourceDenoms; | |
116 done [0..data.noteCount-1]); | |
117 | |
112 data with { | 118 data with { |
113 pitches, | 119 pitches, |
114 sources, | 120 sources, |
115 }); | 121 }); |
116 | 122 |