comparison jnmr/midiEventHolder.cpp @ 39:5685ef75550c

ready to test the checker, currently commented out
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Fri, 16 Dec 2011 18:00:53 +0000
parents c3d32207565f
children 776694bcbd02
comparison
equal deleted inserted replaced
38:c3d32207565f 39:5685ef75550c
805 805
806 double playingTime = ofGetElapsedTimeMillis(); 806 double playingTime = ofGetElapsedTimeMillis();
807 playingTime -= startPlayingTime; 807 playingTime -= startPlayingTime;
808 //now at the last one 808 //now at the last one
809 809
810 810 float smoothLocation = beatPositions[smoothIndex];
811 int currentNote = recordedNoteOnMatrix[smoothIndex][1];
811 812
812 while (smoothIndex < recordedEventTimes.size() && recordedEventTimes[smoothIndex] < newPosition){ 813 while (smoothIndex < recordedEventTimes.size() && recordedEventTimes[smoothIndex] < newPosition){
813 float annotationTime = 0; 814 float annotationTime = 0;
814 float annotationLocation = 0; 815 float annotationLocation = 0;
815 int annotationNote = 0; 816 int annotationNote = 0;
817 float difference = 10000;//very big
818 float currentLocationDifference = 1.0;
819 float range = 1.0;
816 if (smoothIndex < myNotation.rwcAnnotations.size()){ 820 if (smoothIndex < myNotation.rwcAnnotations.size()){
821 //add in test here to find closest matching note
822
823 /*
824 int testIndex = smoothIndex;
825 while (testIndex >= 0 && abs(smoothLocation - myNotation.rwcAnnotations[testIndex].beatLocation) < range){
826
827 if (myNotation.rwcAnnotations[testIndex].midiNote == currentNote){
828 if (abs(myNotation.rwcAnnotations[testIndex].beatLocation - smoothLocation) < currentLocationDifference){
829 currentLocationDifference = abs(myNotation.rwcAnnotations[testIndex].beatLocation - smoothLocation);
830 difference = playingTime - (myNotation.rwcAnnotations[testIndex].eventTime*1000.0);
831 annotationNote = myNotation.rwcAnnotations[testIndex].midiNote;
832 annotationLocation = myNotation.rwcAnnotations[testIndex].beatLocation;
833 annotationTime = myNotation.rwcAnnotations[testIndex].eventTime;
834 }
835 }
836 testIndex--;
837 }
838
839 testIndex = smoothIndex;
840 while (testIndex >= 0 && testIndex < myNotation.rwcAnnotations.size() && abs(smoothLocation - myNotation.rwcAnnotations[testIndex].beatLocation) < range){
841
842 if (myNotation.rwcAnnotations[testIndex].midiNote == currentNote){
843 if (abs(myNotation.rwcAnnotations[testIndex].beatLocation - smoothLocation) < currentLocationDifference){
844 currentLocationDifference = abs(myNotation.rwcAnnotations[testIndex].beatLocation - smoothLocation);
845 difference = playingTime - (myNotation.rwcAnnotations[testIndex].eventTime*1000.0);
846 annotationNote = myNotation.rwcAnnotations[testIndex].midiNote;
847 annotationLocation = myNotation.rwcAnnotations[testIndex].beatLocation;
848 annotationTime = myNotation.rwcAnnotations[testIndex].eventTime;
849 }
850 }
851 testIndex++;
852 }
853 */
817 annotationTime = myNotation.rwcAnnotations[smoothIndex].eventTime; 854 annotationTime = myNotation.rwcAnnotations[smoothIndex].eventTime;
818 annotationNote = myNotation.rwcAnnotations[smoothIndex].midiNote; 855 annotationNote = myNotation.rwcAnnotations[smoothIndex].midiNote;
819 annotationLocation = myNotation.rwcAnnotations[smoothIndex].beatLocation; 856 annotationLocation = myNotation.rwcAnnotations[smoothIndex].beatLocation;
820 } 857 }
821 858
822 float difference = playingTime - (annotationTime*1000.0); 859 difference = playingTime - (annotationTime*1000.0);
823 860
824 if ((*fileOutput).is_open()){ 861 if ((*fileOutput).is_open()){
825 (*fileOutput) << fixed << beatPositions[smoothIndex] <<",\t" << recordedNoteOnMatrix[smoothIndex][1] << ",\t"; 862 (*fileOutput) << fixed << beatPositions[smoothIndex] <<",\t" << recordedNoteOnMatrix[smoothIndex][1] << ",\t";
826 (*fileOutput) << playingTime ; 863 (*fileOutput) << playingTime ;
827 864