diff src/midiEventHolder.cpp @ 10:2ab6f4670cf5

added in the best estimate of error between the observed midi note and the aligned midi track.
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Mon, 17 Oct 2011 22:22:55 +0100
parents 75dcd1308658
children df9c838d0b8f
line wrap: on
line diff
--- a/src/midiEventHolder.cpp	Tue Aug 23 11:20:44 2011 +0100
+++ b/src/midiEventHolder.cpp	Mon Oct 17 22:22:55 2011 +0100
@@ -181,6 +181,7 @@
 	
 	timeString += " \n :  new offset " + ofToString(bayesStruct.prior.offset , 0);
 	timeString += " \n best estimate "+ofToString(bayesStruct.bestEstimate, 1);
+	timeString += " error "+ofToString(minimumMatchError, 0);
 	timeString += " map "+ofToString(bayesStruct.relativeSpeedPosterior.integratedEstimate, 1);
 	timeString += " rel speed "+ofToString(bayesStruct.relativeSpeedPosterior.getIndexInRealTerms(bayesStruct.relativeSpeedPosterior.integratedEstimate), 1);
 	
@@ -259,7 +260,7 @@
 
 	matchesFound.clear();
 	int startIndex = 0;
-	
+
 	if (recordedEventTimes.size() > 0){
 	
 		//get to the right range of events to check in
@@ -270,6 +271,7 @@
 
 	IntVector v;
 	DoubleVector d;
+	double tmpError = 100000.;//v high error
 	
 	double minimumConfidence = 0;
 	while (startIndex < recordedEventTimes.size() && recordedEventTimes[startIndex] < endTime){
@@ -287,6 +289,13 @@
 			double confidence = eventConfidence;//bayesStruct.posterior.getValueAtMillis(mouseX);
 	//																   recordedEventTimes[startIndex]);
 			matchString += "["+ofToString(startIndex)+"] = "+ofToString(confidence, 3)+" .";
+			
+			if (abs(recordedEventTimes[startIndex] - bayesStruct.bestEstimate) < tmpError){
+				//record the error between expected and observed times
+				tmpError = abs(recordedEventTimes[startIndex] - bayesStruct.bestEstimate);
+				minimumMatchError = recordedEventTimes[startIndex] - bayesStruct.bestEstimate;
+			}
+			
 		}
 		startIndex++;
 	}