comparison yeti/silvet.yeti @ 21:8e61ec97b34e

I think this may be the right arrangement. Print out some results.
author Chris Cannam
date Fri, 28 Mar 2014 12:52:11 +0000
parents 982aa1197a7e
children 782b910394f3
comparison
equal deleted inserted replaced
20:982aa1197a7e 21:8e61ec97b34e
62 \() (plot.plot [ Grid newP ]); 62 \() (plot.plot [ Grid newP ]);
63 */ 63 */
64 64
65 em1data = em1.initialise ranges templates 88; 65 em1data = em1.initialise ranges templates 88;
66 66
67 col = head (drop 35 columns); 67 col = head (drop ((length columns) / 2) columns);
68 68
69 \() (plot.plot [ Caption "Source frequency distribution", Vector col ]); 69 \() (plot.plot [ Caption "Source frequency distribution", Vector col ]);
70 70
71 sourceGrid d = 71 sourceGrid d =
72 mat.fromColumns (map do k: d.sources[k] done (sort (keys d.sources))); 72 mat.fromColumns (map do k: d.sources[k] done (sort (keys d.sources)));
75 75
76 oneIteration em1data col n = 76 oneIteration em1data col n =
77 (q = em1.performExpectation em1data col; 77 (q = em1.performExpectation em1data col;
78 // \() (plot.plot [ Caption "Frequency distribution and output of E-step for iteration \(n)", Vector col, Vector q ]); 78 // \() (plot.plot [ Caption "Frequency distribution and output of E-step for iteration \(n)", Vector col, Vector q ]);
79 newdata = em1.performMaximisation em1data col q; 79 newdata = em1.performMaximisation em1data col q;
80 if (n % 2 == 0) then 80 if (n % 6 == 0) then
81 \() (plot.plot [ Caption "Pitch distribution before and after M-step update for iteration \(n)", Vector (em1data.pitches), Vector (newdata.pitches) ]); 81 \() (plot.plot [ Caption "Pitch distribution before and after M-step update for iteration \(n)", Vector (em1data.pitches), Vector (newdata.pitches) ]);
82 \() (plot.plot [ Caption "Source distribution after M-step update for iteration \(n)", Grid (sourceGrid newdata) ]); 82 \() (plot.plot [ Caption "Source distribution after M-step update for iteration \(n)", Grid (sourceGrid newdata) ]);
83 fi; 83 fi;
84 newdata); 84 newdata);
85 85
86 iterations = 6; 86 iterations = 12;
87 87
88 var d = em1data; 88 var d = em1data;
89 89
90 for [1..iterations] do i: 90 for [1..iterations] do i:
91 d := oneIteration d col i; 91 d := oneIteration d col i;
92 done; 92 done;
93 93
94 var sounding = [];
95
96 println "pitch distribution: \(d.pitches)";
97
98 for [d.lowest .. d.highest] do p:
99 if (vec.at d.pitches p) > 0.05 then
100 sounding := sounding ++ [p];
101 fi;
102 done;
103
104 println "Sounding: \(sounding)";
105
106 toNote p = (array ["A","A#","B","C","C#","D","D#","E","F","F#","G","G#"])[p % 12];
107
108 println "Notes: \(map toNote sounding)";
109
110 var instruments = [];
111 for sounding do p:
112 var best = "";
113 var bestp = 0;
114 for d.instruments do i:
115 if vec.at d.sources[i] p > bestp then
116 bestp := vec.at d.sources[i] p;
117 best := i;
118 fi;
119 done;
120 if bestp > 0 then
121 instruments := instruments ++ [best];
122 else
123 instruments := instruments ++ ["unknown"];
124 fi;
125 done;
126
127 println "Instruments: \(instruments)";
128
129
94 (); 130 ();
95 131
96 132