Mercurial > hg > constant-q-cpp
changeset 21:5787785f4560
Restore reshape into atom columns; drop atoms for alignment (not working, we may be compensating in the wrong direction)
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Wed, 30 Oct 2013 18:26:04 +0000 |
parents | dad5d8a06a5d |
children | 701900c371b0 |
files | yeti/cqt.yeti |
diffstat | 1 files changed, 35 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/yeti/cqt.yeti Wed Oct 30 17:29:14 2013 +0000 +++ b/yeti/cqt.yeti Wed Oct 30 18:26:04 2013 +0000 @@ -88,21 +88,30 @@ // relative to those from the highest octave. // Reshape each row vector into the appropriate rectangular matrix -/* - cqblocks = array (map do octlist: - map do rv: - cm.generate do row col: - cm.at rv ((row * kdata.atomsPerFrame) + col) 0 - done { - rows = kdata.binsPerOctave, - columns = kdata.atomsPerFrame - } - done octlist - done cqblocks); -*/ + // and split into single-atom columns -//!!! how then do we arrange to drop a certain number of atoms (rather -//than of atoms+bins chunks)? + emptyHops = kdata.firstCentre / kdata.atomSpacing; + maxDrop = emptyHops * (pow 2 (octaves-1)) - emptyHops; + eprintln "maxDrop = \(maxDrop)"; + + cqblocks = map do octlist: + concat + (map do rv: + cm.asColumns + (cm.generate do row col: + cm.at rv ((row * kdata.atomsPerFrame) + col) 0 + done { + rows = kdata.binsPerOctave, + columns = kdata.atomsPerFrame + }) + done octlist) + done cqblocks; + + cqblocks = array (map2 do octlist octave: + d = emptyHops * (pow 2 (octaves-octave)) - emptyHops; + eprintln "dropping \(d)"; + drop d octlist; + done cqblocks [1..octaves]); assembleBlock bits = (eprintln "assembleBlock: structure of bits is:"; @@ -123,20 +132,16 @@ // row is disposed with 0 at the top, highest octave (in // both pitch and index into bits structure) -// oct = octaves - int (row / binsPerOctave) - 1; oct = int (row / binsPerOctave); binNo = row % kdata.binsPerOctave; + chunks = pow 2 oct; - colsPerChunk = int (columns / chunks); - colsPerAtom = int (colsPerChunk / kdata.atomsPerFrame); - chunkNo = int (col / colsPerChunk); - atomNo = int ((col % colsPerChunk) / colsPerAtom); - atomOffset = ((col % colsPerChunk) % colsPerAtom); + colsPerAtom = int (columns / (chunks * kdata.atomsPerFrame)); + atomNo = int (col / colsPerAtom); + atomOffset = col % colsPerAtom; -// eprintln "row \(row) of \(rows), col \(col) of \(columns): oct \(oct), bin \(binNo), chunk \(chunkNo) of \(chunks), atom \(atomNo) of \(kdata.atomsPerFrame)"; - - if atomOffset == 0 then - cm.at bits[oct][chunkNo] (binNo * kdata.atomsPerFrame + atomNo) 0; + if atomOffset == 0 and atomNo < length bits[oct] then + bits[oct][atomNo][binNo]; else cplx.zero fi; @@ -149,7 +154,7 @@ block::rest: (toAssemble = array (map do oct: - n = pow 2 oct; + n = kdata.atomsPerFrame * pow 2 oct; if not empty? octs[oct] then forBlock = array (take n octs[oct]); octs[oct] := drop n octs[oct]; @@ -184,20 +189,14 @@ //testStream = manipulate.withDuration 96000 (syn.sinusoid 48000 500); //testStream = manipulate.withDuration 96000 (syn.pulseTrain 48000 4); -testStream = af.open "sweep.wav"; +testStream = af.open "sweep-48000.wav"; eprintln "have test stream"; -c = cqt testStream; - -//m = take 1 (drop 2 c); - -//thing = take 50 (drop 200 c); - -//m = cm.newComplexMatrix (ColumnMajor ()) thing; -mm = cm.magnitudes (head c); - -for (mat.asColumns mm) (println . strJoin "," . vec.list); +for (cqt testStream) do c: + mm = cm.magnitudes c; + for (mat.asColumns mm) (println . strJoin "," . vec.list); +done; ()