# HG changeset patch # User Andrew N Robertson # Date 1324057064 0 # Node ID c3d32207565f7a2ebdc79e0eb7c2430e97783130 # Parent 795a99987875918b3fa120afbcb4d9994a050d4a Annotations autoloading for the various files, still needs proper checker though diff -r 795a99987875 -r c3d32207565f .DS_Store Binary file .DS_Store has changed diff -r 795a99987875 -r c3d32207565f jnmr/Annotations.cpp --- a/jnmr/Annotations.cpp Thu Dec 15 13:02:52 2011 +0000 +++ b/jnmr/Annotations.cpp Fri Dec 16 17:37:44 2011 +0000 @@ -13,24 +13,13 @@ } -void Annotations::readInSomeValues(){ +void Annotations::readInRWCfile(std::string& pathName){ - /* - ifstream fp ("/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C002_annotation+WavPos.csv"); - //FILE *fp = fopen("/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C002_annotation+WavPos.csv", "r"); - int x, y, z; - float a, b, c, d; - std::vector vec; - - while (fscanf(fp, "%f, %f, %d, %f, %d, %d, %f", &a, &b, &x, &c, &y, &z, &d) == 6) { - printf("a is %f", a); - } - fclose(fp); - */ +// "/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C002_annotation+WavPos.csv" rwcAnnotations.clear(); - printf("READ FILE\n"); - ifstream file ( "/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C002_annotation+WavPos.csv" ); // declare file stream: http://www.cplusplus.com/reference/iostream/ifstream/ + 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; int count = 0; Notation n; @@ -71,14 +60,26 @@ count++; } - //printAnnotations(); + printAnnotations(); } void Annotations::printAnnotations(){ - for (int i = 0;i < rwcAnnotations.size();i++){ - printf("Beat position %f, note %i happens at time %f \n", rwcAnnotations[i].beatLocation, rwcAnnotations[i].midiNote, rwcAnnotations[i].eventTime); +//rwcAnnotations.size() + for (int i = 0;i < 100;i++){ + printf("Annotation: Loaded Beat position %f, note %i happens at time %f \n", rwcAnnotations[i].beatLocation, rwcAnnotations[i].midiNote, rwcAnnotations[i].eventTime); } } - +/* + ifstream fp ("/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C002_annotation+WavPos.csv"); + //FILE *fp = fopen("/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C002_annotation+WavPos.csv", "r"); + int x, y, z; + float a, b, c, d; + std::vector vec; + + while (fscanf(fp, "%f, %f, %d, %f, %d, %d, %f", &a, &b, &x, &c, &y, &z, &d) == 6) { + printf("a is %f", a); + } + fclose(fp); + */ diff -r 795a99987875 -r c3d32207565f jnmr/Annotations.h --- a/jnmr/Annotations.h Thu Dec 15 13:02:52 2011 +0000 +++ b/jnmr/Annotations.h Fri Dec 16 17:37:44 2011 +0000 @@ -26,7 +26,8 @@ class Annotations{ public: Annotations(); - void readInSomeValues(); + //void readInSomeValues(); + void readInRWCfile(std::string& pathName); //~Annotations(); void printAnnotations(); vector rwcAnnotations; diff -r 795a99987875 -r c3d32207565f jnmr/midiEventHolder.cpp --- a/jnmr/midiEventHolder.cpp Thu Dec 15 13:02:52 2011 +0000 +++ b/jnmr/midiEventHolder.cpp Fri Dec 16 17:37:44 2011 +0000 @@ -17,7 +17,7 @@ midiEventHolder::midiEventHolder(){ - myNotation.readInSomeValues(); + // recordedNoteOnIndex = 0; alignmentPosition = 0; @@ -811,10 +811,12 @@ while (smoothIndex < recordedEventTimes.size() && recordedEventTimes[smoothIndex] < newPosition){ float annotationTime = 0; + float annotationLocation = 0; int annotationNote = 0; if (smoothIndex < myNotation.rwcAnnotations.size()){ annotationTime = myNotation.rwcAnnotations[smoothIndex].eventTime; annotationNote = myNotation.rwcAnnotations[smoothIndex].midiNote; + annotationLocation = myNotation.rwcAnnotations[smoothIndex].beatLocation; } float difference = playingTime - (annotationTime*1000.0); @@ -828,13 +830,15 @@ } (*fileOutput) << " \n"; - printf("midi %i beat pos %f now at %f :: annotaion %i time %f diff \t%f ms\n", recordedNoteOnMatrix[smoothIndex][1], - beatPositions[smoothIndex], playingTime, annotationNote, annotationTime, difference); + } 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], + beatPositions[smoothIndex], playingTime, + annotationNote, annotationLocation, annotationTime, difference); } smoothIndex++; diff -r 795a99987875 -r c3d32207565f jnmr/testApp.cpp --- a/jnmr/testApp.cpp Thu Dec 15 13:02:52 2011 +0000 +++ b/jnmr/testApp.cpp Fri Dec 16 17:37:44 2011 +0000 @@ -16,22 +16,14 @@ 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"; - // myfile << "This is another line.\n"; -// myfile.close(); - printf("WRITING TO TEXT FILE\n"); - } - else cout << "Unable to open example file"; - +// diffFile.open("../../../data/FilesOut/diffTest.txt"); this->args->printArgs(); this->args->printOpts(); loadRWCfileNumber(2); + openOutputFile(2); + loadAnnotation(2); /* if (this->args->getCount() > 0){ museScoreFilename = this->args->getString(1); @@ -217,6 +209,7 @@ if ( m.getAddress() == "/RWCfile" ){ openOutputFile(m.getArgAsInt32(0)); loadRWCfileNumber(m.getArgAsInt32(0)); + loadAnnotation(m.getArgAsInt32(0)); } @@ -605,14 +598,14 @@ void testApp::openOutputFile(const int& i){ if (diffFile.is_open()) diffFile.close(); - - string outputFileName; - + string endBit = ".txt"; + string outputFileName = makeRWCfilename(outputFileRoot, i, endBit); + /* if (i >= 10) outputFileName = outputFileRoot + ofToString(i)+".txt"; else outputFileName = outputFileRoot + "0"+ofToString(i)+".txt"; - + */ diffFile.open(outputFileName.c_str()); } @@ -629,6 +622,26 @@ } } +std::string testApp::makeRWCfilename(std::string& root, const int& fileID, std::string& endPart){ + std::string pathName; + if (fileID >= 1 && fileID <= 64){ + + 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::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); +} int testApp::cannamMainFunction(){ diff -r 795a99987875 -r c3d32207565f jnmr/testApp.h --- a/jnmr/testApp.h Thu Dec 15 13:02:52 2011 +0000 +++ b/jnmr/testApp.h Fri Dec 16 17:37:44 2011 +0000 @@ -140,7 +140,8 @@ int midiFileNumber; void loadRWCfileNumber(const int& i); void openOutputFile(const int& i); - + std::string makeRWCfilename(std::string& root, const int& fileID, std::string& endPart); + void loadAnnotation(const int& fileID); }; #endif