Mercurial > hg > multitrack-audio-matcher
diff bayesianArraySrc/BayesianArrayStructure.cpp @ 8:572564b7cb85
added calculation posterior into both onset and pitch processes
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Fri, 03 Feb 2012 13:28:59 +0000 |
parents | 33dedfe32893 |
children | cbadb9d05d29 |
line wrap: on
line diff
--- a/bayesianArraySrc/BayesianArrayStructure.cpp Thu Feb 02 21:55:51 2012 +0000 +++ b/bayesianArraySrc/BayesianArrayStructure.cpp Fri Feb 03 13:28:59 2012 +0000 @@ -165,10 +165,9 @@ int zeroIndex = posterior.getRealTermsAsIndex(0); printf("ZERO INDEX %i\n", zeroIndex); - posterior.addGaussianShapeFromRealTime(0, 60, 1);//one way to add at x msec + posterior.addGaussianShapeFromRealTime(0, 300, 1);//one way to add at x msec // posterior.addGaussianShape(posterior.getRealTermsAsIndex(10), 50, 1);//alternative way - //posterior.addToIndex(0, 1); likelihood.addConstant(1); updateCounter = 0; @@ -299,8 +298,9 @@ updateBestEstimate(timeDifference); lastBestEstimateUpdateTime = newEventTime;//getTimeNow(timePlayed); + //set TARGETS - commented tenmporarily + setNewDistributionOffsets(max(0., bestEstimate - (prior.scalar*prior.arraySize/2))); - setNewDistributionOffsets(max(0., bestEstimate - (prior.scalar*prior.arraySize/2))); crossUpdateArrays(posterior, relativeSpeedPosterior, timeDifference); //i.e. using the same offset as prior @@ -315,10 +315,9 @@ void BayesianArrayStructure::crossUpdateArrays(DynamicVector& position, DynamicVector& speed, double timeDifference){ + //set the cutoff for offset of position first! XXX -// printf("time difference %f, ", timeDifference); - double timeDifferenceInPositionVectorUnits = timeDifference / prior.scalar; printf("CROSS UPDATE time diff %f ms is %f units; ", timeDifference, timeDifferenceInPositionVectorUnits); @@ -335,7 +334,7 @@ updateCounter++; - prior.renormalise(); + prior.renormalise();//not strictly necessary?? } @@ -401,14 +400,19 @@ void BayesianArrayStructure::translateByMaximumSpeed(const double& timeDifferenceInPositionVectorUnits){ + int distanceMoved, newPriorIndex; + double speedIndex = getSpeedEstimateIndex(); + double speedValue = relativeSpeedPosterior.getIndexInRealTerms(speedIndex); - double speedValue = relativeSpeedPosterior.getIndexInRealTerms(relativeSpeedPosterior.integratedEstimate); +// double speedValue = relativeSpeedPosterior.getIndexInRealTerms(relativeSpeedPosterior.integratedEstimate); + //so for scalar 0.01, 50 -> speed value of 0.5 - double speedContribution = relativeSpeedPosterior.array[relativeSpeedPosterior.integratedEstimate]; + double speedContribution = relativeSpeedPosterior.array[(int)round(speedIndex)]; //so we have moved distanceMoved = round(timeDifferenceInPositionVectorUnits * speedValue);//round the value - // printf("speed [%i] gives %f moved %i in %f units \n", i, speedValue, distanceMoved, timeDifferenceInPositionVectorUnits); + + // printf("speed [%i] gives %f moved %i in %f units \n", i, speedValue, distanceMoved, timeDifferenceInPositionVectorUnits); for (int postIndex = 0;postIndex < posterior.arraySize;postIndex++){ //old posterior contributing to new prior