# HG changeset patch # User Andrew N Robertson # Date 1324058453 0 # Node ID 5685ef75550c282cb6ee77b3172404bc0386d7b0 # Parent c3d32207565f7a2ebdc79e0eb7c2430e97783130 ready to test the checker, currently commented out diff -r c3d32207565f -r 5685ef75550c jnmr/midiEventHolder.cpp --- a/jnmr/midiEventHolder.cpp Fri Dec 16 17:37:44 2011 +0000 +++ b/jnmr/midiEventHolder.cpp Fri Dec 16 18:00:53 2011 +0000 @@ -807,19 +807,56 @@ playingTime -= startPlayingTime; //now at the last one - + float smoothLocation = beatPositions[smoothIndex]; + int currentNote = recordedNoteOnMatrix[smoothIndex][1]; while (smoothIndex < recordedEventTimes.size() && recordedEventTimes[smoothIndex] < newPosition){ float annotationTime = 0; float annotationLocation = 0; int annotationNote = 0; + float difference = 10000;//very big + float currentLocationDifference = 1.0; + float range = 1.0; if (smoothIndex < myNotation.rwcAnnotations.size()){ + //add in test here to find closest matching note + + /* + int testIndex = smoothIndex; + while (testIndex >= 0 && abs(smoothLocation - myNotation.rwcAnnotations[testIndex].beatLocation) < range){ + + if (myNotation.rwcAnnotations[testIndex].midiNote == currentNote){ + if (abs(myNotation.rwcAnnotations[testIndex].beatLocation - smoothLocation) < currentLocationDifference){ + currentLocationDifference = abs(myNotation.rwcAnnotations[testIndex].beatLocation - smoothLocation); + difference = playingTime - (myNotation.rwcAnnotations[testIndex].eventTime*1000.0); + annotationNote = myNotation.rwcAnnotations[testIndex].midiNote; + annotationLocation = myNotation.rwcAnnotations[testIndex].beatLocation; + annotationTime = myNotation.rwcAnnotations[testIndex].eventTime; + } + } + testIndex--; + } + + testIndex = smoothIndex; + while (testIndex >= 0 && testIndex < myNotation.rwcAnnotations.size() && abs(smoothLocation - myNotation.rwcAnnotations[testIndex].beatLocation) < range){ + + if (myNotation.rwcAnnotations[testIndex].midiNote == currentNote){ + if (abs(myNotation.rwcAnnotations[testIndex].beatLocation - smoothLocation) < currentLocationDifference){ + currentLocationDifference = abs(myNotation.rwcAnnotations[testIndex].beatLocation - smoothLocation); + difference = playingTime - (myNotation.rwcAnnotations[testIndex].eventTime*1000.0); + annotationNote = myNotation.rwcAnnotations[testIndex].midiNote; + annotationLocation = myNotation.rwcAnnotations[testIndex].beatLocation; + annotationTime = myNotation.rwcAnnotations[testIndex].eventTime; + } + } + testIndex++; + } + */ annotationTime = myNotation.rwcAnnotations[smoothIndex].eventTime; annotationNote = myNotation.rwcAnnotations[smoothIndex].midiNote; annotationLocation = myNotation.rwcAnnotations[smoothIndex].beatLocation; } - float difference = playingTime - (annotationTime*1000.0); + difference = playingTime - (annotationTime*1000.0); if ((*fileOutput).is_open()){ (*fileOutput) << fixed << beatPositions[smoothIndex] <<",\t" << recordedNoteOnMatrix[smoothIndex][1] << ",\t";