# HG changeset patch # User Andrew N Robertson # Date 1313768310 -3600 # Node ID 195907bb8bb794b2b54f226d0731da6afc15a202 # Parent 4a8e6a6cd2240013e3b5f6a58fde3c88de6adede 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. diff -r 4a8e6a6cd224 -r 195907bb8bb7 src/CannamMidiFileLoader.cpp --- 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: diff -r 4a8e6a6cd224 -r 195907bb8bb7 src/midiEventHolder.cpp --- 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) diff -r 4a8e6a6cd224 -r 195907bb8bb7 src/midiEventHolder.h --- 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;