Mercurial > hg > silvet
view yeti/templates.yeti @ 22:782b910394f3
Instruments by number rather than by name
author | Chris Cannam |
---|---|
date | Fri, 28 Mar 2014 14:00:40 +0000 |
parents | a91de434feb8 |
children | 990b8b8b7e25 |
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; //!!! 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); { loadTemplates, extractRanges }