changeset 40:031386846e3c

Return bin frequencies, for reference; some padding
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 19 Nov 2013 14:37:23 +0000
parents c0514dd5be60
children ae7d2e558ed1
files yeti/cqt.yeti yeti/cqtkernel.yeti yeti/test.yeti
diffstat 3 files changed, 29 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/yeti/cqt.yeti	Mon Nov 18 17:11:47 2013 +0000
+++ b/yeti/cqt.yeti	Tue Nov 19 14:37:23 2013 +0000
@@ -23,6 +23,12 @@
 
     eprintln "atomsPerFrame = \(kdata.atomsPerFrame)";
 
+    padding = (kdata.fftSize / 2) * (pow 2 (octaves-1));
+
+eprintln "padding = \(padding)";
+
+    str = manipulate.paddedBy padding str;
+
     streams = manipulate.duplicated octaves str;
 
     //!!! can't be right!
@@ -131,7 +137,7 @@
             atomNo = int (col / colsPerAtom);
             atomOffset = col % colsPerAtom;
 
-            if /*!!! atomOffset == 0 and */ atomNo < length bits[oct] then
+            if atomOffset == 0 and atomNo < length bits[oct] then
                 bits[oct][atomNo][binNo];
             else
                 cplx.zero
@@ -173,9 +179,18 @@
          done cqblocks [1..octaves]);
 */
 eprintln "octaveLists keys are: \(keys octaveLists)";
-    
-    processOctaveLists octaveLists;
 
+    {
+        kernel = kdata with {
+            binFrequencies = array (concat
+               (map do octave:
+                    map do freq:
+                        freq / (pow 2 octave);
+                    done (reverse (list kdata.binFrequencies))
+                done [0..octaves-1]))
+        },
+        output = processOctaveLists octaveLists
+    }
     );
 
 { cqt }
--- a/yeti/cqtkernel.yeti	Mon Nov 18 17:11:47 2013 +0000
+++ b/yeti/cqtkernel.yeti	Tue Nov 19 14:37:23 2013 +0000
@@ -43,6 +43,8 @@
     // function. We can't do that here; we need to generate real and imag
     // parts separately as real = cos(2*pi*x), imag = sin(2*pi*x).
     
+    binFrequencies = array [];
+
     kernels = map do k:
     
         nk = round(bigQ * sampleRate / (minFreq * (pow 2 ((k-1)/binsPerOctave))));
@@ -56,6 +58,8 @@
 
         fk = minFreq * (pow 2 ((k-1)/binsPerOctave));
 
+        push binFrequencies fk;
+
         genKernel f = vec.multiply win
            (vec.fromList
                (map do i: f (2 * pi * fk * i / sampleRate) done [0..nk-1]));
@@ -112,8 +116,9 @@
         atomsPerFrame = winNr,
         atomSpacing = atomHop,
         firstCentre,
-        maxFreq,
-        minFreq,
+        maxFrequency = maxFreq,
+        minFrequency = minFreq,
+        binFrequencies,
         bigQ
     });
 
--- a/yeti/test.yeti	Mon Nov 18 17:11:47 2013 +0000
+++ b/yeti/test.yeti	Tue Nov 19 14:37:23 2013 +0000
@@ -24,12 +24,14 @@
 
 cq = cqt { maxFreq = testStream.sampleRate/2, minFreq = 1, binsPerOctave = 4 } testStream;
 
-for cq do c:
+eprintln "bin frequencies: \(cq.kernel.binFrequencies)";
+
+for cq.output do c:
     mm = cm.magnitudes c;
     for (mat.asColumns mm) (println . strJoin "," . vec.list);
 done;
 
-bigM = mat.concatHorizontal (map cm.magnitudes cq);
+bigM = mat.concatHorizontal (map cm.magnitudes cq.output);
 
 eprintln "overall output size = \(mat.size bigM)";