Mercurial > hg > midi-score-follower
changeset 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 |
files | jnmr/midiEventHolder.cpp |
diffstat | 1 files changed, 39 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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";