comparison src/midiEventHolder.cpp @ 12:5897a5626f1f

gave prior to tempo so it prefers original speed
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Wed, 26 Oct 2011 14:25:46 +0100
parents df9c838d0b8f
children 3f103cf78148
comparison
equal deleted inserted replaced
11:df9c838d0b8f 12:5897a5626f1f
206 int numberOfMatchesFound = findLocalMatches(pitch); 206 int numberOfMatchesFound = findLocalMatches(pitch);
207 setMatchLikelihoods(numberOfMatchesFound); 207 setMatchLikelihoods(numberOfMatchesFound);
208 bayesStruct.calculatePosterior(); 208 bayesStruct.calculatePosterior();
209 209
210 //having found matches we have matches for new note and matches for previous notes 210 //having found matches we have matches for new note and matches for previous notes
211 if (!confidenceWeightingUsed) 211 //if (!confidenceWeightingUsed)
212 findLocalTempoPairs(); 212 findLocalTempoPairs();
213 else 213 //else
214 findLocalTempoPairsWeightedForConfidence(); 214 //findLocalTempoPairsWeightedForConfidence();
215 215
216 //bayesStruct.addGaussianNoiseToSpeedPosterior(10); 216 //bayesStruct.addGaussianNoiseToSpeedPosterior(10);
217 217
218 } 218 }
219 219
291 matchString += "["+ofToString(startIndex)+"] = "+ofToString(confidence, 3)+" ."; 291 matchString += "["+ofToString(startIndex)+"] = "+ofToString(confidence, 3)+" .";
292 292
293 if (abs(recordedEventTimes[startIndex] - bayesStruct.bestEstimate) < tmpError){ 293 if (abs(recordedEventTimes[startIndex] - bayesStruct.bestEstimate) < tmpError){
294 //record the error between expected and observed times 294 //record the error between expected and observed times
295 tmpError = abs(recordedEventTimes[startIndex] - bayesStruct.bestEstimate); 295 tmpError = abs(recordedEventTimes[startIndex] - bayesStruct.bestEstimate);
296 minimumMatchError = recordedEventTimes[startIndex] - bayesStruct.bestEstimate; 296 minimumMatchError = tmpError;//recordedEventTimes[startIndex] - bayesStruct.bestEstimate;
297 } 297 }
298 298
299 } 299 }
300 startIndex++; 300 startIndex++;
301 } 301 }
366 366
367 //we want the speed of the recording relative to that of the playing live 367 //we want the speed of the recording relative to that of the playing live
368 368
369 double speedRatio = recordedTimeDifference / playedTimeDifference; 369 double speedRatio = recordedTimeDifference / playedTimeDifference;
370 if (speedRatio <= maximumMatchSpeed && speedRatio >= minimumMatchSpeed){ 370 if (speedRatio <= maximumMatchSpeed && speedRatio >= minimumMatchSpeed){
371 //adding in a prior that prefers 1
372 double priorWeighting = sin(speedRatio * PI/2);
373
374
371 /* 375 /*
372 printf("(%i)", matchMatrix[currentPlayedIndex][i+1]); 376 printf("(%i)", matchMatrix[currentPlayedIndex][i+1]);
373 printf("[%i] :: ", recordedPreviousIndex); 377 printf("[%i] :: ", recordedPreviousIndex);
374 printf(" rec{%f} vs play(%f) ", recordedTimeDifference, playedTimeDifference); 378 printf(" rec{%f} vs play(%f) ", recordedTimeDifference, playedTimeDifference);
375 printf("update on speed ratio %f\n", speedRatio); 379 printf("update on speed ratio %f\n", speedRatio);
377 // matchString += " speed: "+ofToString(speedRatio, 3); 381 // matchString += " speed: "+ofToString(speedRatio, 3);
378 // commented for debug 382 // commented for debug
379 383
380 //bayesStruct.updateTempoDistribution(speedRatio, 0.1);//second paramter is confidence in the match 384 //bayesStruct.updateTempoDistribution(speedRatio, 0.1);//second paramter is confidence in the match
381 double amount = (1-bayesStruct.speedLikelihoodNoise)/10; 385 double amount = (1-bayesStruct.speedLikelihoodNoise)/10;
386 amount *= priorWeighting;
382 bayesStruct.updateTempoLikelihood(speedRatio, amount); 387 bayesStruct.updateTempoLikelihood(speedRatio, amount);
383 needToUpdate = true; 388 needToUpdate = true;
384 } 389 }
385 // printf("\n"); 390 // printf("\n");
386 } 391 }