Mercurial > hg > audio-time-warp
changeset 10:69419f188284
added get time now function with a view to allowing offline update too
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Wed, 09 Nov 2011 18:34:25 +0000 |
parents | 9adcffbdc16d |
children | 68e7b61744b6 |
files | src/TimeWarp.cpp src/TimeWarp.h src/testApp.cpp src/testApp.h src/timeWarp.cpp src/timeWarp.h |
diffstat | 6 files changed, 69 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/TimeWarp.cpp Mon Nov 07 18:08:43 2011 +0000 +++ b/src/TimeWarp.cpp Wed Nov 09 18:34:25 2011 +0000 @@ -51,7 +51,7 @@ //matrixPtr.clear(); //chromoGramm.~ChromoGram(); //secondChromoGramm; - + anchorPoints.clear(); } @@ -311,6 +311,12 @@ } +void TimeWarp::addAnchorPoints(const int& startFrameX, const int& startFrameY){ + IntVector v; + v.push_back(startFrameX); + v.push_back(startFrameY); + anchorPoints.push_back(v); +} void TimeWarp::calculateAlignmentMatrix(DoubleMatrix firstMatrix, DoubleMatrix secondMatrix, DoubleMatrix* alignmentMatrix){//, DoubleMatrix simMatrix printf("starting Alignment calculation\n");
--- a/src/TimeWarp.h Mon Nov 07 18:08:43 2011 +0000 +++ b/src/TimeWarp.h Wed Nov 09 18:34:25 2011 +0000 @@ -69,6 +69,8 @@ IntMatrix partBackwardsAlignmentPath; IntMatrix forwardsAlignmentPath; + IntMatrix anchorPoints; + void addAnchorPoints(const int& startFrameX, const int& startFrameY); int partBackwardsAlignmentIndex;
--- a/src/testApp.cpp Mon Nov 07 18:08:43 2011 +0000 +++ b/src/testApp.cpp Wed Nov 09 18:34:25 2011 +0000 @@ -173,9 +173,10 @@ int frameSize = 400; int startFrameY = 0; int startFrameX = 0; - + tw.anchorPoints.clear(); for (int startFrameX = 0;startFrameX < tw.firstEnergyVector.size(); startFrameX += hopsize){//tw.firstChromaEnergyMatrix.size() //replace this with a while startFrame < end of file + tw.addAnchorPoints(startFrameX, startFrameY); //NEED TO ASSUME WE DON'T HAVE timeBefore = ofGetElapsedTimef(); @@ -706,6 +707,7 @@ drawForwardsAlignmentPathOnChromaSimilarity(startingXframe, startingYframe); + drawAnchorPointsOnChromaSimilarity(startingXframe, startingYframe); //SET TEXT @@ -954,8 +956,12 @@ float energyVectorWidth = screenWidth / scrollWidth; float energyVectorHeight = screenHeight / scrollWidth; - int index = 0; + int index = max(0, (int)tw.backwardsAlignmentPath[0].size() - backwardsAlignmentIndex); //OPTIMISE XXX + while (index > 0 && tw.forwardsAlignmentPath[0][index] > startingXFrame){ + //get to NOW + index --; + } while (tw.forwardsAlignmentPath[0][index] < startingXFrame){ //get to NOW @@ -988,6 +994,48 @@ +void testApp::drawAnchorPointsOnChromaSimilarity(const int& startingXFrame, const int& startingYFrame){ + + //using starting frame in energy vector + + if (tw.anchorPoints.size() > 0){ + int endingChromaXFrame = startingXFrame + scrollWidth; + int endingChromaYFrame = startingYFrame + scrollWidth; + + float energyVectorWidth = screenWidth / scrollWidth; + float energyVectorHeight = screenHeight / scrollWidth; + + int index = 0; + + while (index < tw.anchorPoints.size() && tw.anchorPoints[index][0] < startingXFrame){ + index ++; + } + + int xcoord; + + while (index < tw.anchorPoints.size() && tw.anchorPoints[index][0] < endingChromaXFrame) { + xcoord = min((int)(tw.similarityMatrix.size())-1,tw.anchorPoints[index][0]); + int ycoord = (int)tw.anchorPoints[index][1]; + + if (tw.alignmentMeasureMatrix.size() > 0) + ycoord = min((int)tw.anchorPoints[index][1], (int)(tw.alignmentMeasureMatrix[0].size())-1); + + int colour = 255;//tw.similarityMatrix[xcoord][ycoord]*255; + //float value = tw.alignmentMeasureMatrix[xcoord][ycoord] ; + + xcoord -= startingXFrame; + ycoord -= startingYFrame; + ofSetColor(colour,colour,colour); + ofRect((xcoord-1)*energyVectorWidth, (ycoord-1)*energyVectorHeight, 3*energyVectorWidth, 3*energyVectorHeight); + index++; + }//end while + + }//end if + +} + + +
--- a/src/testApp.h Mon Nov 07 18:08:43 2011 +0000 +++ b/src/testApp.h Wed Nov 09 18:34:25 2011 +0000 @@ -119,6 +119,7 @@ void drawEnergyVectorFromPointer(DoubleVector* energyVec); void drawForwardsAlignmentPathOnChromaSimilarity(const int& startingXFrame, const int& startingYFrame); + void drawAnchorPointsOnChromaSimilarity(const int& startingXFrame, const int& startingYFrame); void processAudioToDoubleMatrix(DoubleMatrix* myDoubleMatrix, DoubleVector* energyVector);
--- a/src/timeWarp.cpp Mon Nov 07 18:08:43 2011 +0000 +++ b/src/timeWarp.cpp Wed Nov 09 18:34:25 2011 +0000 @@ -51,7 +51,7 @@ //matrixPtr.clear(); //chromoGramm.~ChromoGram(); //secondChromoGramm; - + anchorPoints.clear(); } @@ -311,6 +311,12 @@ } +void TimeWarp::addAnchorPoints(const int& startFrameX, const int& startFrameY){ + IntVector v; + v.push_back(startFrameX); + v.push_back(startFrameY); + anchorPoints.push_back(v); +} void TimeWarp::calculateAlignmentMatrix(DoubleMatrix firstMatrix, DoubleMatrix secondMatrix, DoubleMatrix* alignmentMatrix){//, DoubleMatrix simMatrix printf("starting Alignment calculation\n");
--- a/src/timeWarp.h Mon Nov 07 18:08:43 2011 +0000 +++ b/src/timeWarp.h Wed Nov 09 18:34:25 2011 +0000 @@ -69,6 +69,8 @@ IntMatrix partBackwardsAlignmentPath; IntMatrix forwardsAlignmentPath; + IntMatrix anchorPoints; + void addAnchorPoints(const int& startFrameX, const int& startFrameY); int partBackwardsAlignmentIndex;