changeset 466:46375e6d1b54

Apply fix from daschuer/mixxx:b9c6bde3 Extend the number of Q bins always to a full octave
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 29 May 2019 14:08:43 +0100
parents 50a97c8d52ed
children 1db23b9a8da4
files dsp/chromagram/Chromagram.cpp dsp/chromagram/ConstantQ.cpp
diffstat 2 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/dsp/chromagram/Chromagram.cpp	Wed May 29 13:55:26 2019 +0100
+++ b/dsp/chromagram/Chromagram.cpp	Wed May 29 14:08:43 2019 +0100
@@ -33,8 +33,8 @@
     m_BPO  = Config.BPO;		// bins per octave
     m_normalise = Config.normalise;     // if frame normalisation is required
 
-    // No. of constant Q bins
-    m_uK = (int) ceil( m_BPO * log(m_FMax/m_FMin)/log(2.0));	
+    // No. of constant Q bins, extended to a full octave
+    m_uK = m_BPO * int(ceil(log(m_FMax/m_FMin)/log(2.0)));
 
     // Create array for chroma result
     m_chromadata = new double[ m_BPO ];
@@ -159,8 +159,8 @@
     m_ConstantQ->process( real, imag, m_CQRe, m_CQIm );
 	
     // add each octave of cq data into Chromagram
-    const int octaves = (int)floor(double( m_uK/m_BPO))-1;
-    for (int octave = 0; octave <= octaves; octave++) 
+    const int octaves = m_uK / m_BPO;
+    for (int octave = 0; octave < octaves; octave++) 
     {
 	int firstBin = octave*m_BPO;
 	for (int i = 0; i < m_BPO; i++) 
--- a/dsp/chromagram/ConstantQ.cpp	Wed May 29 13:55:26 2019 +0100
+++ b/dsp/chromagram/ConstantQ.cpp	Wed May 29 14:08:43 2019 +0100
@@ -293,7 +293,7 @@
     m_CQThresh = Config.CQThresh;// ConstantQ threshold for kernel generation
 
     m_dQ = 1/(pow(2,(1/(double)m_BPO))-1);	// Work out Q value for Filter bank
-    m_uK = (unsigned int) ceil(m_BPO * log(m_FMax/m_FMin)/log(2.0));	// No. of constant Q bins
+    m_uK = m_BPO * int(ceil(log(m_FMax/m_FMin)/log(2.0)));	// No. of constant Q bins, extended to a full octave
 
 //    std::cerr << "ConstantQ::initialise: rate = " << m_FS << ", fmin = " << m_FMin << ", fmax = " << m_FMax << ", bpo = " << m_BPO << ", K = " << m_uK << ", Q = " << m_dQ << std::endl;