changeset 478:c92718cc6ef1

Untabify, indent, tidy
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 30 May 2019 18:40:16 +0100
parents fa407c1d9923
children 7e52c034cf62
files dsp/keydetection/GetKeyMode.cpp dsp/keydetection/GetKeyMode.h
diffstat 2 files changed, 54 insertions(+), 104 deletions(-) [+]
line wrap: on
line diff
--- a/dsp/keydetection/GetKeyMode.cpp	Thu May 30 18:36:48 2019 +0100
+++ b/dsp/keydetection/GetKeyMode.cpp	Thu May 30 18:40:16 2019 +0100
@@ -155,8 +155,8 @@
     double sum1 = 0;
     double sum2 = 0;
     
-    for( unsigned int i = 0; i <length; i++ )
-    {
+    for( unsigned int i = 0; i <length; i++ ) {
+
         int k = (i - shiftProfile + length) % length;
 
         num += pDataNorm[i] * pProfileNorm[k];
@@ -164,7 +164,7 @@
         sum1 += ( pDataNorm[i] * pDataNorm[i] );
         sum2 += ( pProfileNorm[k] * pProfileNorm[k] );
     }
-	
+        
     den = sqrt(sum1 * sum2);
 
     if( den>0 ) {
@@ -181,19 +181,10 @@
     int key;
     unsigned int j,k;
 
-    //////////////////////////////////////////////
     m_Decimator->process( PCMData, m_DecimatedBuffer);
 
     m_ChrPointer = m_Chroma->process( m_DecimatedBuffer );
 
-/*
-    std::cout << "raw chroma: ";
-    for (int ii = 0; ii < kBinsPerOctave; ++ii) {
-      if (ii % (kBinsPerOctave/12) == 0) std::cout << "\n";
-        std::cout << m_ChrPointer[ii] << " ";
-    }
-    std::cout << std::endl;
-*/
     // populate hpcp values;
     int cbidx;
     for( j = 0; j < kBinsPerOctave; j++ ) {
@@ -223,15 +214,12 @@
 
     // Normalize for zero average
     double mHPCP = MathUtilities::mean( m_MeanHPCP, kBinsPerOctave );
-    for( k = 0; k < kBinsPerOctave; k++ )
-    {
+    for( k = 0; k < kBinsPerOctave; k++ ) {
         m_MeanHPCP[k] -= mHPCP;
     }
 
-
-    for( k = 0; k < kBinsPerOctave; k++ )
-    {
-        // The Cromagram has the center of C at bin 0, while the major
+    for( k = 0; k < kBinsPerOctave; k++ ) {
+        // The Chromagram has the center of C at bin 0, while the major
         // and minor profiles have the center of C at 1. We want to have
         // the correlation for C result also at 1.
         // To achieve this we have to shift two times:
@@ -239,19 +227,6 @@
         m_MinCorr[k] = krumCorr( m_MeanHPCP, m_MinProfileNorm, (int)k - 2, kBinsPerOctave );
     }
 
-/*
-  std::cout << "raw keys: ";
-  for (int ii = 0; ii < kBinsPerOctave; ++ii) {
-      if (ii % (kBinsPerOctave/12) == 0) std::cout << "\n";
-      std::cout << m_MajCorr[ii] << " ";
-  }
-  for (int ii = 0; ii < kBinsPerOctave; ++ii) {
-      if (ii % (kBinsPerOctave/12) == 0) std::cout << "\n";
-      std::cout << m_MinCorr[ii] << " ";
-  }
-  std::cout << std::endl;
-*/
-
     // m_MajCorr[1] is C center  1 / 3 + 1 = 1
     // m_MajCorr[4] is D center  4 / 3 + 1 = 2
     // '+ 1' because we number keys 1-24, not 0-23.
@@ -262,10 +237,6 @@
     int maxBin = (maxMaj > maxMin) ? maxMajBin : (maxMinBin + kBinsPerOctave);
     key = maxBin / 3 + 1;
 
-//    std::cout << "fractional key pre-sorting: " << (maxBin + 2) / 3.0 << std::endl;
-//    std::cout << "key pre-sorting: " << key << std::endl;
-
-
     //Median filtering
 
     // track Median buffer initial filling
@@ -291,26 +262,16 @@
 
     qsort(m_SortedBuffer, m_MedianBufferFilling, sizeof(unsigned int),
           MathUtilities::compareInt);
-/*
-  std::cout << "sorted: ";
-  for (int ii = 0; ii < m_MedianBufferFilling; ++ii) {
-  std::cout << m_SortedBuffer[ii] << " ";
-  }
-  std::cout << std::endl;
-*/
+
     int sortlength = m_MedianBufferFilling;
     int midpoint = (int)ceil((double)sortlength/2);
 
-//  std::cout << "midpoint = " << midpoint << endl;
-
     if( midpoint <= 0 ) {
         midpoint = 1;
     }
 
     key = m_SortedBuffer[midpoint-1];
 
-// std::cout << "returning key = " << key << endl;
-
     return key;
 }
 
@@ -332,8 +293,7 @@
         m_keyStrengths[k] = 0;
     }
 
-    for( k = 0; k < kBinsPerOctave; k++ )
-    {
+    for( k = 0; k < kBinsPerOctave; k++ ) {
         int idx = k / (kBinsPerOctave/12);
         int rem = k % (kBinsPerOctave/12);
         if (rem == 0 || m_MajCorr[k] > m_keyStrengths[idx]) {
@@ -341,8 +301,7 @@
         }
     }
 
-    for( k = 0; k < kBinsPerOctave; k++ )
-    {
+    for( k = 0; k < kBinsPerOctave; k++ ) {
         int idx = (k + kBinsPerOctave) / (kBinsPerOctave/12);
         int rem = k % (kBinsPerOctave/12);
         if (rem == 0 || m_MinCorr[k] > m_keyStrengths[idx]) {
@@ -350,14 +309,5 @@
         }
     }
 
-/*
-    std::cout << "key strengths: ";
-    for (int ii = 0; ii < 24; ++ii) {
-        if (ii % 6 == 0) std::cout << "\n";
-        std::cout << m_keyStrengths[ii] << " ";
-    }
-    std::cout << std::endl;
-*/
-
     return m_keyStrengths;
 }
--- a/dsp/keydetection/GetKeyMode.h	Thu May 30 18:36:48 2019 +0100
+++ b/dsp/keydetection/GetKeyMode.h	Thu May 30 18:40:16 2019 +0100
@@ -20,72 +20,72 @@
 class GetKeyMode  
 {
 public:
-	GetKeyMode( int sampleRate, float tuningFrequency,
-		    double hpcpAverage, double medianAverage );
+    GetKeyMode( int sampleRate, float tuningFrequency,
+                double hpcpAverage, double medianAverage );
 
-	virtual ~GetKeyMode();
+    virtual ~GetKeyMode();
 
-	int process( double* PCMData );
+    int process( double* PCMData );
 
-	double krumCorr( const double *pDataNorm, const double *pProfileNorm, 
-                         int shiftProfile, unsigned int length );
+    double krumCorr( const double *pDataNorm, const double *pProfileNorm, 
+                     int shiftProfile, unsigned int length );
 
-	unsigned int getBlockSize() { return m_ChromaFrameSize*m_DecimationFactor; }
-	unsigned int getHopSize() { return m_ChromaHopSize*m_DecimationFactor; }
+    unsigned int getBlockSize() { return m_ChromaFrameSize*m_DecimationFactor; }
+    unsigned int getHopSize() { return m_ChromaHopSize*m_DecimationFactor; }
 
-	double* getChroma() { return m_ChrPointer; }
-	unsigned int getChromaSize();
+    double* getChroma() { return m_ChrPointer; }
+    unsigned int getChromaSize();
 
-	double* getMeanHPCP() { return m_MeanHPCP; }
+    double* getMeanHPCP() { return m_MeanHPCP; }
 
-	double* getKeyStrengths();
+    double* getKeyStrengths();
 
-	bool isModeMinor( int key ); 
+    bool isModeMinor( int key ); 
 
 protected:
 
-	double m_hpcpAverage;
-	double m_medianAverage;
-	unsigned int m_DecimationFactor;
+    double m_hpcpAverage;
+    double m_medianAverage;
+    unsigned int m_DecimationFactor;
 
-	//Decimator (fixed)
-	Decimator* m_Decimator;
+    //Decimator (fixed)
+    Decimator* m_Decimator;
 
-	//chroma configuration
-	ChromaConfig m_ChromaConfig;
+    //chroma configuration
+    ChromaConfig m_ChromaConfig;
 
-	//Chromagram object
-	Chromagram* m_Chroma;
+    //Chromagram object
+    Chromagram* m_Chroma;
 
-	//Chromagram output pointer
-	double* m_ChrPointer;
+    //Chromagram output pointer
+    double* m_ChrPointer;
 
-	//Framesize
-	unsigned int m_ChromaFrameSize;
-	//Hop
-	unsigned int m_ChromaHopSize;
+    //Framesize
+    unsigned int m_ChromaFrameSize;
+    //Hop
+    unsigned int m_ChromaHopSize;
 
 
-	unsigned int m_ChromaBuffersize;
-	unsigned int m_MedianWinsize;
-	
-	unsigned int m_bufferindex;
-	unsigned int m_ChromaBufferFilling;
-	unsigned int m_MedianBufferFilling;
-	
+    unsigned int m_ChromaBuffersize;
+    unsigned int m_MedianWinsize;
+        
+    unsigned int m_bufferindex;
+    unsigned int m_ChromaBufferFilling;
+    unsigned int m_MedianBufferFilling;
+        
 
-	double* m_DecimatedBuffer;
-	double* m_ChromaBuffer;
-	double* m_MeanHPCP;
+    double* m_DecimatedBuffer;
+    double* m_ChromaBuffer;
+    double* m_MeanHPCP;
 
-	double* m_MajProfileNorm;
-	double* m_MinProfileNorm;
-	double* m_MajCorr;
-	double* m_MinCorr;
-	int* m_MedianFilterBuffer;
-	int* m_SortedBuffer;
+    double* m_MajProfileNorm;
+    double* m_MinProfileNorm;
+    double* m_MajCorr;
+    double* m_MinCorr;
+    int* m_MedianFilterBuffer;
+    int* m_SortedBuffer;
 
-	double *m_keyStrengths;
+    double *m_keyStrengths;
 };
 
 #endif // !defined GETKEYMODE_H