changeset 12:5897a5626f1f

gave prior to tempo so it prefers original speed
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Wed, 26 Oct 2011 14:25:46 +0100
parents df9c838d0b8f
children bba4a9da57f1
files src/midiEventHolder.cpp
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/midiEventHolder.cpp	Tue Oct 25 15:01:52 2011 +0100
+++ b/src/midiEventHolder.cpp	Wed Oct 26 14:25:46 2011 +0100
@@ -208,10 +208,10 @@
 	bayesStruct.calculatePosterior();
 	
 	//having found matches we have matches for new note and matches for previous notes
-	if (!confidenceWeightingUsed)
+	//if (!confidenceWeightingUsed)
 	findLocalTempoPairs();
-	else
-	findLocalTempoPairsWeightedForConfidence();
+	//else
+	//findLocalTempoPairsWeightedForConfidence();
 	
 	//bayesStruct.addGaussianNoiseToSpeedPosterior(10);
 	 
@@ -293,7 +293,7 @@
 			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;
+				minimumMatchError = tmpError;//recordedEventTimes[startIndex] - bayesStruct.bestEstimate;
 			}
 			
 		}
@@ -368,6 +368,10 @@
 				
 				double speedRatio = recordedTimeDifference / playedTimeDifference;
 				if (speedRatio <= maximumMatchSpeed && speedRatio >= minimumMatchSpeed){
+					//adding in a prior that prefers 1
+					double priorWeighting = sin(speedRatio * PI/2);
+					
+					
 					/*
 					 printf("(%i)", matchMatrix[currentPlayedIndex][i+1]);
 					 printf("[%i] :: ", recordedPreviousIndex);
@@ -379,6 +383,7 @@
 					
 					//bayesStruct.updateTempoDistribution(speedRatio, 0.1);//second paramter is confidence in the match
 					double amount =	(1-bayesStruct.speedLikelihoodNoise)/10;
+					amount *= priorWeighting;
 					bayesStruct.updateTempoLikelihood(speedRatio, amount);
 					needToUpdate = true;
 				}