Mercurial > hg > midi-score-follower
diff jnmr/midiEventHolder.cpp @ 36:5a1b0c6fa1fb
Added class to read in the csv Annotation file, then write out the respective difference between the performed piece as followed here, and the annotation of RWC by Ewert and Muller
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Thu, 15 Dec 2011 02:28:49 +0000 |
parents | 6cd3e0075adf |
children | 795a99987875 |
line wrap: on
line diff
--- a/jnmr/midiEventHolder.cpp Wed Dec 14 17:28:17 2011 +0000 +++ b/jnmr/midiEventHolder.cpp Thu Dec 15 02:28:49 2011 +0000 @@ -11,10 +11,14 @@ //Main file to look at here is newNoteEvent() - this calls everything else to update the Bayesian array #include "midiEventHolder.h" -#include <iostream> -#include <fstream> + +//#include <iostream> +//#include <fstream> midiEventHolder::midiEventHolder(){ + + myNotation.readInSomeValues(); + // recordedNoteOnIndex = 0; alignmentPosition = 0; @@ -803,10 +807,28 @@ playingTime -= startPlayingTime; //now at the last one + + while (smoothIndex < recordedEventTimes.size() && recordedEventTimes[smoothIndex] < newPosition){ + float annotationTime = 0; + int annotationNote = 0; + if (smoothIndex < myNotation.rwcAnnotations.size()){ + annotationTime = myNotation.rwcAnnotations[smoothIndex].eventTime; + annotationNote = myNotation.rwcAnnotations[smoothIndex].midiNote; + } + + if ((*fileOutput).is_open()){ - (*fileOutput) << beatPositions[smoothIndex] <<", " << recordedNoteOnMatrix[smoothIndex][1] << ", "; - (*fileOutput) << playingTime << "\n"; + (*fileOutput) << fixed << beatPositions[smoothIndex] <<",\t" << recordedNoteOnMatrix[smoothIndex][1] << ",\t"; + (*fileOutput) << playingTime ; + float difference = playingTime - (annotationTime*1000.0); + if ( recordedNoteOnMatrix[smoothIndex][1] == annotationNote){ + (*fileOutput) << " corresponds to " << annotationTime; + } + (*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); } smoothIndex++;