Mercurial > hg > audio-time-warp
changeset 12:13c19fe83301
Causal version working with large files too, anchor points shown in white.
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Tue, 22 Nov 2011 17:37:45 +0000 |
parents | 68e7b61744b6 |
children | a3d797046ea8 |
files | src/TimeWarp.cpp src/testApp.cpp src/testApp.h src/timeWarp.cpp |
diffstat | 4 files changed, 56 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/TimeWarp.cpp Thu Nov 10 17:31:05 2011 +0000 +++ b/src/TimeWarp.cpp Tue Nov 22 17:37:45 2011 +0000 @@ -207,8 +207,8 @@ conversionFactor = (int) round((*energyVectorOne).size() / (*chromaSimilarityMatrix).size() ); - printf("RUNDED CONVERSION FACTOR IS %i\n", conversionFactor); - printf("CHROMA SIM SIZE %i\n", (int) (*chromaSimilarityMatrix).size()); + printf("tw.ROUNDED CONVERSION FACTOR IS %i\n", conversionFactor); + printf("tw.CHROMA SIM SIZE %i\n", (int) (*chromaSimilarityMatrix).size()); simMatrix->clear(); @@ -217,6 +217,8 @@ double distance, firstSum, secondSum; + //lets try not actually doing calculation + for (int x = 0;x < (*energyVectorOne).size();x++){ DoubleVector d; @@ -247,8 +249,10 @@ (*simMatrix).push_back(d); }//end for x - - printf("..sim size: %i, height: %i \n", (int) (*simMatrix).size(), (int) (*simMatrix)[0].size()); + + printf("..sim size: %i, height: %i \n", (int) (*simMatrix).size(), (int) (*simMatrix)[0].size()); + + }
--- a/src/testApp.cpp Thu Nov 10 17:31:05 2011 +0000 +++ b/src/testApp.cpp Tue Nov 22 17:37:45 2011 +0000 @@ -148,26 +148,10 @@ double timeBefore = ofGetElapsedTimef(); tw.calculateChromaSimilarityMatrix(&tw.chromaMatrix, &tw.secondMatrix, &tw.chromaSimilarityMatrix); double elapsedTime = ofGetElapsedTimef() - timeBefore; - printf("CHROMA SIMILARITY ONLY TAKES %f\n", elapsedTime); + printf("CHROMA SIMILARITY ONLY TAKES %2.2f seconds\n", elapsedTime); - timeBefore = ofGetElapsedTimef(); - tw.calculateJointSimilarityMatrix(&tw.firstEnergyVector, &tw.secondEnergyVector, &tw.chromaSimilarityMatrix, &tw.similarityMatrix); - elapsedTime = ofGetElapsedTimef() - timeBefore; - printf("JOINT SIMILARITY TAKES %f\n", elapsedTime); - //this has been replaced by the joint function + dontDoJunkAlignment(); - // the big similarity measure - //timeBefore = ofGetElapsedTimef(); - //tw.calculateSimilarityMatrixWithPointers(&tw.firstChromaEnergyMatrix, &tw.secondChromaEnergyMatrix, &tw.similarityMatrix); - //elapsedTime = ofGetElapsedTimef() - timeBefore; - //printf("CREATING BIG SIMILARITY MATRIX TAKES %f\n", elapsedTime); - //bug is here above - needed to make sim matrix visible - - //new fn -// tw.calculateSimilarityMatrixFromChromagramAndEnergy(&tw.firstEnergyVector, &tw.chromaMatrix, &tw.secondEnergyVector, tw.secondMatrix, &tw.similarityMatrix); -// tw.calculateAlignmentMatrix(tw.firstChromaEnergyMatrix, tw.secondChromaEnergyMatrix, &tw.alignmentMeasureMatrix); -// tw.calculateMinimumAlignmentPath(&tw.alignmentMeasureMatrix, &tw.backwardsAlignmentPath, false); - tw.forwardsAlignmentPath.clear(); //causal part int hopsize = 200; @@ -229,19 +213,19 @@ // tw.calculatePartMinimumAlignmentPath(0, 0, 100, 100, &tw.partAlignmentMeasureMatrix); - printf("ENERGY SIZE:%i, SIM SIZE:%i\n",(int)tw.firstEnergyVector.size(), (int)tw.similarityMatrix.size()); + // conversionFactor = (int)round((tw.firstEnergyVector.size() / tw.similarityMatrix.size())); - printf("SIM SIZE%i, chrom size %ix%i\n", tw.similarityMatrix.size(), tw.chromaMatrix.size(), tw.chromaMatrix[0].size()); + printf("large SIM SIZE%i, chrom size %ix%i\n", tw.similarityMatrix.size(), tw.chromaMatrix.size(), tw.chromaMatrix[0].size()); conversionFactor = (int) round(tw.firstEnergyVector.size() / tw.chromaMatrix.size()); chromaConversionRatio = (int) round(tw.firstEnergyVector.size() / tw.chromaMatrix.size()); //conversionFactor = 1.0;//since we are using onset level matching chromoLength = scrollWidth / (float)conversionFactor;// CHROMA_CONVERSION_FACTOR; printf("scrollwidth %i, conversion factor %i, chromo length %i\n", scrollWidth, (int)conversionFactor, (int)chromoLength); - + if (tw.similarityMatrix.size() > 0 && tw.chromaSimilarityMatrix.size() > 0){ printf("SIM SIZE %i, and %i \n",(int) tw.similarityMatrix.size(), (int) tw.similarityMatrix[0].size()); printf("chomra sim size %i, and %i\n", (int) tw.chromaSimilarityMatrix.size(), tw.chromaSimilarityMatrix[0].size()); - + } tw.copyForwardsPathToBackwardsPath(); //tw.printBackwardsPath(0, tw.forwardsAlignmentPath[0].size()-1, &tw.forwardsAlignmentPath); @@ -919,9 +903,10 @@ } int xcoord; +//replacing tw.similarityMatrix.size() by first e vec below while (index < tw.forwardsAlignmentPath[0].size() && tw.forwardsAlignmentPath[0][index] < endingChromaXFrame) { - xcoord = min((int)(tw.similarityMatrix.size())-1,tw.forwardsAlignmentPath[0][index]); + xcoord = min((int)(tw.firstEnergyVector.size())-1,tw.forwardsAlignmentPath[0][index]); int ycoord = (int)tw.forwardsAlignmentPath[1][index]; if (tw.alignmentMeasureMatrix.size() > 0) @@ -970,9 +955,9 @@ } int xcoord; - + //replacing tw.similarityMatrix.size() by fiorst e vec while (index < tw.forwardsAlignmentPath[0].size() && tw.forwardsAlignmentPath[0][index] < endingChromaXFrame) { - xcoord = min((int)(tw.similarityMatrix.size())-1,tw.forwardsAlignmentPath[0][index]); + xcoord = min((int)(tw.firstEnergyVector.size())-1,tw.forwardsAlignmentPath[0][index]); int ycoord = (int)tw.forwardsAlignmentPath[1][index]; if (tw.alignmentMeasureMatrix.size() > 0) @@ -1015,7 +1000,7 @@ int xcoord; while (index < tw.anchorPoints.size() && tw.anchorPoints[index][0] < endingChromaXFrame) { - xcoord = min((int)(tw.similarityMatrix.size())-1,tw.anchorPoints[index][0]); + xcoord = min((int)(tw.firstEnergyVector.size())-1,tw.anchorPoints[index][0]); int ycoord = (int)tw.anchorPoints[index][1]; if (tw.alignmentMeasureMatrix.size() > 0) @@ -1616,7 +1601,33 @@ - +void testApp::dontDoJunkAlignment(){ + + if (1 == 2){ + //dont do joint as matrix is too large - energyvec x energyvec + //needs doing in parts + double timeBefore = ofGetElapsedTimef(); + tw.calculateJointSimilarityMatrix(&tw.firstEnergyVector, &tw.secondEnergyVector, &tw.chromaSimilarityMatrix, &tw.similarityMatrix); + double elapsedTime = ofGetElapsedTimef() - timeBefore; + printf("JOINT SIMILARITY TAKES %6.2f seconds\n", elapsedTime); + //this has been replaced by the joint function + } + + + + // the big similarity measure + //timeBefore = ofGetElapsedTimef(); + //tw.calculateSimilarityMatrixWithPointers(&tw.firstChromaEnergyMatrix, &tw.secondChromaEnergyMatrix, &tw.similarityMatrix); + //elapsedTime = ofGetElapsedTimef() - timeBefore; + //printf("CREATING BIG SIMILARITY MATRIX TAKES %f\n", elapsedTime); + //bug is here above - needed to make sim matrix visible + + //new fn + // tw.calculateSimilarityMatrixFromChromagramAndEnergy(&tw.firstEnergyVector, &tw.chromaMatrix, &tw.secondEnergyVector, tw.secondMatrix, &tw.similarityMatrix); + // tw.calculateAlignmentMatrix(tw.firstChromaEnergyMatrix, tw.secondChromaEnergyMatrix, &tw.alignmentMeasureMatrix); + // tw.calculateMinimumAlignmentPath(&tw.alignmentMeasureMatrix, &tw.backwardsAlignmentPath, false); + +}
--- a/src/testApp.h Thu Nov 10 17:31:05 2011 +0000 +++ b/src/testApp.h Tue Nov 22 17:37:45 2011 +0000 @@ -204,6 +204,8 @@ OnsetDetectionFunction* onset; float conversionFactor; + + void dontDoJunkAlignment(); }; #endif
--- a/src/timeWarp.cpp Thu Nov 10 17:31:05 2011 +0000 +++ b/src/timeWarp.cpp Tue Nov 22 17:37:45 2011 +0000 @@ -207,8 +207,8 @@ conversionFactor = (int) round((*energyVectorOne).size() / (*chromaSimilarityMatrix).size() ); - printf("RUNDED CONVERSION FACTOR IS %i\n", conversionFactor); - printf("CHROMA SIM SIZE %i\n", (int) (*chromaSimilarityMatrix).size()); + printf("tw.ROUNDED CONVERSION FACTOR IS %i\n", conversionFactor); + printf("tw.CHROMA SIM SIZE %i\n", (int) (*chromaSimilarityMatrix).size()); simMatrix->clear(); @@ -217,6 +217,8 @@ double distance, firstSum, secondSum; + //lets try not actually doing calculation + for (int x = 0;x < (*energyVectorOne).size();x++){ DoubleVector d; @@ -247,8 +249,10 @@ (*simMatrix).push_back(d); }//end for x - - printf("..sim size: %i, height: %i \n", (int) (*simMatrix).size(), (int) (*simMatrix)[0].size()); + + printf("..sim size: %i, height: %i \n", (int) (*simMatrix).size(), (int) (*simMatrix)[0].size()); + + }