Mercurial > hg > midi-score-follower
changeset 21:11e3119ce6b4
working well. Checking in before creating diagrams
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Sun, 27 Nov 2011 21:56:19 +0000 |
parents | 7bb9ab04ee89 |
children | 9860abc92a30 |
files | src/BayesianArrayStructure.cpp src/midiEventHolder.cpp src/midiEventHolder.h |
diffstat | 3 files changed, 22 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/BayesianArrayStructure.cpp Fri Nov 25 16:52:33 2011 +0000 +++ b/src/BayesianArrayStructure.cpp Sun Nov 27 21:56:19 2011 +0000 @@ -523,7 +523,7 @@ relativeString += ": index "+ofToString(startArrayIndex)+" , "+ofToString(endArrayIndex)+" ["; // relativeString += ofToString(prior.getIndexInRealTerms(endArrayIndex), 3)+"] (sc-width:"+ofToString(screenWidthMillis, 1)+") "; relativeString += " mapped to screen "+ofToString(startScreenPosition)+" , "+ofToString(endScreenPosition); - ofDrawBitmapString(relativeString, 100, 180); +// ofDrawBitmapString(relativeString, 100, 180); ofSetColor(255, 255, 0); likelihood.drawConstrainedVector(startArrayIndex, endArrayIndex, startScreenPosition, endScreenPosition);
--- a/src/midiEventHolder.cpp Fri Nov 25 16:52:33 2011 +0000 +++ b/src/midiEventHolder.cpp Sun Nov 27 21:56:19 2011 +0000 @@ -12,6 +12,8 @@ midiEventHolder::midiEventHolder(){ // recordedNoteOnIndex = 0; + useTempoPrior = true;//puts sine wave round tempo + runningInRealTime = false; bayesStruct.realTimeMode = &runningInRealTime; @@ -30,7 +32,7 @@ minimumMatchSpeed = 0.0; maximumMatchSpeed = 2.0; - likelihoodWidth = 100; + likelihoodWidth = 100;//using 100 is good likelihoodToNoiseRatio = 0.08;//was 0.02 on 18/11/11, changing to give more weight to observations bayesStruct.speedLikelihoodNoise = 0.1;//was 0.05 @@ -200,12 +202,13 @@ timeString += " new OFF "+ofToString(bayesStruct.bestEstimate - (bayesStruct.prior.scalar*bayesStruct.prior.arraySize/2), 1); timeString += " notearrayindex "+ofToString(noteArrayIndex, 0); //when this is off teh screen there is a problem somehow XXX - bayesStruct.posterior.offset = max(0., bayesStruct.bestEstimate - (bayesStruct.prior.scalar*bayesStruct.prior.arraySize/2)); -// bayesStruct.prior.offset = max(0., bayesStruct.bestEstimate - (bayesStruct.prior.scalar*bayesStruct.prior.arraySize/2)); + + bayesStruct.posterior.offset = max(0., bayesStruct.bestEstimate - (bayesStruct.prior.scalar*bayesStruct.prior.arraySize/2));// bayesStruct.prior.offset = max(0., bayesStruct.bestEstimate - (bayesStruct.prior.scalar*bayesStruct.prior.arraySize/2)); + //trying to switch to prior - //bayesStruct.lastEventTime = ofGetElapsedTimeMillis(); - bayesStruct.lastEventTime = timePlayed; + + bayesStruct.lastEventTime = timePlayed;//bayesStruct.lastEventTime = ofGetElapsedTimeMillis(); //do the cross update to find current posterior for location // totalConfidence= 0; @@ -385,7 +388,10 @@ double speedRatio = recordedTimeDifference / playedTimeDifference; if (speedRatio <= maximumMatchSpeed && speedRatio >= minimumMatchSpeed){ //adding in a prior that prefers 1 - double priorWeighting = sin(speedRatio * PI/2); + double priorWeighting = 1; + if (useTempoPrior) + priorWeighting = sin(speedRatio * PI/2); + /* @@ -582,15 +588,15 @@ int maxSize = recordedNoteOnMatrix[size-1][0]; - string indexString = "num screens in "+ofToString(numberOfScreensIn)+"; min index to print "+ofToString(minNoteIndexToPrint)+", max index to print "+ofToString(maxNoteIndexToPrint); + /* string indexString = "num screens in "+ofToString(numberOfScreensIn)+"; min index to print "+ofToString(minNoteIndexToPrint)+", max index to print "+ofToString(maxNoteIndexToPrint); indexString += " size "+ofToString(size)+" tick loc "+ofToString(tickLocation)+" max size "+ofToString(maxSize); ofDrawBitmapString(indexString, 20, 40); - + */ } - ofDrawBitmapString(ofToString(timeOffsetForScreen, 1), 20,20); + //ofDrawBitmapString(ofToString(timeOffsetForScreen, 1), 20,20); - ofDrawBitmapString(timeString, 20, 60); + //ofDrawBitmapString(timeString, 20, 60); } @@ -613,19 +619,20 @@ ofSetColor(0, 0, 0); - ofDrawBitmapString(matchString, 20, ofGetHeight() - 20); + //ofDrawBitmapString(matchString, 20, ofGetHeight() - 20); double confidence = bayesStruct.posterior.getValueAtMillis(mouseX); /* string mouseString = "mouseX "+ofToString(confidence, 3)+" ."; ofDrawBitmapString(mouseString, 20 , ofGetHeight() - 40); -*/ + string mouseString = "updateCounter "+ofToString(bayesStruct.updateCounter); ofDrawBitmapString(mouseString, 20 , ofGetHeight() - 40); string infostring = "speed "+ofToString(bayesStruct.relativeSpeedPosterior.getIndexInRealTerms(bayesStruct.relativeSpeedPosterior.MAPestimate), 3); ofDrawBitmapString(infostring, 20 , ofGetHeight() - 60); -} +*/ + } int midiEventHolder::getLocationFromTicks(double tickPosition){ return (int)((float)(tickPosition - numberOfScreensIn*ticksPerScreen)*(*screenWidth)/(float)ticksPerScreen);
--- a/src/midiEventHolder.h Fri Nov 25 16:52:33 2011 +0000 +++ b/src/midiEventHolder.h Sun Nov 27 21:56:19 2011 +0000 @@ -134,5 +134,6 @@ void correctTiming(IntMatrix& noteOnMatrix); void doublecheckOrder(IntMatrix& noteOnMatrix); int getIndexOfMinimumAboveIndex(const int& index, IntMatrix& noteOnMatrix); + bool useTempoPrior; }; #endif \ No newline at end of file