diff src/BayesianArrayStructure.cpp @ 14:3f103cf78148

Checking to allow offline version
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Thu, 10 Nov 2011 17:29:45 +0000
parents 75dcd1308658
children c7107e5c8f03
line wrap: on
line diff
--- a/src/BayesianArrayStructure.cpp	Thu Oct 27 21:30:42 2011 +0100
+++ b/src/BayesianArrayStructure.cpp	Thu Nov 10 17:29:45 2011 +0000
@@ -22,8 +22,8 @@
 	speedPriorValue = 1.0;
 	speedEstimate = speedPriorValue;
 	
-	lastEventTime = ofGetElapsedTimeMillis();
-	
+	lastEventTime = 0;//ofGetElapsedTimeMillis();
+
 	/*
 	 tmpPrior.createVector(240);
 	 tmpPrior.addGaussianShape(100, 40, 1);
@@ -32,6 +32,7 @@
 	 */
 	tmpBestEstimate = 0;
 	crossUpdateTimeThreshold = 100;
+	priorWidth = 30;
 }
 
 BayesianArrayStructure::BayesianArrayStructure(int length){
@@ -94,7 +95,7 @@
 	speedPriorValue = f;
 	int index = relativeSpeedPosterior.getRealTermsAsIndex(speedPriorValue);
 	relativeSpeedPosterior.zero();
-	relativeSpeedPosterior.addGaussianShape(index, 20, 0.8);
+	relativeSpeedPosterior.addGaussianShape(index, priorWidth, 0.8);
 	relativeSpeedPosterior.renormalise();
 	relativeSpeedPosterior.getMaximum();
 	relativeSpeedPrior.copyFromDynamicVector(relativeSpeedPosterior);
@@ -158,8 +159,10 @@
 void BayesianArrayStructure::setStartPlaying(){
 	lastEventTime = 0;//ofGetElapsedTimeMillis();
 	bestEstimate = 0;
-	lastBestEstimateUpdateTime = ofGetElapsedTimeMillis();
-	
+	lastBestEstimateUpdateTime = lastEventTime;
+	//bug somewhere here that prevented offline
+	//ofGetElapsedTimeMillis();//lastEventTime;//
+	printf("start playing - best estimate %f\n", lastBestEstimateUpdateTime);
 	resetArrays();
 }
 
@@ -184,7 +187,10 @@
 	updateCounter = 0;
 	
 	bestEstimate = 0;
-//	lastBestEstimateUpdateTime = ofGetElapsedTimeMillis();
+	lastBestEstimateUpdateTime = ofGetElapsedTimeMillis();
+	//cannot just be zero - offline bug
+	
+	printf("bayes reset arrays - best estimate %f\n", lastBestEstimateUpdateTime);
 	
 	setSpeedPrior(speedPriorValue);
 }
@@ -212,9 +218,15 @@
 	//lastBestEstimateUpdateTime = ofGetElapsedTimeMillis();
 }
 	
-void BayesianArrayStructure::updateBestEstimate(){
+void BayesianArrayStructure::updateBestEstimate(const double& timeDifference){
 //	double timeDiff = ofGetElapsedTimeMillis() - lastEventTime;//
-	double timeDiff = ofGetElapsedTimeMillis() - lastBestEstimateUpdateTime;
+	
+	double timeDiff = timeDifference;
+	
+	//Using timedifferencfe here will make it go wrong. Is time since beginning of playing
+	
+	//if (*realTimeMode)
+		timeDiff = ofGetElapsedTimeMillis() - lastBestEstimateUpdateTime;
 	
 	double speedEstimate = relativeSpeedPosterior.getIntegratedEstimate();
 	speedEstimate = relativeSpeedPosterior.getIndexInRealTerms(speedEstimate);