diff dsp/chromagram/Chromagram.cpp @ 468:a72d98f8baa3

Revise mechanism for extending chromagram to round number of octaves - do it only in the chromagram itself, so that we can still create deviant constant-Q spectrograms if desired
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 30 May 2019 11:35:35 +0100
parents 1db23b9a8da4
children fdaa63607c15
line wrap: on
line diff
--- a/dsp/chromagram/Chromagram.cpp	Wed May 29 15:56:30 2019 +0100
+++ b/dsp/chromagram/Chromagram.cpp	Thu May 30 11:35:35 2019 +0100
@@ -33,8 +33,9 @@
     m_BPO  = Config.BPO;		// bins per octave
     m_normalise = Config.normalise;     // if frame normalisation is required
 
-    // No. of constant Q bins, extended to a full octave
-    m_uK = m_BPO * int(ceil(log(m_FMax/m_FMin)/log(2.0)));
+    // Extend range to a full octave
+    double octaves = log(m_FMax / m_FMin) / log(2.0);
+    m_FMax = m_FMin * pow(2.0, ceil(octaves));
 
     // Create array for chroma result
     m_chromadata = new double[ m_BPO ];
@@ -53,6 +54,9 @@
     // Initialise ConstantQ operator
     m_ConstantQ = new ConstantQ( ConstantQConfig );
 
+    // No. of constant Q bins
+    m_uK = m_ConstantQ->getK();
+
     // Initialise working arrays
     m_frameSize = m_ConstantQ->getfftlength();
     m_hopSize = m_ConstantQ->gethop();