Mercurial > hg > multitrack-audio-matcher
view annotationCalculatorSrc/EwertAnnotationReader.cpp @ 50:93d21c20cfbc
Added Markers and the ability to switch to these points in the file when playing
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Thu, 14 Jun 2012 20:04:49 +0100 |
parents | |
children |
line wrap: on
line source
/* * EwertAnnotationReader.cpp * annotationResultCalculator * * Created by Andrew on 14/05/2012. * Copyright 2012 QMUL. All rights reserved. * */ #include "EwertAnnotationReader.h" EwertAnnotationReader::EwertAnnotationReader(){ swapOrder = false; annotationsLoaded = false; } void EwertAnnotationReader::clearAlignmentMatrix(){ alignmentTimes.clear(); DoubleVector v; alignmentTimes.push_back(v); v.clear(); alignmentTimes.push_back(v); } void EwertAnnotationReader::readInBeatsFile(std::string& pathName){ // "/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C002_annotation+WavPos.csv" //beatTimes.clear(); clearAlignmentMatrix(); printf("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; if (tmpLine.substr(0,1) != "%"){ //printf("line%i='%s'", count, tmpLine.c_str()); count++; string::size_type start = tmpLine.find_first_not_of(" ;,\t\v\n"); if (start != string::npos){ string firstpart = tmpLine.substr(start, string::npos); string::size_type end = firstpart.find_first_of(" ;,\t\v\n"); string part = firstpart.substr(0, end); string secondpart = tmpLine.substr(end+1, string::npos); //start = secondpart.find_first_not_of(" ,\t\v\n"); //secondpart = tmpLine.substr(end , string::npos); double firstTime = atof(part.c_str()); double secondTime = atof(secondpart.c_str()); //printf("%f,%f\n", firstTime, secondTime); if (!swapOrder){ alignmentTimes[0].push_back(firstTime); alignmentTimes[1].push_back(secondTime); } else{ alignmentTimes[0].push_back(secondTime); alignmentTimes[1].push_back(firstTime); } }else {//didnt find separator til end of line //printf("END: line empty\n"); } }else {//starts with % //printf("FIRST LINE IGNORED line%i='%s'", count, tmpLine.c_str()); // count++; } }//end while file is good annotationsLoaded = true; // printBeatTimes(); //printf("There are %i BEAT annotations\n", (int)beatTimes.size()); }