Mercurial > hg > bayesian-drum-tracker
changeset 11:23ff520d28ff
Changed the likelihood to noise - now 0.6 likelihood, added in a reste for the data output
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Fri, 09 Mar 2012 20:41:32 +0000 |
parents | d880f7f29fbe |
children | e148d1534733 |
files | .DS_Store newOFsrc/BayesDrumTracker.cpp newOFsrc/BayesDrumTracker.h newOFsrc/bayesianArray.cpp newOFsrc/bayesianArray.h newOFsrc/testApp.cpp newOFsrc/testApp.h |
diffstat | 7 files changed, 34 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/newOFsrc/BayesDrumTracker.cpp Wed Mar 07 16:47:10 2012 +0000 +++ b/newOFsrc/BayesDrumTracker.cpp Fri Mar 09 20:41:32 2012 +0000 @@ -19,6 +19,7 @@ initialiseTracker(); sender.setup( HOST, OUTPORT ); + generalLikelihoodToNoiseRatio = 0.6; } @@ -181,23 +182,24 @@ }//end if paused - + beatDistribution.likelihoodNoise = 1 - generalLikelihoodToNoiseRatio; +/* if (onsetType == "kick"){ if (accompanimentStarted) - beatDistribution.likelihoodNoise = 0.5; + beatDistribution.likelihoodNoise = generalLikelihoodtoNoiseRatio; else beatDistribution.likelihoodNoise = 0.5; // printf("kick %f ", cpuBeatTime); } else{ //snare - if (accompanimentStarted) + if (accompanimentStarted)//was 0.7 and else 0.85 beatDistribution.likelihoodNoise = 0.7; else beatDistribution.likelihoodNoise = 0.85; // printf("snare %f ", cpuBeatTime); } - + */ setBeatDistribution(beatTimes.beatSegment%12);
--- a/newOFsrc/BayesDrumTracker.h Wed Mar 07 16:47:10 2012 +0000 +++ b/newOFsrc/BayesDrumTracker.h Fri Mar 09 20:41:32 2012 +0000 @@ -104,6 +104,8 @@ float debugArray [4]; string tempoUpdateStrings[16]; string tempoDataString; + + double generalLikelihoodToNoiseRatio; }; #endif \ No newline at end of file
--- a/newOFsrc/bayesianArray.cpp Wed Mar 07 16:47:10 2012 +0000 +++ b/newOFsrc/bayesianArray.cpp Fri Mar 09 20:41:32 2012 +0000 @@ -323,4 +323,15 @@ return -1*entropy; } +double bayesianArray::getEntropyOfPrior(){ + double entropy = 0; + //make sure normalised? (it is) + for (int i = 0;i < arraySize;i++){ + if (posterior[i] > 0){ + entropy += prior[i]*log(prior[i]); + } + } + return -1*entropy; +} +
--- a/newOFsrc/bayesianArray.h Wed Mar 07 16:47:10 2012 +0000 +++ b/newOFsrc/bayesianArray.h Fri Mar 09 20:41:32 2012 +0000 @@ -60,6 +60,7 @@ double getKLdivergence(); double getEntropyOfPosterior(); + double getEntropyOfPrior(); private: };
--- a/newOFsrc/testApp.cpp Wed Mar 07 16:47:10 2012 +0000 +++ b/newOFsrc/testApp.cpp Fri Mar 09 20:41:32 2012 +0000 @@ -215,11 +215,12 @@ int size = drumTracker.beatDistribution.arraySize; int newIndex = round((size/2)+(recentError*size)); priorValue = drumTracker.beatDistribution.posterior[newIndex]; + drumTracker.newKickError(m.getArgAsFloat(0), m.getArgAsFloat(2), m.getArgAsString(1)); KLdiv = drumTracker.beatDistribution.getKLdivergence(); entropy = drumTracker.beatDistribution.getEntropyOfPosterior(); - + priorEntropy = drumTracker.beatDistribution.getEntropyOfPrior(); drumType = m.getArgAsString(1); int drumIndicator = 2; @@ -230,16 +231,16 @@ beatPosition = m.getArgAsFloat(3); printf("NEW BEAT: time %f error %f, position %f, drum %s, ", beatTime, recentError, beatPosition, drumType.c_str()); - printf("KL div %f, entropy %f prior value %f, ", KLdiv, entropy, priorValue); + printf("KL div %f, entropy %f prior Entropy %f prior value %f, ", KLdiv, entropy, priorEntropy, priorValue); printf("tatum is %f\n", drumTracker.beatTimes.tatum ); if (outputFile.is_open()){ outputFile.precision(4); - outputFile << fixed << beatTime << ", " << drumIndicator << ", " << recentError <<", " << beatPosition << ", " ; + outputFile << fixed << beatTime << ", " << drumIndicator << ", " << recentError << ", " << beatPosition << ", " ; outputFile.precision(6); - outputFile << fixed << priorValue << ", " << KLdiv << ", " << entropy << ", " << drumTracker.beatTimes.tatum << "\n"; + outputFile << fixed << priorValue << ", " << KLdiv << ", " << entropy << ", " << priorEntropy << ", " << drumTracker.beatTimes.tatum << "\n"; }else{ printf("file not open\n"); } @@ -1164,7 +1165,14 @@ if (key == 's'){ bSmooth = !bSmooth; } - + if (key == 'n'){ + if (outputFile.is_open()){ + outputFile.close(); + } + outputFile.open("../../../data/baydrumTest.txt"); + + } + if (key == 'x'){ printInterval = !printInterval; }
--- a/newOFsrc/testApp.h Wed Mar 07 16:47:10 2012 +0000 +++ b/newOFsrc/testApp.h Fri Mar 09 20:41:32 2012 +0000 @@ -127,7 +127,7 @@ // string tempoUpdateStrings[16]; // string tempoDataString; - double KLdiv, entropy, recentError; + double KLdiv, entropy, recentError, priorEntropy; string drumType; double priorValue;