Mercurial > hg > multitrack-audio-matcher
view annotationCalculatorSrc/testApp.cpp @ 53:5274e3b5479d
Smoothed output, added tempo distribution variation to match the output
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Tue, 14 Aug 2012 21:45:12 +0100 |
parents | 93d21c20cfbc |
children | 2eca10a31ae2 |
line wrap: on
line source
#include "testApp.h" //-------------------------------------------------------------- void testApp::setup(){ ofBackground(255); histogramWidth = 10; histogramBinNumber = 25; ewertFlag = true; // 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 < 11;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); } void testApp::processFile(int file){ setFilePaths(file); readInFiles(); processResults(); } void testApp::setFilePaths(int fileToLoad){ switch (fileToLoad) { case 0: liveGroundTruthPath = "../../../data/MarbleArch/marbleArch_4_beats.txt"; rehearsalGroundTruthPath = "../../../data/MarbleArch/marbleArch_6_beats.txt"; 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"; ewertFlag = true; break; case 1: liveGroundTruthPath = "../../../data/Lewes/LewesTake14_beatsSV.txt"; rehearsalGroundTruthPath = "../../../data/Lewes/Take13_proper_beatsSV.txt"; 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"; ewertFlag = true; break; case 2: liveGroundTruthPath = "../../../data/Wanderlust/wanderlust_take15_svBeats.txt"; rehearsalGroundTruthPath = "../../../data/Wanderlust/wanderlust_take16_svBeats.txt"; // liveToRehMultitrackAlignmentPath = "../../../data/Wanderlust/wanderlust_live15_reh16_output.txt"; // liveToRehMultitrackAlignmentPath = "../../../data/Wanderlust/wanderlust_live15_reh16_2_output.txt"; 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"; ewertFlag = true; break; case 3: //THESE NEED FIXING OF GROUTND TRUTH BEATS liveGroundTruthPath = "../../../data/DiamondWhite/DiamondWhite_Take1_beats.txt"; rehearsalGroundTruthPath = "../../../data/DiamondWhite/DiamondWhite_Take2_beats.txt"; 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"; ewertFlag = true; break; case 4: //THESE NEED FIXING OF GROUTND TRUTH BEATS liveGroundTruthPath = "../../../data/Motorcade/Motorcade_take53_beats.txt"; rehearsalGroundTruthPath = "../../../data/Motorcade/Motorcade_take57_beats.txt"; 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"; ewertFlag = true; break; case 5: liveGroundTruthPath = "../../../data/Festival/Festival21_beats.txt"; rehearsalGroundTruthPath = "../../../data/Festival/Festival23_beats.txt"; liveToRehMultitrackAlignmentPath = "../../../data/Festival/FestivalOutput_live21_reh23.txt"; liveToRehMatchOFpath = "../../../data/Festival/Festival_LiveTwo21_RehThree23_match_OF.out"; liveToRehMatchOBpath = "../../../data/Festival/Festival_LiveTwo21_RehThree23_match_OB.out"; ewertAlignmentPath = ""; ewertFlag = false; break; case 6: liveGroundTruthPath = "../../../data/StationGate/StationGate_final1_beats.txt"; rehearsalGroundTruthPath = "../../../data/StationGate/StationGate_final2_beats.txt"; liveToRehMultitrackAlignmentPath = "../../../data/StationGate/StationGate_final_reh_takeTwo_liveTakeOne_output.txt"; liveToRehMatchOFpath = "../../../data/StationGate/StationGate_Live1_reh2_match_OF.out"; liveToRehMatchOBpath = "../../../data//StationGate/StationGate_Live1_reh2_match_OB.out"; ewertAlignmentPath = ""; ewertFlag = false; break; case 7: liveGroundTruthPath = "../../../data/PennyArcade/PennyArcade_TrRehearsalBeats.txt"; rehearsalGroundTruthPath = "../../../data/PennyArcade/PennyArcade_StudioMixdown_beats.txt"; liveToRehMultitrackAlignmentPath = "../../../data/PennyArcade/PennyArcade_Live_TrRehMay12_Reh_StudioVersion14a_output.txt"; liveToRehMatchOFpath = "../../../data/PennyArcade/PennyArcade_LiveTrReh_rehStudioMix14a_match_OF.out"; liveToRehMatchOBpath = "../../../data/PennyArcade/PennyArcade_LiveTrReh_rehStudioMix14a_match_OB.out"; ewertAlignmentPath = ""; ewertFlag = false; break; case 8: //THESE NEED FIXING OF GROUTND TRUTH BEATS liveGroundTruthPath = "../../../data/SonOfMan/SonOfMan_take2_beats.txt"; rehearsalGroundTruthPath = "../../../data/SonOfMan/SonOfMan_take3_beats.txt"; liveToRehMultitrackAlignmentPath = "../../../data/SonOfMan/SonOfMan_live2_reh3_thinner_output.txt"; liveToRehMatchOFpath = "../../../data/SonOfMan/SonOfMan_live2_reh3_match_OF.out"; liveToRehMatchOBpath = "../../../data/SonOfMan/SonOfMan_live2_reh3_match_OB.out"; ewertAlignmentPath = "../../../data/SonOfMan/SonOfMan_take2__SonOfMan_take3.csv"; ewertFlag = true; break; case 9: liveGroundTruthPath = "../../../data/NewYearsResolution/NewYearsResolution_take6_beats.txt"; rehearsalGroundTruthPath = "../../../data/NewYearsResolution/NewYearsResolution_take11_beats.txt"; liveToRehMultitrackAlignmentPath = "../../../data/NewYearsResolution/NewYearsResolution_liveTakeSix_rehTake11studio_output.txt"; liveToRehMatchOFpath = "../../../data/NewYearsResolution/NewYearsResolution_Live6_reh11_match_OF.out"; liveToRehMatchOBpath = "../../../data/NewYearsResolution/NewYearsResolution_Live6_reh11_match_OB.out"; ewertAlignmentPath = ""; ewertFlag = false; break; case 10: liveGroundTruthPath = "../../../data/Stones/Stones_take2_beats.txt"; rehearsalGroundTruthPath = "../../../data/Stones/Stones_take3_beats.txt"; liveToRehMultitrackAlignmentPath = "../../../data/Stones/stones_RehTakeThree_liveTakeTwo_output_new.txt"; liveToRehMatchOFpath = "../../../data/Stones/Stones_liveTake2_RehTake3_OF.out"; liveToRehMatchOBpath = "../../../data/Stones/Stones_liveTake2_RehTake3_OB.out"; ewertAlignmentPath = ""; ewertFlag = false; break; default: /*liveGroundTruthPath = NULL; rehearsalGroundTruthPath = NULL; liveToRehMultitrackAlignmentPath = NULL; liveToRehMatchOFpath = NULL; liveToRehMatchOBpath = NULL; */ break; } } void testApp::readInFiles(){ GroundTruth.clear(); //so we have our first file list of ground truth beats beatReader.readInBeatsFile(liveGroundTruthPath); GroundTruth.push_back(beatReader.beatTimes); //then the second i.e. analysed list of beats beatReader.readInBeatsFile(rehearsalGroundTruthPath); GroundTruth.push_back(beatReader.beatTimes); //so GroundTruth[0] is the DoubleVector of file 1 beats //this is the Live file - i.e. played along //i.e. GT[0][0] - first, GT[0][1] second and so on //Then we need to know where our alignment path has projected these positions to be beatReader.readInMultiAlignmentFile(liveToRehMultitrackAlignmentPath); //read in the alignments from Match algorithm - first backwards, non-causal, path matchBackwardsNotations.readInMatchFile(liveToRehMatchOBpath); //and forwards matchForwardNotations.readInMatchFile(liveToRehMatchOFpath); matchForwardNotations.reverseAnnotations();//which needs reversing if (ewertFlag) ewertReader.readInBeatsFile(ewertAlignmentPath); else{ printf("No alignment file for Ewert method"); } } void testApp::processResults(){ printf("\n\nMultitrack Alignment\n"); beatReader.calculateMedianError(GroundTruth[0], GroundTruth[1], beatReader.alignmentTimes[0], beatReader.alignmentTimes[1]); multiHistogram.createHistogram(histogramWidth, histogramBinNumber); multiHistogram.processDataIntoHistogram(beatReader.errors); printf("\nMULTI ABS\n"); multiAbsTotalHistogram.processDataIntoHistogram(beatReader.absoluteErrors); printf("\n\nMATCH BACKWARDS\n"); beatReader.calculateMedianError(GroundTruth[0], GroundTruth[1], matchBackwardsNotations.matchLiveTimes, matchBackwardsNotations.matchRehearsalTimes); matchBackwardsHistogram.createHistogram(histogramWidth, histogramBinNumber); matchBackwardsHistogram.processDataIntoHistogram(beatReader.errors); printf("\nMATCH OB ABS\n"); matchBackwardsAbsTotalHistogram.processDataIntoHistogram(beatReader.absoluteErrors); printf("\n\nMATCH FORWARDS\n"); beatReader.calculateMedianError(GroundTruth[0], GroundTruth[1], matchForwardNotations.matchLiveTimes, matchForwardNotations.matchRehearsalTimes); matchForwardHistogram.createHistogram(histogramWidth, histogramBinNumber); matchForwardHistogram.processDataIntoHistogram(beatReader.errors); 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(); } //-------------------------------------------------------------- void testApp::update(){ } //-------------------------------------------------------------- void testApp::draw(){ switch (screenToDraw) { case 0: drawAlignmentVectors(); break; case 1: ofSetColor(0,0,255); multiHistogram.plotHistogram(); break; case 2: ofSetColor(0,255,0); matchBackwardsHistogram.plotHistogram(); break; case 3: 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; } if (squareBeingDragged) drawSquare(); } void testApp::drawSquare(){ ofSetColor(100,100,100); ofRect(squareX, squareY, squareWidth, squareHeight); } void testApp::drawAlignmentVectors(){ ofSetColor(0,0,0); // plotter.plotVector(beatReader.beatTimes); int limit = 50; //live is X //rehearsal is Y plotter.plotTwoVectors(GroundTruth[0], GroundTruth[1], xPlotMin, xPlotMax, yPlotMin, yPlotMax, true); //x axis is the live time ofSetColor(0,0,200); plotter.plotTwoVectors(beatReader.alignmentTimes[0], beatReader.alignmentTimes[1], xPlotMin, xPlotMax, yPlotMin, yPlotMax, false); ofSetColor(200,0,0); plotter.plotTwoVectors(beatReader.alignmentTimes[0], beatReader.alignmentTimes[2], xPlotMin, xPlotMax, yPlotMin, yPlotMax, false); ofSetColor(0,200,0); plotter.plotTwoVectors(matchBackwardsNotations.matchLiveTimes, matchBackwardsNotations.matchRehearsalTimes, xPlotMin, xPlotMax, yPlotMin, yPlotMax, false); ofSetColor(0,200, 200); plotter.plotTwoVectors(matchForwardNotations.matchLiveTimes, matchForwardNotations.matchRehearsalTimes, xPlotMin, xPlotMax, yPlotMin, yPlotMax, false); } void testApp::setCoordinatesToSquare(){ xPlotMin += (xPlotMax - xPlotMin)*squareX / ofGetWidth(); xPlotMax = xPlotMin + ((xPlotMax - xPlotMin)*(squareX + squareWidth)/ ofGetWidth()); double screenHeight = (double)ofGetHeight(); yPlotMax -= (yPlotMax - yPlotMin) * (squareY)/screenHeight ; yPlotMin += (yPlotMax - yPlotMin) * (screenHeight - squareY - squareHeight)/screenHeight; } //-------------------------------------------------------------- void testApp::keyPressed(int key){ if (key == OF_KEY_RIGHT){ double tmp = 0.5*(xPlotMax - xPlotMin); xPlotMax += tmp; xPlotMin += tmp; getYvalues(); } if (key == OF_KEY_LEFT){ double tmp = 0.5*(xPlotMax - xPlotMin); xPlotMin -= tmp; xPlotMax -= tmp; getYvalues(); } if (key == OF_KEY_UP){ xPlotMax = xPlotMin/2 + xPlotMax/2 ; yPlotMax = yPlotMin/2 + yPlotMax/2; } if (key == OF_KEY_DOWN){ xPlotMax = -1*xPlotMin + 2*xPlotMax ; yPlotMax = -1*xPlotMin + 2*yPlotMax; } if (key == OF_KEY_RETURN){ xPlotMin = 0; xPlotMax = beatReader.alignmentTimes[0][beatReader.alignmentTimes[0].size()-1]; yPlotMin = 0; yPlotMax = beatReader.alignmentTimes[1][beatReader.alignmentTimes[1].size()-1];; } if (key == 's'){ screenToDraw++; if (screenToDraw == NUMBER_OF_SCREENS) screenToDraw = 0; } } void testApp::getYvalues(){ //we have xmin and max // need the y equivalent int index = 0; while (index < beatReader.alignmentTimes[0].size() && beatReader.alignmentTimes[0][index] < xPlotMin){ index++; //printf("beat[%i]: %f\n", index, beatReader.alignmentTimes[0][index]); } //printf("found index %i, size %i, at val %.3f\n", index, (int)beatReader.alignmentTimes[0].size(), beatReader.alignmentTimes[0][index]); yPlotMin = beatReader.alignmentTimes[1][index]; while (index < beatReader.alignmentTimes[0].size() && beatReader.alignmentTimes[0][index] < xPlotMax) index++; yPlotMax = beatReader.alignmentTimes[1][index]; //printPlotValues(); } void testApp::printPlotValues(){ printf("xmin %.0f, mxax %.0f\n", xPlotMin, xPlotMax); printf("ymin %.0f, ymax %.0f\n", yPlotMin, yPlotMax); } //-------------------------------------------------------------- void testApp::keyReleased(int key){ } //-------------------------------------------------------------- void testApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ squareWidth = x - squareX; squareHeight = y - squareY; squareBeingDragged = true; } //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ squareX = x; squareY = y; } //-------------------------------------------------------------- void testApp::mouseReleased(int x, int y, int button){ squareBeingDragged = false; setCoordinatesToSquare(); } //-------------------------------------------------------------- void testApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void testApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void testApp::dragEvent(ofDragInfo dragInfo){ }