changeset 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 803edc47e825
children 158f5f38e9d3
files .DS_Store jnmr/Annotations.cpp jnmr/Annotations.h jnmr/midiEventHolder.cpp jnmr/midiEventHolder.h jnmr/testApp.cpp jnmr/testApp.h matchAnnotationSrc/jnmrMidiPlayerAnnotations.cpp matchAnnotationSrc/jnmrMidiPlayerAnnotations.h matchAnnotationSrc/main.cpp matchAnnotationSrc/matchAnnotations.cpp matchAnnotationSrc/matchAnnotations.h matchAnnotationSrc/testApp.cpp matchAnnotationSrc/testApp.h
diffstat 14 files changed, 603 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
Binary file .DS_Store has changed
--- a/jnmr/Annotations.cpp	Tue Mar 06 17:11:46 2012 +0000
+++ b/jnmr/Annotations.cpp	Fri Mar 23 10:53:57 2012 +0000
@@ -30,8 +30,8 @@
 			iss << tmpLine;
 //			printf("tmp line %s\n", tmpLine.c_str());
 			while(getline ( iss, value, ',' )){ // 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
-		
+	//	cout << string( value, 1, value.length()-2 ); // display value removing the first and the last character from it
+				
 		string::size_type start = value.find_first_not_of(" ,\t\v\n");
 		string part = value.substr(start, string::npos);
 //		printf("%s (%i)\n", part.c_str(), count);
@@ -40,11 +40,9 @@
 	//	printf("reading %s\n", part.c_str());
 		switch (count%7) {
 	
-			case 6:
+			case 0:
 				my_float = atof(part.c_str());
-				n.eventTime = my_float;
-				rwcAnnotations.push_back(n);
-			//	printf("count%i, event time float is %f\n", count, my_float);
+				n.midiTime = my_float;
 				break;
 				
 			case 1:
@@ -59,9 +57,21 @@
 			//	printf("count %i, MIDI note float is %i\n", count, my_int);
 				n.midiNote = my_int;
 				break;	
+			
 		
+				
+			case 6:
+				my_float = atof(part.c_str());
+				n.eventTime = my_float;
+				rwcAnnotations.push_back(n);
+				//	printf("count%i, event time float is %f\n", count, my_float);
+				break;
+				
+				
 			default:
 				break;
+				
+				
 		}
 				count++;
 			}//end while reading line
@@ -70,15 +80,17 @@
 		
 	}//end while
 	
-	printAnnotations();
-	printf("There are %i annotations\n", (int)rwcAnnotations.size());
+//	printAnnotations();
+//	printf("There are %i annotations\n", (int)rwcAnnotations.size());
 	
 }
 
 void Annotations::printAnnotations(){
 //rwcAnnotations.size()
 	for (int i = 0;i < min(100, (int)rwcAnnotations.size());i++){
-	printf("Annotation: Loaded Beat position %f, note %i happens at time %f \n", rwcAnnotations[i].beatLocation, rwcAnnotations[i].midiNote, rwcAnnotations[i].eventTime);
+	printf("Annotation: Loaded Beat position %f, note %i happens at time %f midi played time %f \n", 
+		   rwcAnnotations[i].beatLocation, rwcAnnotations[i].midiNote, rwcAnnotations[i].eventTime,
+		   rwcAnnotations[i].midiTime);
 	}
 }
 
--- a/jnmr/Annotations.h	Tue Mar 06 17:11:46 2012 +0000
+++ b/jnmr/Annotations.h	Fri Mar 23 10:53:57 2012 +0000
@@ -21,6 +21,7 @@
 	int midiNote;
 	float beatLocation;
 	float eventTime;
+	float midiTime;
 };
 
 class Annotations{
--- a/jnmr/midiEventHolder.cpp	Tue Mar 06 17:11:46 2012 +0000
+++ b/jnmr/midiEventHolder.cpp	Fri Mar 23 10:53:57 2012 +0000
@@ -24,7 +24,8 @@
 
 midiEventHolder::midiEventHolder(){
 	
-
+	timeProjectionToMeet = 600;//ms in future they will intersect bet predicted and causal play position
+	
 	double scalarForPositionVectors = 10;
 	
 //	recordedNoteOnIndex = 0;
@@ -790,15 +791,24 @@
 		//	bayesStruct.updateTmpBestEstimate(timeDifference);
 	}
 	
-	
+	//did just update smooth to current if it was less
 	
 	if (smoothPlayPosition < bayesStruct.bestEstimate){
 		updateSmoothPositionTo(bayesStruct.bestEstimate);
 		//smoothPlayPosition = bayesStruct.bestEstimate;
 	}
 	
+
+	
 	updateCausalPlayPosition(getTimeNow(bayesStruct.lastBestEstimateUpdateTime));
 	
+/*
+	//now we try updating it to a causal path that tries to match into the future	
+ if (smoothPlayPosition < causalPlayPosition){
+		updateSmoothPositionTo(causalPlayPosition);
+	}
+*/	
+	
 //	playPositionInMillis = timeDifference;//based on updating from when we change period
 	//this to be added
 
@@ -873,6 +883,7 @@
 //		assert(annotationNote == recordedNoteOnMatrix[smoothIndex][1]);
 	assert(annotationTick == recordedNoteOnMatrix[smoothIndex][0]);
 	
+		smoothDifference = difference;
 		
 		if ((*differenceOutput).is_open()){
 			(*differenceOutput) << beatPositions[smoothIndex] << "," << difference << "," << playingTime << "," << (annotationTime*1000.0) << "\n";
@@ -894,7 +905,7 @@
 
 void midiEventHolder::updateCausalPlayPosition(const double& timeNow){
 	//projected position
-	double timeProjectionToMeet = 1000;//ms in future they will intersect
+	
 	double difference =	bayesStruct.bestEstimate - causalPlayPosition;
 	causalSpeed = bayesStruct.speedEstimate;
 	causalSpeed += (difference/timeProjectionToMeet);
@@ -1038,6 +1049,7 @@
 	//ofDrawBitmapString(ofToString(timeOffsetForScreen, 1), 20,20);
 	ofSetColor(255,255,255);
 	ofDrawBitmapString(timeString, 20, 60);
+	ofDrawBitmapString("diff "+ofToString(smoothDifference), 20, 140);
 	
 //last played piutch
 	ofSetColor(0,200,0,50);
--- a/jnmr/midiEventHolder.h	Tue Mar 06 17:11:46 2012 +0000
+++ b/jnmr/midiEventHolder.h	Fri Mar 23 10:53:57 2012 +0000
@@ -190,5 +190,8 @@
 	ofstream *fileOutput;
 	Annotations myNotation;
 	ofstream *differenceOutput;
+	double timeProjectionToMeet;///ms in future they will intersect
+	
+	double smoothDifference;
 };
 #endif
\ No newline at end of file
--- a/jnmr/testApp.cpp	Tue Mar 06 17:11:46 2012 +0000
+++ b/jnmr/testApp.cpp	Fri Mar 23 10:53:57 2012 +0000
@@ -11,17 +11,17 @@
 
 	
 	
-	root = "/Users/andrew/Documents/work/MuseScore/RWC/Classical_RWC_Groundtruth/RM-C0";
+	root = "/Users/andrew/Documents/work/Alignment/MuseScore/RWC/Classical_RWC_Groundtruth/RM-C0";
 	outputFileRoot = "../../../data/FilesOut/rwcOutputData_RM-C0";
-	
+	annotationRoot = "/Users/andrew/Documents/work/Alignment/MuseScore/RWC/ANNOTATION/RM-C0";
 	myfile.open("../../../data/FilesOut/exampletest2.txt");
 	
 	
 	
-// 	diffFile.open("../../../data/FilesOut/diffTest.txt");
+ 	//diffFile.open("../../../data/FilesOut/diffTest.txt");
 	
 	midiEvents.fileOutput = &myfile;
-	midiEvents.differenceOutput = &diffFile;
+	
 	
 	
 	this->args->printArgs();
@@ -33,6 +33,8 @@
 	openOutputFile(2);
 	loadAnnotation(2);
 
+	midiEvents.differenceOutput = &diffFile;
+	
 /*	if (this->args->getCount() > 0){
 		museScoreFilename = this->args->getString(1);
 	//printf("MUSESCORE FILENAME IS %s\n", museScoreFilename);
@@ -705,7 +707,7 @@
 }
 
 void testApp::loadAnnotation(const int& fileID){
-	string annotationRoot = "/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C0";
+	
 	string annotationEnding = "_annotation+WavPos.csv";
 	string path = makeRWCfilename(annotationRoot, fileID, annotationEnding );
 	midiEvents.myNotation.readInRWCfile(path);
--- a/jnmr/testApp.h	Tue Mar 06 17:11:46 2012 +0000
+++ b/jnmr/testApp.h	Fri Mar 23 10:53:57 2012 +0000
@@ -148,6 +148,7 @@
 	
 	vector<std::string> rwcFileNameStrings;
 	void createRWCfilenameStrings();
+	string annotationRoot ;//eg = "/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C0";
 };
 
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/matchAnnotationSrc/jnmrMidiPlayerAnnotations.cpp	Fri Mar 23 10:53:57 2012 +0000
@@ -0,0 +1,111 @@
+/*
+ *  jnmrMidiPlayerannotations.cpp
+ *  matchJNMRannotationReader
+ *
+ *  Created by Andrew on 23/03/2012.
+ *  Copyright 2012 QMUL. All rights reserved.
+ *
+ */
+
+#include "jnmrMidiPlayerAnnotations.h"
+
+
+void jnmrMidiPlayerAnnotations::readInjnmrMidiPlayerFile(std::string& pathName){
+	
+	jnmrMidiPlayerData.clear();
+	differences.clear();
+	
+	printf("jnmrMidiPlayer : READ FILE %s\n", pathName.c_str());
+	ifstream file ( pathName.c_str());
+	string value, tmpLine;
+	stringstream iss;
+	int count = 0;
+	
+	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/
+			jnmrMidiPlayerNotation n;
+		//	string::size_type start = value.find_first_not_of(" ,\t\v\n");
+		//	string part = value.substr(start, string::npos);
+			
+			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);
+			
+			end = secondpart.find_first_of(" ,\t\v\n");
+			secondpart = secondpart.substr(0, end);
+			
+			n.difference = atof(secondpart.c_str());
+			n.midiTime = 0;
+			n.audioTime = 0;
+			jnmrMidiPlayerData.push_back(n);
+			differences.push_back(atof(secondpart.c_str()));
+			
+		//	printf("%s (%i) second part:%s\n", part.c_str(), count, secondpart.c_str());
+			float my_float;
+			int my_int;
+			//	printf("reading %s\n", part.c_str());
+			switch (count%4) {
+					
+				case 0:
+					my_float = atof(part.c_str());
+					n.midiTime = my_float;
+					break;
+					
+				case 1:
+					
+					my_float = atof(part.c_str());
+				//	printf("count%i, DIFF %f\n", count, my_float);
+					n.difference = my_float;
+					break;
+				case 2:
+					
+					my_float = atof(part.c_str());
+					n.audioTime = my_float;
+					break;
+					
+				case 3:
+					
+					my_float = atof(part.c_str());
+					n.midiTime = my_float;
+					jnmrMidiPlayerData.push_back(n);
+					break;	
+					
+					
+				default:
+					break;
+					
+					
+			}
+			count++;
+
+		}//end while reading line
+		iss.clear();
+		
+		
+	}//end while
+	
+	//printAnnotations();
+	printf("There are %i JNMR annotations\n", (int)jnmrMidiPlayerData.size());
+	
+}
+
+void jnmrMidiPlayerAnnotations::printAnnotations(){
+	//rwcAnnotations.size()
+	for (int i = 0;i < min(200, (int)jnmrMidiPlayerData.size());i++){
+	//	printf("jnmrMidiPlayer audio times %f, midi played time %f \n", 
+	//		   jnmrMidiPlayerData[i].audioTime,
+	//		   jnmrMidiPlayerData[i].midiTime);
+		
+		printf("jnmrMidiPlayer diff %f \n", 
+			   jnmrMidiPlayerData[i].difference);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/matchAnnotationSrc/jnmrMidiPlayerAnnotations.h	Fri Mar 23 10:53:57 2012 +0000
@@ -0,0 +1,39 @@
+/*
+ *  jnmrMidiPlayerannotations.h
+ *  matchJNMRannotationReader
+ *
+ *  Created by Andrew on 23/03/2012.
+ *  Copyright 2012 QMUL. All rights reserved.
+ *
+ */
+
+
+#ifndef JNMR_ANNOTATIONS
+#define JNMR_ANNOTATIONS
+
+#include "ofMain.h"
+
+#include <iostream>
+#include <fstream>
+using namespace std;
+
+struct jnmrMidiPlayerNotation {
+	
+	float midiTime;
+	float audioTime;
+	float difference;
+};
+
+class jnmrMidiPlayerAnnotations{
+public:
+	//matchAnnotations();
+	
+	void readInjnmrMidiPlayerFile(std::string& pathName);
+	//~Annotations();
+	void 	printAnnotations();
+	vector<jnmrMidiPlayerNotation> jnmrMidiPlayerData;
+	
+	vector<float> differences;
+	
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/matchAnnotationSrc/main.cpp	Fri Mar 23 10:53:57 2012 +0000
@@ -0,0 +1,16 @@
+#include "ofMain.h"
+#include "testApp.h"
+#include "ofAppGlutWindow.h"
+
+//========================================================================
+int main( ){
+
+    ofAppGlutWindow window;
+	ofSetupOpenGL(&window, 1024,768, OF_WINDOW);			// <-------- setup the GL context
+
+	// this kicks off the running of my app
+	// can be OF_WINDOW or OF_FULLSCREEN
+	// pass in width and height too:
+	ofRunApp( new testApp());
+
+}
--- /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);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/matchAnnotationSrc/matchAnnotations.h	Fri Mar 23 10:53:57 2012 +0000
@@ -0,0 +1,36 @@
+/*
+ *  matchAnnotations.h
+ *  matchJNMRannotationReader
+ *
+ *  Created by Andrew on 22/03/2012.
+ *  Copyright 2012 QMUL. All rights reserved.
+ *
+ */
+
+
+#ifndef MATCH_ANNOTATIONS
+#define MATCH_ANNOTATIONS
+
+#include "ofMain.h"
+
+#include <iostream>
+#include <fstream>
+using namespace std;
+
+struct MatchNotation {
+
+	float midiTime;
+	float audioTime;
+};
+
+class matchAnnotations{
+public:
+	//matchAnnotations();
+
+	void readInMatchFile(std::string& pathName);
+	//~Annotations();
+	void 	printAnnotations();
+	vector<MatchNotation> matchData;
+	
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/matchAnnotationSrc/testApp.cpp	Fri Mar 23 10:53:57 2012 +0000
@@ -0,0 +1,245 @@
+#include "testApp.h"
+
+//--------------------------------------------------------------
+void testApp::setup(){
+	//fixed stuff
+	annotationRoot = "/Users/andrew/Documents/work/Alignment/MuseScore/RWC/ANNOTATION/RM-C0";
+	jnmrPlayerRoot = "/Users/andrew/Documents/work/programming/of_preRelease_v007_osx/apps/myOpenFrameworks007/JNMR_MidiFollower/bin/data/FilesOut/savedOutputs/rwcOutputData_RM-C0";
+	
+	createRWCfilenameStrings();
+	
+	
+	std::string matchRoot = "/Users/andrew/Documents/work/programming/Shell Scripts/matchOutput/RWCmatch_RM-C0";
+	std::string matchEnd = "_ob.out";
+	std::string txtEnd = ".txt";
+	//naming convention
+	//match output must also follow the RWC ID
+	//01, 02, 03 etc
+	
+	
+	
+	int fileID = 2;
+	
+	matchPath = makeRWCfilename(matchRoot, fileID, matchEnd);
+	printf("MATCH PATH\n", matchPath.c_str());
+	matchNotations.readInMatchFile(matchPath);
+
+	
+	loadAnnotation(fileID);
+
+	printf("MATCH\n");
+	calculateMatchErrors();
+	
+	jnmrPlayerPath = makeRWCfilename(jnmrPlayerRoot, fileID, txtEnd);//+ "rwcOutputData_RM-C003.txt";
+	jnmrPlayerAnnotations.readInjnmrMidiPlayerFile(jnmrPlayerPath);
+	
+	printf("JNMR DIFFERENCES\n");
+	sortDifferenceVector(jnmrPlayerAnnotations.differences);
+	
+}
+
+
+std::string testApp::makeRWCfilename(std::string& root, const int& fileID, std::string& endPart){
+	std::string pathName;
+	if (fileID >= 0 && fileID <= 64){
+		
+		pathName = root + rwcFileNameStrings[fileID]+endPart;
+		/*
+		 if (fileID >= 10)
+		 pathName = root + ofToString(fileID)+endPart;
+		 else
+		 pathName = root + "0"+ofToString(fileID)+endPart;
+		 */
+		//printf("RWC PATH:%s\n", pathName.c_str());
+	}
+	return pathName;
+}
+
+void testApp::createRWCfilenameStrings(){
+	rwcFileNameStrings.clear();
+	for (int i = 1;i< 10;i++){
+		rwcFileNameStrings.push_back("0"+ofToString(i));
+	}
+	for (int i = 10;i< 23;i++){
+		rwcFileNameStrings.push_back(ofToString(i));
+	}
+	rwcFileNameStrings.push_back("23A");
+	rwcFileNameStrings.push_back("23B");
+	rwcFileNameStrings.push_back("23C");
+	rwcFileNameStrings.push_back("23D");
+	rwcFileNameStrings.push_back("23E");
+	
+	rwcFileNameStrings.push_back("24A");
+	rwcFileNameStrings.push_back("24B");
+	rwcFileNameStrings.push_back("24C");
+	
+	rwcFileNameStrings.push_back("25A");
+	rwcFileNameStrings.push_back("25B");
+	rwcFileNameStrings.push_back("25C");
+	rwcFileNameStrings.push_back("25D");
+	
+	for (int i = 26;i< 35;i++){
+		rwcFileNameStrings.push_back(ofToString(i));
+	}
+	rwcFileNameStrings.push_back("35A");
+	rwcFileNameStrings.push_back("35B");
+	rwcFileNameStrings.push_back("35C");
+	for (int i = 36;i< 51;i++){
+		rwcFileNameStrings.push_back(ofToString(i));
+	}
+	
+	//	for (int i = 0;i < rwcFileNameStrings.size();i++) {
+	//		printf("RWC{%i}:'%s'\n", i, rwcFileNameStrings[i].c_str());
+	//	}
+	
+}
+
+void testApp::loadAnnotation(const int& fileID){
+	
+	string annotationEnding = "_annotation+WavPos.csv";
+	string path = makeRWCfilename(annotationRoot, fileID, annotationEnding );
+	//printf("read in annotations from\n%s\n", path.c_str());
+	rwcAnnotations.readInRWCfile(path);
+}
+
+
+void testApp::calculateMatchErrors(){
+	int matchIndex = 0;
+
+	vector<float> matchDiffs;
+	
+	for (int i = 0;i < rwcAnnotations.rwcAnnotations.size();i++){
+//		printf("rwc time %f midi time %f\n", rwcAnnotations.rwcAnnotations[i].eventTime, rwcAnnotations.rwcAnnotations[i].midiTime);
+		
+		while (matchIndex < matchNotations.matchData.size() && matchNotations.matchData[matchIndex].midiTime < rwcAnnotations.rwcAnnotations[i].midiTime)
+			matchIndex++;
+		
+		while (matchNotations.matchData[matchIndex].midiTime > rwcAnnotations.rwcAnnotations[i].midiTime)
+			matchIndex--;
+		
+	//	float matchFraction = (rwcAnnotations.rwcAnnotations[i].midiTime - matchNotations.matchData[matchIndex].midiTime)/(matchNotations.matchData[matchIndex+1].midiTime - matchNotations.matchData[matchIndex].midiTime);
+	//	matchFraction *= (matchNotations.matchData[matchIndex+1].audioTime - matchNotations.matchData[matchIndex].audioTime);
+		float matchTime = matchNotations.matchData[matchIndex].audioTime;// +matchFraction  ;
+		
+//		printf("matchTime %f gives event time %f from flat event time %f\n", matchNotations.matchData[matchIndex].midiTime, matchTime, matchNotations.matchData[matchIndex].audioTime);
+	
+		float matchDifference = 1000.0*(matchTime - rwcAnnotations.rwcAnnotations[i].eventTime);
+//		printf("Match diff %f\n", matchDifference);
+	
+		matchDiffs.push_back(fabs(matchDifference));
+	}
+	
+	sortDifferenceVector(matchDiffs);
+	/*
+//GETS MEAN AND MEDIAN
+	int count = 0;
+	float total = 0;
+	
+	for (int i = 0;i < matchDiffs.size();i++){
+	//	printf("M[%i] : %f\n", i, matchDiffs[i]);
+		
+		count++;
+		total += fabs(matchDiffs[i]);
+		
+	}
+	total /= count;
+	
+	std::sort(matchDiffs.begin(), matchDiffs.end());
+	
+//	printf("SORTED TWO HUNDRED\n");
+	
+//	for (int i = 0;i < matchDiffs.size() ;i++){
+//		printf("M[%i] : %f\n", i, matchDiffs[i]);
+//	}
+	
+	printf("MATCH median %f, mean is %f\n", matchDiffs[(int)(matchDiffs.size()/2)], total);
+	*/
+
+	
+	
+}
+
+
+void testApp::sortDifferenceVector(vector<float> diffVec){
+	
+	//GETS MEAN AND MEDIAN
+	int count = 0;
+	float total = 0;
+	
+	for (int i = 0;i < diffVec.size();i++){
+		//	printf("M[%i] : %f\n", i, matchDiffs[i]);
+		
+		count++;
+		total += fabs(diffVec[i]);
+		diffVec[i] = fabs(diffVec[i]);//replace with +ve value
+	}
+	total /= count;
+	
+	std::sort(diffVec.begin(), diffVec.end());//sort vector
+	
+	/*	printf("SORTED TWO HUNDRED\n");
+	
+		for (int i = 0;i < diffVec.size() ;i++){
+			printf("Sort[%i] : %f\n", i, diffVec[i]);
+		}
+	*/
+	printf("Count %i Median %f, mean is %f\n", count, diffVec[(int)(diffVec.size()/2)], total);
+	
+	
+
+}
+
+//--------------------------------------------------------------
+void testApp::update(){
+
+}
+
+//--------------------------------------------------------------
+void testApp::draw(){
+
+}
+
+//--------------------------------------------------------------
+void testApp::keyPressed(int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::keyReleased(int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseMoved(int x, int y ){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseDragged(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mousePressed(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseReleased(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::windowResized(int w, int h){
+
+}
+
+//--------------------------------------------------------------
+void testApp::gotMessage(ofMessage msg){
+
+}
+
+//--------------------------------------------------------------
+void testApp::dragEvent(ofDragInfo dragInfo){ 
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/matchAnnotationSrc/testApp.h	Fri Mar 23 10:53:57 2012 +0000
@@ -0,0 +1,45 @@
+#pragma once
+
+#include "ofMain.h"
+
+#include "Annotations.h"
+#include "matchAnnotations.h"
+#include "jnmrMidiPlayerAnnotations.h"
+
+class testApp : public ofBaseApp{
+
+	public:
+		void setup();
+		void update();
+		void draw();
+
+		void keyPressed  (int key);
+		void keyReleased(int key);
+		void mouseMoved(int x, int y );
+		void mouseDragged(int x, int y, int button);
+		void mousePressed(int x, int y, int button);
+		void mouseReleased(int x, int y, int button);
+		void windowResized(int w, int h);
+		void dragEvent(ofDragInfo dragInfo);
+		void gotMessage(ofMessage msg);
+		
+	Annotations rwcAnnotations;
+	
+	void loadRWCfileNumber(const int& i);
+	vector<std::string> rwcFileNameStrings;
+	void createRWCfilenameStrings();
+	string annotationRoot ;
+	std::string makeRWCfilename(std::string& root, const int& fileID,  std::string& endPart);
+	void loadAnnotation(const int& fileID);
+	
+	string matchPath;
+	
+	matchAnnotations matchNotations;
+	
+	string jnmrPlayerPath, jnmrPlayerRoot;
+	jnmrMidiPlayerAnnotations jnmrPlayerAnnotations;
+	
+	void calculateMatchErrors();
+	void sortDifferenceVector(vector<float> diffVec);
+	
+};