Mercurial > hg > silvet
view yeti/silvet.yeti @ 16:d42c500b8ad0
Add non-convolutional version
author | Chris Cannam |
---|---|
date | Wed, 26 Mar 2014 08:33:45 +0000 |
parents | a91de434feb8 |
children | f1f8c84339d0 |
line wrap: on
line source
program silvet; { prepareTimeFrequency } = load timefreq; { loadTemplates, extractRanges } = load templates; em = load em; mat = load may.matrix; vec = load may.vector; plot = load may.plot; templates = loadTemplates (); ranges = extractRanges templates; eprintln "\nWe have \(length (keys templates)) instruments:"; for (sort (keys templates)) do k: eprintln " * \(k) \(mat.size templates[k]) range \(ranges[k].lowest) -> \(ranges[k].highest)"; done; eprintln ""; columns = prepareTimeFrequency "test.wav"; height = if empty? columns then 0 else vec.length (head columns) fi; chunkSize = { rows = height, columns = 100 }; emdata = em.initialise ranges templates 88 chunkSize; eprintln "initialised EM data: overall pitch range \(emdata.lowest) -> \(emdata.highest)"; chunkify cols = if empty? cols then [] else (mat.resizedTo chunkSize (mat.fromColumns (take chunkSize.columns cols))) :. \(chunkify (drop chunkSize.columns cols)); fi; chunks = chunkify columns; eprintln "we have \(length chunks) chunks of size \(mat.size (head chunks))"; eprintln "attempting one expectation phase..."; error = em.performExpectation emdata (head chunks); eprintln "done, result has dimension \(mat.size error)"; eprintln "attempting one maximisation phase..."; newP = em.performMaximisation emdata (head chunks) error; eprintln "done"; \() (plot.plot [ Grid (head chunks) ]); \() (plot.plot [ Grid error ]); \() (plot.plot [ Grid newP ]); ();