diff dsp/chromagram/Chromagram.cpp @ 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
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++)