Mercurial > hg > silvet
changeset 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 |
files | yeti/em_onecolumn.yeti yeti/silvet.yeti |
diffstat | 2 files changed, 41 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/yeti/em_onecolumn.yeti Thu Mar 27 11:52:07 2014 +0000 +++ b/yeti/em_onecolumn.yeti Fri Mar 28 12:52:11 2014 +0000 @@ -60,7 +60,7 @@ fold do acc instrument: { w, p, s } = distributionsFor data instrument note; fold do acc bin: - acc + s * (vec.at w bin) * (vec.at q bin); + acc + s * p * (vec.at w bin) * (vec.at q bin); done acc [0..vec.length column - 1] done epsilon data.instruments; done [data.lowest .. data.highest]); @@ -72,7 +72,7 @@ if not inRange data.ranges instrument note then epsilon else { w, p, s } = distributionsFor data instrument note; fold do acc bin: - acc + (vec.at w bin) * (vec.at q bin); + acc + s * p * (vec.at w bin) * (vec.at q bin); done epsilon [0..vec.length column - 1] fi; done [data.lowest .. data.highest]) @@ -81,10 +81,6 @@ sourceDenoms = fold do acc instrument: vec.add [acc, sources[instrument]] done (vec.zeros (data.highest - data.lowest + 1)) data.instruments; - - \() (plot.plot [ Caption "Source numerators for piano", Vector (sources["piano-maps-SptkBGCl"]) ]); - - \() (plot.plot [ Caption "Source denominators", Vector sourceDenoms ]); sources = mapIntoHash id do instrument:
--- a/yeti/silvet.yeti Thu Mar 27 11:52:07 2014 +0000 +++ b/yeti/silvet.yeti Fri Mar 28 12:52:11 2014 +0000 @@ -64,7 +64,7 @@ em1data = em1.initialise ranges templates 88; -col = head (drop 35 columns); +col = head (drop ((length columns) / 2) columns); \() (plot.plot [ Caption "Source frequency distribution", Vector col ]); @@ -77,13 +77,13 @@ (q = em1.performExpectation em1data col; // \() (plot.plot [ Caption "Frequency distribution and output of E-step for iteration \(n)", Vector col, Vector q ]); newdata = em1.performMaximisation em1data col q; - if (n % 2 == 0) then + if (n % 6 == 0) then \() (plot.plot [ Caption "Pitch distribution before and after M-step update for iteration \(n)", Vector (em1data.pitches), Vector (newdata.pitches) ]); \() (plot.plot [ Caption "Source distribution after M-step update for iteration \(n)", Grid (sourceGrid newdata) ]); fi; newdata); -iterations = 6; +iterations = 12; var d = em1data; @@ -91,6 +91,42 @@ d := oneIteration d col i; done; +var sounding = []; + +println "pitch distribution: \(d.pitches)"; + +for [d.lowest .. d.highest] do p: + if (vec.at d.pitches p) > 0.05 then + sounding := sounding ++ [p]; + fi; +done; + +println "Sounding: \(sounding)"; + +toNote p = (array ["A","A#","B","C","C#","D","D#","E","F","F#","G","G#"])[p % 12]; + +println "Notes: \(map toNote sounding)"; + +var instruments = []; +for sounding do p: + var best = ""; + var bestp = 0; + for d.instruments do i: + if vec.at d.sources[i] p > bestp then + bestp := vec.at d.sources[i] p; + best := i; + fi; + done; + if bestp > 0 then + instruments := instruments ++ [best]; + else + instruments := instruments ++ ["unknown"]; + fi; +done; + +println "Instruments: \(instruments)"; + + ();