Mercurial > hg > silvet
view yeti/templates.yeti @ 88:97b77e7cb94c timing
Store templates as doubles instead of floats
author | Chris Cannam |
---|---|
date | Tue, 06 May 2014 12:49:49 +0100 |
parents | 990b8b8b7e25 |
children |
line wrap: on
line source
module templates; vec = load may.vector; mat = load may.matrix; // Load instrument templates instruments = [ "bassoon", "cello", "clarinet", "flute", "guitar", "horn", "oboe", "tenorsax", "violin", "piano-maps-SptkBGCl" ]; loadTemplates () = mapIntoHash id do instrument: readFile "../data/\(instrument).csv" "UTF-8" do istr: mat.fromColumns (map do line: vec.fromList (map number (strSplit "," line)) done (istr.lines ())); 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 do instrument: levels = map vec.sum (mat.asColumns (templates[instrument])); first = length levels - length (find (>0) levels); last = length (find (>0) (reverse levels)) - 1; { lowest = first, highest = last } done (keys templates); extractRanges templates = hardcodedRanges; { loadTemplates, extractRanges }