diff matchAnnotationSrc/matchAnnotations.cpp @ 49:3ce6dadd8167

Added src for the results calculator, comparing match output with the JNMR midi follower output
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Fri, 23 Mar 2012 10:53:57 +0000
parents
children 158f5f38e9d3
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/matchAnnotationSrc/matchAnnotations.cpp	Fri Mar 23 10:53:57 2012 +0000
@@ -0,0 +1,63 @@
+/*
+ *  matchAnnotations.cpp
+ *  matchJNMRannotationReader
+ *
+ *  Created by Andrew on 22/03/2012.
+ *  Copyright 2012 QMUL. All rights reserved.
+ *
+ */
+
+#include "matchAnnotations.h"
+
+
+void matchAnnotations::readInMatchFile(std::string& pathName){
+	
+	// "/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C002_annotation+WavPos.csv"
+	matchData.clear();
+	
+	printf("MATCH : READ FILE %s\n", pathName.c_str());
+	ifstream file ( pathName.c_str());
+	string value, tmpLine;
+	stringstream iss;
+	int count = 0;
+	MatchNotation n;
+	while ( file.good() )
+	{
+		getline(file, tmpLine);
+		iss << tmpLine;
+		//			printf("tmp line %s\n", tmpLine.c_str());
+		while(getline ( iss, value, '\t' )){ // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
+			//	cout << string( value, 1, value.length()-2 ); // display value removing the first and the last character from it
+	//		printf("line:%s\n", value.c_str());
+			string::size_type start = value.find_first_not_of(" ,\t\v\n");
+			string firstpart = value.substr(start, string::npos);
+			string::size_type end = firstpart.find_first_of(" ,\t\v\n");
+			string part = firstpart.substr(0, end);
+			string secondpart = firstpart.substr(end, string::npos);
+			start = secondpart.find_first_not_of(" ,\t\v\n");
+			secondpart = secondpart.substr(start , string::npos);
+	//		printf("part:%s,%s\n", part.c_str(), secondpart.c_str());
+			MatchNotation n;
+			n.audioTime = atof(part.c_str());
+			n.midiTime = atof(secondpart.c_str());
+			matchData.push_back(n);
+		}//end while reading line
+		iss.clear();
+		
+		
+	}//end while
+	
+//	printAnnotations();
+	printf("There are %i MATCH annotations\n", (int)matchData.size());
+	
+}
+
+void matchAnnotations::printAnnotations(){
+	//rwcAnnotations.size()
+	for (int i = 0;i < min(200, (int)matchData.size());i++){
+		printf("MATCH audio times %f, midi played time %f \n", 
+			   matchData[i].audioTime,
+			   matchData[i].midiTime);
+	}
+}
+