comparison 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
comparison
equal deleted inserted replaced
35:6cd3e0075adf 36:5a1b0c6fa1fb
9 9
10 10
11 //Main file to look at here is newNoteEvent() - this calls everything else to update the Bayesian array 11 //Main file to look at here is newNoteEvent() - this calls everything else to update the Bayesian array
12 12
13 #include "midiEventHolder.h" 13 #include "midiEventHolder.h"
14 #include <iostream> 14
15 #include <fstream> 15 //#include <iostream>
16 //#include <fstream>
16 17
17 midiEventHolder::midiEventHolder(){ 18 midiEventHolder::midiEventHolder(){
19
20 myNotation.readInSomeValues();
21
18 // recordedNoteOnIndex = 0; 22 // recordedNoteOnIndex = 0;
19 alignmentPosition = 0; 23 alignmentPosition = 0;
20 24
21 useTempoPrior = false;//puts sine wave round tempo 25 useTempoPrior = false;//puts sine wave round tempo
22 confidenceWeightingUsed = true; 26 confidenceWeightingUsed = true;
801 805
802 double playingTime = ofGetElapsedTimeMillis(); 806 double playingTime = ofGetElapsedTimeMillis();
803 playingTime -= startPlayingTime; 807 playingTime -= startPlayingTime;
804 //now at the last one 808 //now at the last one
805 809
810
811
806 while (smoothIndex < recordedEventTimes.size() && recordedEventTimes[smoothIndex] < newPosition){ 812 while (smoothIndex < recordedEventTimes.size() && recordedEventTimes[smoothIndex] < newPosition){
813 float annotationTime = 0;
814 int annotationNote = 0;
815 if (smoothIndex < myNotation.rwcAnnotations.size()){
816 annotationTime = myNotation.rwcAnnotations[smoothIndex].eventTime;
817 annotationNote = myNotation.rwcAnnotations[smoothIndex].midiNote;
818 }
819
820
807 if ((*fileOutput).is_open()){ 821 if ((*fileOutput).is_open()){
808 (*fileOutput) << beatPositions[smoothIndex] <<", " << recordedNoteOnMatrix[smoothIndex][1] << ", "; 822 (*fileOutput) << fixed << beatPositions[smoothIndex] <<",\t" << recordedNoteOnMatrix[smoothIndex][1] << ",\t";
809 (*fileOutput) << playingTime << "\n"; 823 (*fileOutput) << playingTime ;
824 float difference = playingTime - (annotationTime*1000.0);
825 if ( recordedNoteOnMatrix[smoothIndex][1] == annotationNote){
826 (*fileOutput) << " corresponds to " << annotationTime;
827 }
828 (*fileOutput) << " \n";
829
830 printf("midi %i beat pos %f now at %f :: annotaion %i time %f diff \t%f ms\n", recordedNoteOnMatrix[smoothIndex][1],
831 beatPositions[smoothIndex], playingTime, annotationNote, annotationTime, difference);
810 } 832 }
811 833
812 smoothIndex++; 834 smoothIndex++;
813 } 835 }
814 836