Mercurial > hg > multitrack-audio-matcher
view annotationCalculatorSrc/MatchMultitrackAnnotationReader.cpp @ 45:d23685b9e766
Fixed the alignment error caluculations and added histogram plotting
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Tue, 08 May 2012 21:53:11 +0100 |
parents | |
children | ba36a1721538 |
line wrap: on
line source
/* * MatchMultitrackAnnotationReader.cpp * annotationResultCalculator * * Created by Andrew on 08/05/2012. * Copyright 2012 QMUL. All rights reserved. * */ #include "MatchMultitrackAnnotationReader.h" void MatchMultitrackAnnotationReader::readInMatchFile(std::string& pathName){ // "/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C002_annotation+WavPos.csv" matchData.clear(); matchLiveTimes.clear(); matchRehearsalTimes.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.firstTime = atof(part.c_str()); n.secondTime = atof(secondpart.c_str()); matchLiveTimes.push_back(atof(part.c_str())); matchRehearsalTimes.push_back(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 MatchMultitrackAnnotationReader::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].firstTime, matchData[i].secondTime); } }