# HG changeset patch # User Chris Cannam # Date 1396021087 0 # Node ID 990b8b8b7e25975bc3c18fcf8fd59eebde12195c # Parent 782b910394f307a8aeaf1e8f494dd83eec08711e Hardcode the ranges diff -r 782b910394f3 -r 990b8b8b7e25 yeti/em_onecolumn.yeti --- a/yeti/em_onecolumn.yeti Fri Mar 28 14:00:40 2014 +0000 +++ b/yeti/em_onecolumn.yeti Fri Mar 28 15:38:07 2014 +0000 @@ -32,6 +32,7 @@ done instruments), instruments = array instruments, instCount = length instruments, + noteCount = notes, templates = array (map do iname: m = templates[iname]; @@ -75,13 +76,16 @@ pitches = vec.fromList (map do note: - fold do acc inst: - { w, p, s } = distributionsFor data inst note; - fold do acc bin: - acc + s * p * (vec.at w bin) * (vec.at q bin); - done acc [0..vec.length column - 1] - done epsilon [0..data.instCount-1]; - done [data.lowest .. data.highest]); + if note >= data.lowest and note <= data.highest then + fold do acc inst: + { w, p, s } = distributionsFor data inst note; + fold do acc bin: + acc + s * p * (vec.at w bin) * (vec.at q bin); + done acc [0..vec.length column - 1] + done epsilon [0..data.instCount-1]; + else epsilon + fi + done [0..data.noteCount-1]); pitches = vec.divideBy (vec.sum pitches) pitches; sources = mat.fromColumns @@ -93,12 +97,12 @@ acc + s * p * (vec.at w bin) * (vec.at q bin); done epsilon [0..vec.length column - 1] fi; - done [data.lowest .. data.highest]) + done [0..data.noteCount-1]) done [0..data.instCount-1]); sourceDenoms = fold do acc inst: vec.add [acc, (mat.getColumn inst sources)] - done (vec.zeros (data.highest - data.lowest + 1)) [0..data.instCount-1]; + done (vec.zeros data.noteCount) [0..data.instCount-1]; sources = mat.fromColumns (map do inst: diff -r 782b910394f3 -r 990b8b8b7e25 yeti/silvet.yeti --- a/yeti/silvet.yeti Fri Mar 28 14:00:40 2014 +0000 +++ b/yeti/silvet.yeti Fri Mar 28 15:38:07 2014 +0000 @@ -64,7 +64,7 @@ em1data = em1.initialise ranges templates 88; -col = head (drop ((length columns) / 2) columns); +col = head (drop 50 columns); // (drop ((length columns) / 2) columns); \() (plot.plot [ Caption "Source frequency distribution", Vector col ]); diff -r 782b910394f3 -r 990b8b8b7e25 yeti/templates.yeti --- a/yeti/templates.yeti Fri Mar 28 14:00:40 2014 +0000 +++ b/yeti/templates.yeti Fri Mar 28 15:38:07 2014 +0000 @@ -30,8 +30,21 @@ done; done instruments; +hardcodedRanges = [ + "bassoon": { lowest = 15, highest = 51 }, + "cello": { lowest = 15, highest = 60 }, + "clarinet": { lowest = 29, highest = 68 }, + "flute": { lowest = 39, highest = 72 }, + "guitar": { lowest = 19, highest = 55 }, + "horn": { lowest = 20, highest = 56 }, + "oboe": { lowest = 37, highest = 70 }, + "tenorsax": { lowest = 23, highest = 54 }, + "violin": { lowest = 34, highest = 72 }, + "piano-maps-SptkBGCl": { lowest = 16, highest = 72 }, +]; + //!!! these ranges are hardcoded, in the original (and are a bit more restrictive) -extractRanges templates = mapIntoHash id +extractRanges' templates = mapIntoHash id do instrument: levels = map vec.sum (mat.asColumns (templates[instrument])); first = length levels - length (find (>0) levels); @@ -39,6 +52,8 @@ { lowest = first, highest = last } done (keys templates); +extractRanges templates = hardcodedRanges; + { loadTemplates, extractRanges