# HG changeset patch # User Andrew N Robertson # Date 1327352090 0 # Node ID 60c1f0fbc8f483bf71722f86513c4e6f29ea738c # Parent 776694bcbd0209ad95f0dc3cd7cf7dcd9147fcbf Fixed annotation reader to read in beat and event times correctly diff -r 776694bcbd02 -r 60c1f0fbc8f4 jnmr/Annotations.cpp --- a/jnmr/Annotations.cpp Mon Dec 19 23:28:21 2011 +0000 +++ b/jnmr/Annotations.cpp Mon Jan 23 20:54:50 2012 +0000 @@ -20,47 +20,59 @@ printf("ANNOTATIONS : READ FILE %s\n", pathName.c_str()); ifstream file ( pathName.c_str()); // declare file stream: http://www.cplusplus.com/reference/iostream/ifstream/ - string value; + string value, tmpLine; + stringstream iss; int count = 0; Notation n; while ( file.good() ) { - getline ( file, value, ',' ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/ + getline(file, tmpLine); + 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 - string::size_type start = value.find_first_not_of(" \t\v"); + 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); +// printf("%s (%i)\n", part.c_str(), count); float my_float; int my_int; - - switch (count%6) { + // printf("reading %s\n", part.c_str()); + switch (count%7) { + + case 0: + my_float = atof(part.c_str()); + n.eventTime = my_float; + printf("count%i, event time float is %f\n", count, my_float); + break; + case 1: - // printf("reading %s\n", part.c_str()); + my_float = atof(part.c_str()); - // printf("float is %f\n", my_float); + printf("count%i, beat loc float is %f\n", count, my_float); n.beatLocation = my_float; break; case 2: - // printf("reading %s\n", part.c_str()); + my_int = atoi(part.c_str()); - // printf("float is %i\n", my_int); + printf("count %i, MIDI note float is %i\n", count, my_int); n.midiNote = my_int; break; - case 0: - my_float = atof(part.c_str()); - n.eventTime = my_float; - break; case 3: rwcAnnotations.push_back(n); break; default: break; } - count++; - } + count++; + }//end while reading line + iss.clear(); + + + }//end while printAnnotations(); + printf("There are %i annotations\n", (int)rwcAnnotations.size()); } diff -r 776694bcbd02 -r 60c1f0fbc8f4 jnmr/midiEventHolder.cpp --- a/jnmr/midiEventHolder.cpp Mon Dec 19 23:28:21 2011 +0000 +++ b/jnmr/midiEventHolder.cpp Mon Jan 23 20:54:50 2012 +0000 @@ -873,7 +873,8 @@ if ((*differenceOutput).is_open()){ (*differenceOutput) << beatPositions[smoothIndex] << "," << difference << "\n"; - printf("midi %i beat pos %f now at %f :: annotaion %i loc % f time %f diff \t%f ms\n", recordedNoteOnMatrix[smoothIndex][1], + printf("midi %i beat pos %f now at %f :: annotaion %i loc % f time %f diff \t%f ms\n", + recordedNoteOnMatrix[smoothIndex][1], beatPositions[smoothIndex], playingTime, annotationNote, annotationLocation, annotationTime, difference); } diff -r 776694bcbd02 -r 60c1f0fbc8f4 jnmr/testApp.cpp --- a/jnmr/testApp.cpp Mon Dec 19 23:28:21 2011 +0000 +++ b/jnmr/testApp.cpp Mon Jan 23 20:54:50 2012 +0000 @@ -21,6 +21,8 @@ this->args->printArgs(); this->args->printOpts(); + createRWCfilenameStrings(); + loadRWCfileNumber(2); openOutputFile(2); loadAnnotation(2); @@ -86,6 +88,7 @@ lastScoreIndexSent = 0; midiEvents.bestMatchIndex = 0; + } //-------------------------------------------------------------- @@ -214,6 +217,7 @@ }//end while osc + if (midiEvents.recordedEventTimes.size() > 0) checkNewScoreNote(); @@ -620,32 +624,74 @@ } void testApp::loadRWCfileNumber(const int& i){ - if (i >= 1 && i <= 64){ - midiFileNumber = i; + if (i >= 0 && 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()); + */ + midiFileName = root + rwcFileNameStrings[i]+".MID"; + printf("MIDI FILE:%s\n", midiFileName.c_str()); cannamMainFunction(); } } std::string testApp::makeRWCfilename(std::string& root, const int& fileID, std::string& endPart){ std::string pathName; - if (fileID >= 1 && fileID <= 64){ - + 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("MAKE FILE:%s\n", midiFileName.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 annotationRoot = "/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C0"; string annotationEnding = "_annotation+WavPos.csv"; diff -r 776694bcbd02 -r 60c1f0fbc8f4 jnmr/testApp.h --- a/jnmr/testApp.h Mon Dec 19 23:28:21 2011 +0000 +++ b/jnmr/testApp.h Mon Jan 23 20:54:50 2012 +0000 @@ -142,6 +142,9 @@ void openOutputFile(const int& i); std::string makeRWCfilename(std::string& root, const int& fileID, std::string& endPart); void loadAnnotation(const int& fileID); + + vector rwcFileNameStrings; + void createRWCfilenameStrings(); }; #endif