changeset 9:0ad78ead0b75

adding output file capability
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Tue, 06 Mar 2012 17:20:18 +0000
parents 525938caf772
children d880f7f29fbe
files newOFsrc/testApp.cpp newOFsrc/testApp.h
diffstat 2 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/newOFsrc/testApp.cpp	Tue Mar 06 17:10:06 2012 +0000
+++ b/newOFsrc/testApp.cpp	Tue Mar 06 17:20:18 2012 +0000
@@ -39,6 +39,9 @@
 //INtroduce lock scheme for tempo - we know where the beat fell, so can calculate the appropriate tempo interval
 
 void testApp::setup(){
+	
+	outputFile.open("my_output_test.txt");
+	
 // listen on the given port
 	cout << "listening for osc messages on port " << PORT << "\n";
 	receiver.setup( PORT );
@@ -120,6 +123,7 @@
 		if ( m.getAddress() == "/Reset" ){
 			printf("baysian reset\n");
 			drumTracker.resetParameters();
+			outputFile.close();
 		}
 		
 		
@@ -142,6 +146,16 @@
 			printf("KL div %f, entropy %f prior value %f, ", KLdiv, entropy, priorValue);
 			
 			printf("tatum is %f\n", drumTracker.beatTimes.tatum );
+			
+			
+			if (outputFile.is_open()){
+				outputFile << m.getArgAsFloat(2) << ", " << recentError <<", "<<beatPosition<<", "<< drumType.c_str() << "\n";
+			}else{
+				printf("file not open\n");
+			}
+			
+			
+			
 		}//end if new error
 		
 
--- a/newOFsrc/testApp.h	Tue Mar 06 17:10:06 2012 +0000
+++ b/newOFsrc/testApp.h	Tue Mar 06 17:20:18 2012 +0000
@@ -8,6 +8,8 @@
 //#include "bayesianArray.h"
 //#include "beatTempo.h"
 #include "BayesDrumTracker.h"
+#include <iostream>
+#include <fstream>
 
 // listen on port 12345
 #define PORT 12345
@@ -129,6 +131,8 @@
 	double beatPosition;
 	
 	void drawKLdivAndEntropy();
+	ofstream outputFile;
+	
 	private:
 
 	//	ofxOscSender sender;