diff dsp/onsets/DetectionFunction.cpp @ 13:f2b5c4251bf3

...
author cannam
date Wed, 23 May 2007 15:22:10 +0000
parents da277e8b5244
children 68801ecbab6a
line wrap: on
line diff
--- a/dsp/onsets/DetectionFunction.cpp	Fri May 18 16:43:17 2007 +0000
+++ b/dsp/onsets/DetectionFunction.cpp	Wed May 23 15:22:10 2007 +0000
@@ -35,6 +35,8 @@
     m_dataLength = Config.frameLength;
     m_halfLength = m_dataLength/2;
     m_DFType = Config.DFType;
+    m_stepSecs = Config.stepSecs;
+    m_stepSize = Config.stepSize;
 
     m_magHistory = new double[ m_halfLength ];
     memset(m_magHistory,0, m_halfLength*sizeof(double));
@@ -98,7 +100,7 @@
 	retVal = HFC( m_halfLength, m_magnitude);
 	break;
 	
-    case  DF_SPECDIFF:
+    case DF_SPECDIFF:
 	retVal = specDiff( m_halfLength, m_magnitude);
 	break;
 	
@@ -142,10 +144,9 @@
 		
 	diff= sqrt(temp);
 
-	if( src[ i ] > 0.1)
-	{
-	    val += diff;
-	}
+        // (See note in phaseDev below.)
+
+        val += diff;
 
 	m_magHistory[ i ] = src[ i ];
     }
@@ -167,12 +168,17 @@
     {
 	tmpPhase = (srcPhase[ i ]- 2*m_phaseHistory[ i ]+m_phaseHistoryOld[ i ]);
 	dev = MathUtilities::princarg( tmpPhase );
+
+        // A previous version of this code only counted the value here
+        // if the magnitude exceeded 0.1.  My impression is that
+        // doesn't greatly improve the results for "loud" music (so
+        // long as the peak picker is reasonably sophisticated), but
+        // does significantly damage its ability to work with quieter
+        // music, so I'm removing it and counting the result always.
+        // Same goes for the spectral difference measure above.
 		
-	if( srcMagnitude[ i  ] > 0.1)
-	{
-	    tmpVal  = fabs( dev);
-	    val += tmpVal ;
-	}
+        tmpVal  = fabs(dev);
+        val += tmpVal ;
 
 	m_phaseHistoryOld[ i ] = m_phaseHistory[ i ] ;
 	m_phaseHistory[ i ] = srcPhase[ i ];