Mercurial > hg > multitrack-audio-matcher
view annotationCalculatorSrc/testApp.cpp @ 46:ba36a1721538
Added abs median calculation, match forwards and backwards paths
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Tue, 08 May 2012 23:16:00 +0100 |
parents | d23685b9e766 |
children | 689704aa55d5 |
line wrap: on
line source
#include "testApp.h" //-------------------------------------------------------------- void testApp::setup(){ ofBackground(255); histogramWidth = 10; histogramBinNumber = 25; std::string path = "../../../data/marbleArch_4_beats.txt"; // path = "../../../data/marbleArchKick_take4.txt"; beatReader.readInBeatsFile(path); GroundTruth.push_back(beatReader.beatTimes);//so we have our first file list of beats //now get the second file beat list path = "../../../data/marbleArch_6_beats.txt";//just the same one for the mo... // path = "../../../data/marbleArchKick_take6.txt";//annotated kick tracks beatReader.readInBeatsFile(path); GroundTruth.push_back(beatReader.beatTimes);//so we have our first file list of beats //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 // path = "../../../data/marbleArchloaded6_live4.txt"; path = "../../../data/MarbleArch_live4_reh6_output.txt"; path = "../../../data/marbleArch_take4_to_take6_new_output.txt"; path = "../../../data/MarbleArch_live4_reh6_newOutput.txt"; //Then we need to know where our alignment path has gone and projected these positions to be //this is the rehearsal file that was analysed //so we need to load an alignment path //then calculate the error histogram etc beatReader.readInMultiAlignmentFile(path); printf("\n\nMultitrack Alignment\n"); beatReader.calculateMedianError(GroundTruth[0], GroundTruth[1], beatReader.alignmentTimes[0], beatReader.alignmentTimes[1]); multiHistogram.createHistogram(histogramWidth, histogramBinNumber, beatReader.errors); printf("\n\nMATCH BACKWARDS\n"); matchPath = "../../../data/MatchAlignments/marbleArchlive4_reh6_match_OB.out"; matchBackwardsNotations.readInMatchFile(matchPath); beatReader.calculateMedianError(GroundTruth[0], GroundTruth[1], matchBackwardsNotations.matchLiveTimes, matchBackwardsNotations.matchRehearsalTimes); matchBackwardsHistogram.createHistogram(histogramWidth, histogramBinNumber, beatReader.errors); printf("\n\nMATCH FORWARDS\n"); matchPath = "../../../data/MatchAlignments/marbleArchlive4_reh6_match_OF.out"; matchForwardNotations.readInMatchFile(matchPath); matchForwardNotations.reverseAnnotations(); beatReader.calculateMedianError(GroundTruth[0], GroundTruth[1], matchForwardNotations.matchLiveTimes, matchForwardNotations.matchRehearsalTimes); matchForwardHistogram.createHistogram(histogramWidth, histogramBinNumber, beatReader.errors); screenToDraw = 1; xPlotMin = 0; xPlotMax = 40; yPlotMin = 0; yPlotMax = 40; } //-------------------------------------------------------------- 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; } } 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::keyPressed(int key){ if (key == OF_KEY_RIGHT){ xPlotMax += 20; xPlotMin += 20; getYvalues(); } if (key == OF_KEY_LEFT){ xPlotMin -= 20; xPlotMax -= 20; 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 == '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){ } //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void testApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void testApp::dragEvent(ofDragInfo dragInfo){ }