diff jnmr/testApp.cpp @ 37:795a99987875

Added new patcher to test RWC database, automatically loads the file in both Max and the score follower, then stores data to a given text file. Need to fix the annotation checker next
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Thu, 15 Dec 2011 13:02:52 +0000
parents 5a1b0c6fa1fb
children c3d32207565f
line wrap: on
line diff
--- a/jnmr/testApp.cpp	Thu Dec 15 02:28:49 2011 +0000
+++ b/jnmr/testApp.cpp	Thu Dec 15 13:02:52 2011 +0000
@@ -10,9 +10,14 @@
 
 	
 	midiEvents.fileOutput = &myfile;
+	midiEvents.differenceOutput = &diffFile;
 	
-	string root = "../../../data/FilesOut/exampletest.txt";
-	myfile.open("../../../data/FilesOut/exampletest.txt");
+	root = "/Users/andrew/Documents/work/MuseScore/RWC/Classical_RWC_Groundtruth/RM-C0";
+	outputFileRoot = "../../../data/FilesOut/rwcOutputData_RM-C0";
+	
+	myfile.open("../../../data/FilesOut/exampletest2.txt");
+	diffFile.open("../../../data/FilesOut/diffTest.txt");
+	
 	if (myfile.is_open())
 	{
 	//	myfile << "This is a line.\n";
@@ -20,19 +25,21 @@
 //		myfile.close();
 		printf("WRITING TO TEXT FILE\n");
 	}
-	else cout << "Unable to open file";
+	else cout << "Unable to open example file";
 	
 	
- this->args->printArgs();
+	this->args->printArgs();
 	this->args->printOpts();
-	midiFileName = "../../../data/frerejacques.mid";
-	
-	if (this->args->getCount() > 0){
+
+	loadRWCfileNumber(2);
+
+/*	if (this->args->getCount() > 0){
 		museScoreFilename = this->args->getString(1);
 	//printf("MUSESCORE FILENAME IS %s\n", museScoreFilename);
 	cout << "running!! " << museScoreFilename << endl;
 	midiFileName = museScoreFilename;
 	}
+*/	
 
 	int retVal = cannamMainFunction();
 	
@@ -137,7 +144,6 @@
 		if ( m.getAddress() == "/stopplaying" )
 		{
 			stopPlaying();
-			myfile.close();
 		}
 		
 		
@@ -208,6 +214,11 @@
 			
 		}
 		
+		if ( m.getAddress() == "/RWCfile" ){
+			openOutputFile(m.getArgAsInt32(0));
+			loadRWCfileNumber(m.getArgAsInt32(0));
+		}
+		
 		
 	}//end while osc
 	if (midiEvents.recordedEventTimes.size() > 0)
@@ -562,6 +573,9 @@
 	midiEvents.bestMatchIndex = 0;
 	sendNoteToMuseScore();
 	
+	diffFile.close();
+	myfile.close();
+	
 }
 
 bool testApp::getFilenameFromDialogBox(string* fileNameToSave){
@@ -588,7 +602,32 @@
 	
 }
 
+void testApp::openOutputFile(const int& i){
+	if (diffFile.is_open())
+		diffFile.close();
+	
+	string outputFileName;
+	
+	if (i >= 10)
+		outputFileName = outputFileRoot + ofToString(i)+".txt";
+	else
+		outputFileName = outputFileRoot + "0"+ofToString(i)+".txt";
+	
+	diffFile.open(outputFileName.c_str());
+}
 
+void testApp::loadRWCfileNumber(const int& i){
+	if (i >= 1 && i <= 64){
+		midiFileNumber = i;
+			if (i >= 10)
+				midiFileName = root + ofToString(midiFileNumber)+".MID";
+			else
+				midiFileName = root + "0"+ofToString(midiFileNumber)+".MID";
+		
+		printf("FILE:%s\n", midiFileName.c_str());
+		cannamMainFunction();
+	}
+}
 
 
 int testApp::cannamMainFunction(){
@@ -604,7 +643,7 @@
 	//	}
 		
 	std::string filename = midiFileName;//argv[1];
-	
+	printf("Loading'%s'\n", midiFileName.c_str());
 //	fileLoader.chopBeginning = true;
 	fileLoader.loadFile(filename, midiEvents);