Mercurial > hg > multitrack-audio-matcher
changeset 49:8df911733fdc
Added new histogram functions - absolute error graphs like Match paper
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Tue, 22 May 2012 22:53:44 +0100 |
parents | 5359e2c0b0fb |
children | 93d21c20cfbc |
files | EvaluationPlan.pages annotationCalculatorSrc/Histogram.cpp annotationCalculatorSrc/Histogram.h annotationCalculatorSrc/testApp.cpp annotationCalculatorSrc/testApp.h src/RecordedMultitrackAudio.cpp |
diffstat | 6 files changed, 194 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/annotationCalculatorSrc/Histogram.cpp Wed May 09 21:55:16 2012 +0100 +++ b/annotationCalculatorSrc/Histogram.cpp Tue May 22 22:53:44 2012 +0100 @@ -15,11 +15,14 @@ void Histogram::createHistogram(const int& binWidthIn, const int& numberofBinsIn){ //printf("create regular histo\n"); + numberofBins = numberofBinsIn; binWidth = binWidthIn; minimumBinValue = -1.0 * binWidth * ((double)numberofBins/2); + histogram.clear(); histogram.assign(numberofBins, 0); + maximum = 0; numberOutsideRange = 0; @@ -44,6 +47,38 @@ setBinPoints(); } +void Histogram::createAbsoluteHistogramForMatchData(){ + printf("create abs histo\n"); + + minimumBinValue = 0; + + numberofBins = 7; + + histogram.clear(); + histogram.assign(numberofBins, 0); + + maximum = 0; + numberOutsideRange = 0; + + setBinPointsToMatchRange(); +} + +void Histogram::setBinPointsToMatchRange(){ + binPoints.clear(); + numberofBins = 7; + binWidth = 0; + binPoints.push_back(0); + binPoints.push_back(20); + binPoints.push_back(40); + binPoints.push_back(60); + binPoints.push_back(100); + binPoints.push_back(200); + binPoints.push_back(500); + maximumBinValue = 1000; +} + + + void Histogram::setBinPoints(){ binPoints.clear(); binPoints.push_back(minimumBinValue); @@ -75,8 +110,8 @@ binPoint = binPoints[0];//i.e. minimumBinValue; // printf("binpT%f\n", binPoint); if (data[i] >= binPoint){//i.e. falls inside - // while (data[i] > (binPoint + binWidth) && bin < numberofBins) { - while (bin < numberofBins && data[i] > binPoints[bin]) { + + while (bin < numberofBins && data[i] > binPoints[bin+1]) { //printf("data pt %f bin %i binPt %.1f\n", data[i], bin, binPoint); bin++; binPoint = binPoints[bin]; @@ -111,6 +146,22 @@ } + +void Histogram::printHistogramPercentages(){ + double total = numberOutsideRange; + + for (int k = 0; k < histogram.size();k++){ + total += histogram[k]; + } + + for (int k = 0;k < histogram.size() - 1;k++){ + printf("HISTO[%i] (%.1f - %.1f) = %.2f\n", k, binPoints[k], binPoints[k+1], 100.0*(double)histogram[k]/total); + } + printf("HISTO[%i] (%.1f - %.1f) = %.2f\n", histogram.size() - 1, binPoints[histogram.size() - 1], maximumBinValue, 100.0*(double)histogram[histogram.size() - 1]/total); + printf("OUTSIDE = %.2f\n", (double) 100.0*numberOutsideRange/total); + +} + void Histogram::plotHistogram(){ plotHistogram(maximum); } @@ -132,6 +183,31 @@ } +void Histogram::labelHistogram(){ + + double width = ofGetWidth(); +// double height = ofGetHeight(); + screenHeight = ofGetHeight(); + if (numberofBins > 0){ + width /= numberofBins; + // height /= maxHeight; + + + + for (int i = 0;i < numberofBins;i++){ + + int nextBinVal = maximumBinValue; + if (i < numberofBins - 1){ + nextBinVal = binPoints[i+1]; + } + + ofDrawBitmapString(ofToString(binPoints[i], 0)+" - "+ofToString(nextBinVal, 0), (i +0.2) * width, screenHeight - 10); + } + + } + +} + int Histogram::getY(const int& y){ return screenHeight - y;
--- a/annotationCalculatorSrc/Histogram.h Wed May 09 21:55:16 2012 +0100 +++ b/annotationCalculatorSrc/Histogram.h Tue May 22 22:53:44 2012 +0100 @@ -23,13 +23,15 @@ void createHistogram(const int& binWidthIn, const int& numberofBinsIn); void createAbsoluteHistogram(const int& binWidthIn, const int& numberofBinsIn); - + void createAbsoluteHistogramForMatchData(); void processDataIntoHistogram(const DoubleVector& data); void plotHistogram(); void plotHistogram(const double& maxHeight); void setBinPoints(); + void setBinPointsToMatchRange(); + int numberofBins; int binWidth; double minimumBinValue, maximumBinValue; @@ -41,5 +43,7 @@ int getY(const int& y); int screenHeight; + void labelHistogram(); + void printHistogramPercentages(); }; #endif \ No newline at end of file
--- a/annotationCalculatorSrc/testApp.cpp Wed May 09 21:55:16 2012 +0100 +++ b/annotationCalculatorSrc/testApp.cpp Tue May 22 22:53:44 2012 +0100 @@ -8,22 +8,48 @@ - multiAbsTotalHistogram.createAbsoluteHistogram(histogramWidth, histogramBinNumber); - matchBackwardsAbsTotalHistogram.createAbsoluteHistogram(histogramWidth, histogramBinNumber); - matchForwardAbsTotalHistogram.createAbsoluteHistogram(histogramWidth, histogramBinNumber); +// multiAbsTotalHistogram.createAbsoluteHistogram(histogramWidth, histogramBinNumber); +// matchBackwardsAbsTotalHistogram.createAbsoluteHistogram(histogramWidth, histogramBinNumber); +// matchForwardAbsTotalHistogram.createAbsoluteHistogram(histogramWidth, histogramBinNumber); + + + multiAbsTotalHistogram.createAbsoluteHistogramForMatchData();//(histogramWidth, histogramBinNumber); + matchBackwardsAbsTotalHistogram.createAbsoluteHistogramForMatchData();//(histogramWidth, histogramBinNumber); + matchForwardAbsTotalHistogram.createAbsoluteHistogramForMatchData();//(histogramWidth, histogramBinNumber); + + ewertAbsTotalHistogram.createAbsoluteHistogramForMatchData(); //processFile(0); - for (int i = 0;i < 1;i++){ + for (int i = 0;i < 5;i++){ processFile(i); } + printPercentageTotals(); + screenToDraw = 1; + int maxi = max(multiAbsTotalHistogram.maximum, matchForwardAbsTotalHistogram.maximum); + maxi = max(maxi, (int)matchBackwardsAbsTotalHistogram.maximum); + maxi += 10; + multiAbsTotalHistogram.maximum = maxi; + matchForwardAbsTotalHistogram.maximum = maxi; + matchBackwardsAbsTotalHistogram.maximum = maxi; + xPlotMin = 0; xPlotMax = 40; yPlotMin = 0; yPlotMax = 40; + + readEwertAnnotations(); +} + +void testApp::readEwertAnnotations(){ + + std::string path = "/Users/andrew/Dropbox/MultitrackAlignmentTesting/__Synchronized"; + path += "/DiamondWhite_Take1__DiamondWhite_Take2.csv"; + ewertReader.readInBeatsFile(path); + } @@ -42,6 +68,8 @@ liveToRehMultitrackAlignmentPath = "../../../data/MarbleArch/MarbleArch_live4_reh6_newOutput.txt"; liveToRehMatchOFpath = "../../../data/MarbleArch/marbleArchlive4_reh6_match_OF.out"; liveToRehMatchOBpath = "../../../data/MarbleArch/marbleArchlive4_reh6_match_OB.out"; + ewertReader.swapOrder = false; + ewertAlignmentPath = "../../../data/EwertResults/MarbleArch_Take4_multiMix__MarbleArch_Take6_multiMix.csv"; break; case 1: liveGroundTruthPath = "../../../data/Lewes/LewesTake14_beatsSV.txt"; @@ -49,6 +77,9 @@ liveToRehMultitrackAlignmentPath = "../../../data/Lewes/LewesLiveTake14_rehTake13proper_output.txt"; liveToRehMatchOFpath = "../../../data/Lewes/LewesLive14_reh13p_match_OF.out"; liveToRehMatchOBpath = "../../../data/Lewes/LewesLive14_reh13p_match_OB.out"; + ewertReader.swapOrder = true; + ewertAlignmentPath = "../../../data/EwertResults/Lewes_Take13_Newproper_Multimix__Lewes_Take14_Multimix.csv"; + break; case 2: liveGroundTruthPath = "../../../data/Wanderlust/wanderlust_take15_svBeats.txt"; @@ -58,6 +89,8 @@ liveToRehMultitrackAlignmentPath = "../../../data/Wanderlust/wandelust_live15_reh16_3_output_4msonsetw_dot2like.txt"; liveToRehMatchOFpath = "../../../data/Wanderlust/wanderlustLive15_reh16_match_OF.out"; liveToRehMatchOBpath = "../../../data/Wanderlust/wanderlustLive15_reh16_match_OB.out"; + ewertReader.swapOrder = false; + ewertAlignmentPath = "../../../data/EwertResults/Wanderlust_Take15__Wanderlust_Take16.csv"; break; case 3: @@ -67,6 +100,9 @@ liveToRehMultitrackAlignmentPath = "../../../data/DiamondWhite/DiamondWhite_live1_reh2_new_output.txt"; liveToRehMatchOFpath = "../../../data/DiamondWhite/DiamondWhite_live1_reh2_match_OF.out"; liveToRehMatchOBpath = "../../../data/DiamondWhite/DiamondWhite_live1_reh2_match_OB.out"; + ewertReader.swapOrder = false; + ewertAlignmentPath = "../../../data/EwertResults/DiamondWhite_Take1__DiamondWhite_Take2.csv"; + break; case 4: @@ -76,6 +112,8 @@ liveToRehMultitrackAlignmentPath = "../../../data/Motorcade/motorcade_live53_reh57_output.txt"; liveToRehMatchOFpath = "../../../data/Motorcade/Motorcade_live53_reh57_match_OF.out"; liveToRehMatchOBpath = "../../../data/Motorcade/Motorcade_live53_reh57_match_OB.out"; + ewertReader.swapOrder = false; + ewertAlignmentPath = "../../../data/EwertResults/Motorcade_mix_Take53__Motorcade_mix_Take57.csv"; break; @@ -106,6 +144,8 @@ void testApp::readInFiles(){ + GroundTruth.clear(); + //so we have our first file list of ground truth beats beatReader.readInBeatsFile(liveGroundTruthPath); GroundTruth.push_back(beatReader.beatTimes); @@ -125,6 +165,9 @@ //and forwards matchForwardNotations.readInMatchFile(liveToRehMatchOFpath); matchForwardNotations.reverseAnnotations();//which needs reversing + + + ewertReader.readInBeatsFile(ewertAlignmentPath); } @@ -152,6 +195,27 @@ printf("\nMATCH OF ABS\n"); matchForwardAbsTotalHistogram.processDataIntoHistogram(beatReader.absoluteErrors); + if (ewertReader.annotationsLoaded){ + printf("\n\nEWERT TIMES %i \n", ewertReader.alignmentTimes[0].size()); + + beatReader.calculateMedianError(GroundTruth[0], GroundTruth[1], ewertReader.alignmentTimes[0], ewertReader.alignmentTimes[1]); + ewertHistogram.createHistogram(histogramWidth, histogramBinNumber); + ewertHistogram.processDataIntoHistogram(beatReader.errors); + printf("\nEWERT ABS\n"); + ewertAbsTotalHistogram.processDataIntoHistogram(beatReader.absoluteErrors); + } + +} + +void testApp::printPercentageTotals(){ + printf("\nMULTI TOTAL\n"); + multiAbsTotalHistogram.printHistogramPercentages(); + printf("\nMATCH OF TOTAL\n"); + matchForwardAbsTotalHistogram.printHistogramPercentages(); + printf("\nMATCH OB TOTAL\n"); + matchBackwardsAbsTotalHistogram.printHistogramPercentages(); + printf("\nEWERT TOTAL\n"); + ewertAbsTotalHistogram.printHistogramPercentages(); } //-------------------------------------------------------------- @@ -177,6 +241,38 @@ ofSetColor(0,155,0); matchForwardHistogram.plotHistogram(); break; + case 4: + ofSetColor(0,0,255); + multiAbsTotalHistogram.plotHistogram(); + ofSetColor(0); + multiAbsTotalHistogram.labelHistogram(); + break; + case 5: + ofSetColor(0,255,0); + matchBackwardsAbsTotalHistogram.plotHistogram(); + ofSetColor(0); + matchBackwardsAbsTotalHistogram.labelHistogram(); + break; + case 6: + ofSetColor(0,155,0); + matchForwardAbsTotalHistogram.plotHistogram(); + ofSetColor(0); + matchForwardAbsTotalHistogram.labelHistogram(); + break; + case 7: + ofSetColor(155,0,0); + ewertHistogram.plotHistogram(); + ofSetColor(0); + ewertHistogram.labelHistogram(); + break; + + case 8: + ofSetColor(255,0,0); + ewertAbsTotalHistogram.plotHistogram(); + ofSetColor(0); + ewertAbsTotalHistogram.labelHistogram(); + break; + }
--- a/annotationCalculatorSrc/testApp.h Wed May 09 21:55:16 2012 +0100 +++ b/annotationCalculatorSrc/testApp.h Tue May 22 22:53:44 2012 +0100 @@ -6,7 +6,9 @@ #include "MatchMultitrackAnnotationReader.h" #include "Histogram.h" -#define NUMBER_OF_SCREENS 4 +#include "EwertAnnotationReader.h" + +#define NUMBER_OF_SCREENS 9 class testApp : public ofBaseApp{ public: @@ -35,6 +37,7 @@ void setFilePaths(int fileToLoad); void readInFiles(); void processResults(); + void printPercentageTotals(); void drawAlignmentVectors(); @@ -56,6 +59,9 @@ Histogram matchBackwardsAbsTotalHistogram; Histogram matchForwardAbsTotalHistogram; + Histogram ewertHistogram; + Histogram ewertAbsTotalHistogram; + int screenToDraw; int histogramWidth, histogramBinNumber; @@ -69,4 +75,7 @@ void drawSquare(); void setCoordinatesToSquare(); + EwertAnnotationReader ewertReader; + void readEwertAnnotations(); + std::string ewertAlignmentPath; };
--- a/src/RecordedMultitrackAudio.cpp Wed May 09 21:55:16 2012 +0100 +++ b/src/RecordedMultitrackAudio.cpp Tue May 22 22:53:44 2012 +0100 @@ -16,7 +16,7 @@ printf("loaded max val is %f\n", loadedAudioFiles[0].fileLoader.onsetDetect.onsetDetector.maximumDetectionValue); - int multitrackToLoad = 18; + int multitrackToLoad = 23; setDifferentMultitracks(multitrackToLoad);//command to load this set of audio files - see below //number 7 is problematic with memory