Mercurial > hg > midi-score-follower
changeset 5:195907bb8bb7
added purple where notes have been seen - lets you see what updates have been used. Also the chopping of midi files to the beginning was introduced recently, so when they load, you chop any white space at the beginning, then use first note to launch.
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Fri, 19 Aug 2011 16:38:30 +0100 |
parents | 4a8e6a6cd224 |
children | 6f5836d432ca |
files | src/CannamMidiFileLoader.cpp src/midiEventHolder.cpp src/midiEventHolder.h |
diffstat | 3 files changed, 31 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/CannamMidiFileLoader.cpp Fri Aug 19 15:53:04 2011 +0100 +++ b/src/CannamMidiFileLoader.cpp Fri Aug 19 16:38:30 2011 +0100 @@ -179,7 +179,9 @@ myMidiEvents.recordedEventTimes.push_back(myMidiEvents.getEventTimeMillis(t) - firstNoteTime); // printf("chopping beginning %f \n", myMidiEvents.getEventTimeMillis(t) - firstNoteTime); } - + + myMidiEvents.noteOnMatches.push_back(false); + break; case MIDI_POLY_AFTERTOUCH:
--- a/src/midiEventHolder.cpp Fri Aug 19 15:53:04 2011 +0100 +++ b/src/midiEventHolder.cpp Fri Aug 19 16:38:30 2011 +0100 @@ -70,10 +70,16 @@ playedEventTimes.clear(); playedNoteOnMatrix.clear(); matchMatrix.clear(); + bestMatchIndex = 0; bayesStruct.resetSpeedToOne(); bayesStruct.setSpeedPrior(speedPriorValue); - + setMatchedNotesBackToFalse(); +} + +void midiEventHolder::setMatchedNotesBackToFalse(){ + for (int i = 0;i < noteOnMatches.size();i++) + noteOnMatches[i] = false; } void midiEventHolder::clearAllEvents(){ @@ -209,6 +215,7 @@ windowStartTime = max(0.0,(bayesStruct.bestEstimate - matchWindowWidth/2));//was playPositionInMillis int numberOfMatches = findMatch(notePitch, windowStartTime, windowStartTime + matchWindowWidth); + matchString += " pitch: "+ofToString(notePitch)+" matches "+ofToString(numberOfMatches)+" win start "+ofToString(windowStartTime); @@ -252,20 +259,29 @@ } - + double minimumConfidence = 0; while (startIndex < recordedEventTimes.size() && recordedEventTimes[startIndex] < endTime){ if (recordedNoteOnMatrix[startIndex][1] == notePitch){ matchesFound.push_back(startIndex); + double eventConfidence = bayesStruct.posterior.getValueAtMillis(recordedEventTimes[startIndex]); + if (eventConfidence > minimumConfidence){ + minimumConfidence = eventConfidence; + bestMatchIndex = startIndex; + } + double confidence = bayesStruct.posterior.getValueAtMillis(mouseX); // recordedEventTimes[startIndex]); matchString += "["+ofToString(startIndex)+"] = "+ofToString(confidence, 3)+" ."; } startIndex++; } - + + // printf("%i MATCHES TO Note %i found\n", (int)matchesFound.size(), notePitch); int size = matchesFound.size(); - + if (size > 0) + noteOnMatches[bestMatchIndex] = true; + IntVector v; v.push_back(size); for (int i = 0;i < matchesFound.size();i++) @@ -389,8 +405,13 @@ if (checkIfMatchedNote(tmpIndex)) ofSetColor(0,0,255); - else + else if(noteOnMatches[tmpIndex]){ + ofSetColor(255,0,255); + }else{ ofSetColor(255,255,255); + } + + // XXX replace ofgetwidth below //if (tmpIndex >= 0 && tmpIndex < size)
--- a/src/midiEventHolder.h Fri Aug 19 15:53:04 2011 +0100 +++ b/src/midiEventHolder.h Fri Aug 19 16:38:30 2011 +0100 @@ -89,6 +89,7 @@ void drawFile(); void reset(); + void setMatchedNotesBackToFalse(); int ticksPerScreen; int tickLocation; @@ -114,7 +115,7 @@ BayesianArrayStructure bayesStruct; double speedPriorValue; - + int bestMatchIndex; string timeString; double startTime;