diff src/BTrack.cpp @ 56:b6d440942ff6

Added some simple unit tests. Removed the destructor from the BTrack class as it was unnecessary.
author Adam Stark <adamstark@users.noreply.github.com>
date Thu, 23 Jan 2014 12:17:06 +0000
parents 5e520f59127f
children 296af6af6c3d
line wrap: on
line diff
--- a/src/BTrack.cpp	Wed Jan 22 18:47:16 2014 +0000
+++ b/src/BTrack.cpp	Thu Jan 23 12:17:06 2014 +0000
@@ -43,12 +43,6 @@
 }
 
 //=======================================================================
-BTrack::~BTrack()
-{	
-	
-}
-
-//=======================================================================
 double BTrack::getBeatTimeInSeconds(long frameNumber,int hopSize,int fs)
 {
     double hop = (double) hopSize;
@@ -156,9 +150,7 @@
     // calculate the onset detection function sample for the frame
     double sample = odf.getDFsample(frame);
     
-    // add a tiny constant to the sample to stop it from ever going
-    // to zero. this is to avoid problems further down the line
-    sample = sample + 0.0001;
+    
     
     // process the new onset detection function sample in the beat tracking algorithm
     processOnsetDetectionFunctionSample(sample);
@@ -166,7 +158,15 @@
 
 //=======================================================================
 void BTrack::processOnsetDetectionFunctionSample(double newSample)
-{	 
+{
+    // we need to ensure that the onset
+    // detection function sample is positive
+    newSample = fabs(newSample);
+    
+    // add a tiny constant to the sample to stop it from ever going
+    // to zero. this is to avoid problems further down the line
+    newSample = newSample + 0.0001;
+    
 	m0--;
 	beat--;
 	playbeat = 0;