Mercurial > hg > midi-score-follower
changeset 15:9e972948d654
looking at offline version - need to do updateBestEstimate routine which presently only works for realtime
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Tue, 15 Nov 2011 13:10:12 +0000 |
parents | 3f103cf78148 |
children | f0abb0e414ec |
files | .DS_Store src/midiEventHolder.cpp src/testApp.cpp |
diffstat | 3 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/midiEventHolder.cpp Thu Nov 10 17:29:45 2011 +0000 +++ b/src/midiEventHolder.cpp Tue Nov 15 13:10:12 2011 +0000 @@ -6,7 +6,6 @@ * Copyright 2011 QMUL. All rights reserved. * */ -//hello #include "midiEventHolder.h" @@ -148,7 +147,9 @@ // double timeDifference = ofGetElapsedTimeMillis() - bayesStruct.lastEventTime; double timeDifference = timePlayed - bayesStruct.lastEventTime; -// printf("note %i played at %f and last event %f\n", pitch, timePlayed, bayesStruct.lastEventTime); + + + printf("note %i played at %f and last event %f time difference %f and current best estmate %f\n", pitch, timePlayed, bayesStruct.lastEventTime, timeDifference, bayesStruct.bestEstimate); //addnoise to the tempo distribution //bayesStruct.decaySpeedDistribution(timeDifference); if (timeDifference > 50){ @@ -233,6 +234,7 @@ matchString = ""; windowStartTime = max(0.0,(bayesStruct.bestEstimate - matchWindowWidth/2));//was playPositionInMillis + cout << "best estimate is " << bayesStruct.bestEstimate << endl; int numberOfMatches = findMatch(notePitch, windowStartTime, windowStartTime + matchWindowWidth); @@ -329,7 +331,7 @@ matchMatrix.push_back(v); matchConfidence.push_back(d); - printf("BEST MATCH TO note %i,time %i is recorded time %i, confidence %0.2f\n", notePitch, startTime, (int) recordedEventTimes[bestMatchIndex], minimumConfidence); + printf("BEST MATCH TO note %i, start time %i, endtime %i, time %i is recorded time %i, confidence %0.2f\n", notePitch, startTime, endTime, (int) recordedEventTimes[bestMatchIndex], minimumConfidence); return size; } @@ -483,7 +485,10 @@ //actually time since beginning of file i think - double timeDifference = ofGetElapsedTimeMillis() - lastPeriodUpdateTime;//elpased - lastperiodupdatetime + double timeDifference = 0; + if (runningInRealTime) + timeDifference = ofGetElapsedTimeMillis() - lastPeriodUpdateTime;//elpased - lastperiodupdatetime + //this is time diff in milliseconds //then we have double quarterNoteIntervals = (timeDifference / period);
--- a/src/testApp.cpp Thu Nov 10 17:29:45 2011 +0000 +++ b/src/testApp.cpp Tue Nov 15 13:10:12 2011 +0000 @@ -65,6 +65,20 @@ { stopPlaying(); } + + + + if ( m.getAddress() == "/realtime" ) + { + midiEvents.runningInRealTime = true; + } + + + if ( m.getAddress() == "/offline" ) + { + midiEvents.runningInRealTime = false; + } + }//end while osc }