diff src/AccompanimentSynchroniser.cpp @ 55:2eca10a31ae2

improving printing of information, looking at how tempo is modelled
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Mon, 10 Dec 2012 17:07:21 +0000
parents 5274e3b5479d
children
line wrap: on
line diff
--- a/src/AccompanimentSynchroniser.cpp	Tue Aug 14 21:45:25 2012 +0100
+++ b/src/AccompanimentSynchroniser.cpp	Mon Dec 10 17:07:21 2012 +0000
@@ -21,6 +21,7 @@
 
 void AccompanimentSynchroniser::reset(){
 	
+	printf("ACC SYNC RESET\n");
 	
 	playingPositionRatio = 0;
 	playingPositionSamples = 0;
@@ -29,10 +30,12 @@
 	
 	recordedPositionMillis = 0;
 	recordedPositionTimeSent = 0;
-	
+
 	speed = 1;
 	smoothedSpeedOutput = 1;
 	difference = 0;
+
+	sendSpeed(smoothedSpeedOutput);
 	
 }
 
@@ -54,7 +57,7 @@
 	//we want the playing position to more closely align with the recordedPosition
 
 
-	difference += 0.5*((recordedPositionMillis - playingPositionMillis)-difference);
+	difference += 0.5*((recordedPositionMillis - playingPositionMillis) - difference);
 //	difference -=  (recordedPositionTimeSent - playingPositionTimeSent);
 	
 	//suppose we project that we will align in 1 seconds time
@@ -80,7 +83,7 @@
 }
 
 void AccompanimentSynchroniser::sendSpeed(double const& val){
-	if (val > -3 && val < 4){
+	if (val > -2 && val < 2.){
 		ofxOscMessage m;
 		m.setAddress( "/setSpeed" );
 		m.addFloatArg( val );
@@ -90,5 +93,14 @@
 		z.setAddress( "/syncDifference" );
 		z.addFloatArg( difference );
 		sender.sendMessage( z );
+	} else {
+		printf("TRY TO SEND START rec pos %f play %f\n", recordedPositionMillis, playingPositionMillis);
+		ofxOscMessage z;
+		z.setAddress( "/setToSyncPlayingPosition" );
+		z.addFloatArg( recordedPositionMillis );
+		sender.sendMessage( z );
+		sendSpeed(1);
+		smoothedSpeedOutput = 1;
+		difference = 0;
 	}
 }
\ No newline at end of file