Mercurial > hg > audio-time-warp
changeset 8:166bece5922c
Version that works sequentially with chroma and onset energy, but doesn't use combined matrix, hence more efficient. playing switches okay, bug fixed on path calculation
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Mon, 07 Nov 2011 17:24:52 +0000 |
parents | fc0a8412d6fb |
children | 9adcffbdc16d |
files | src/TimeWarp.cpp src/TimeWarp.h src/testApp.cpp src/testApp.h src/timeWarp.cpp src/timeWarp.h |
diffstat | 6 files changed, 141 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/src/TimeWarp.cpp Fri Nov 04 23:23:13 2011 +0000 +++ b/src/TimeWarp.cpp Mon Nov 07 17:24:52 2011 +0000 @@ -33,7 +33,9 @@ //-------------------------------------------------------------- // destructor TimeWarp :: TimeWarp(){ + diagonalPenalty = 1;//favours diagonal over other paths diagonalPenalty = 2;//penalises diagonal so all path gradients equal weighting + } // destructor @@ -53,10 +55,26 @@ } + + +void TimeWarp::clearVectors(){ + firstEnergyVector.clear(); + secondEnergyVector.clear(); + chromaMatrix.clear(); + secondMatrix.clear(); + similarityMatrix.clear(); + chromaSimilarityMatrix.clear(); + tmpSimilarityMatrix.clear(); + alignmentMeasureMatrix.clear(); + tmpAlignmentMeasureMatrix.clear(); + minimumAlignmentPath.clear(); + partBackwardsAlignmentPath.clear(); +// forwardsAlignmentPath.clear(); + +} void TimeWarp::initialiseVariables(){ - diagonalPenalty = 1;//penalises diagonal so all path gradients equal weighting - + diagonalPenalty = 1; //chromoGramm.initialise(FRAMESIZE,2048);//framesize 512 and hopsize 2048 } @@ -146,7 +164,7 @@ void TimeWarp::calculateSimilarityMatrixWithPointers(DoubleMatrix* firstChromaMatrix, DoubleMatrix* secondChromaMatrix, DoubleMatrix* simMatrix){ printf("Calculate similarity : pointers : size %i x %i ", (int) (*firstChromaMatrix).size(), (int) (*secondChromaMatrix).size()); - (*simMatrix).clear(); + simMatrix->clear(); double distance, firstSum, secondSum; @@ -192,7 +210,7 @@ printf("RUNDED CONVERSION FACTOR IS %i\n", conversionFactor); printf("CHROMA SIM SIZE %i\n", (int) (*chromaSimilarityMatrix).size()); - (*simMatrix).clear(); + simMatrix->clear(); double energyProportion = 0.3; double chromaProportion = 1 - energyProportion; @@ -297,7 +315,8 @@ void TimeWarp::calculateAlignmentMatrix(DoubleMatrix firstMatrix, DoubleMatrix secondMatrix, DoubleMatrix* alignmentMatrix){//, DoubleMatrix simMatrix printf("starting Alignment calculation\n"); //initialise alignment - (*alignmentMatrix).clear(); + alignmentMatrix->clear(); + DoubleVector d; d.push_back(getDistance(0,0)); (*alignmentMatrix).push_back(d); @@ -369,7 +388,7 @@ void TimeWarp::calculatePartSimilarityMatrix(DoubleMatrix* firstChromaMatrix, DoubleMatrix* secondChromaMatrix, DoubleMatrix* simMatrix, int startX, int startY, int endX){ // printf("Calculate similarity : pointers : size %i x %i ", (int) firstChromaMatrix.size(), (int) secondChromaMatrix.size()); - (*simMatrix).clear(); + simMatrix->clear(); double distance, firstSum, secondSum; endX = min (endX, (int)(*firstChromaMatrix).size()-1);//in case out of size @@ -413,7 +432,7 @@ printf("PART SIM CALC Calculate similarity : pointers : size %i x %i ", startX, startY);//(int) (*firstEnergyVector).size(), (int) (*secondEnergyVector).size()); conversionFactor = (int) round((*firstEnergyVector).size() / (*chromaSimMatrix).size() ); - (*simMatrix).clear(); + simMatrix->clear(); double energyProportion = 0.5; double chromaProportion = 1 - energyProportion; @@ -457,7 +476,8 @@ void TimeWarp::calculatePartAlignmentMatrix(int endIndexX, int endIndexY, DoubleMatrix* alignmentMatrix, DoubleMatrix* simMatrix){ printf("starting PART Alignment calculation : sim matrix size %i %i\n", (int)(*simMatrix).size(), (int)(*simMatrix)[0].size()); //initialise alignment - (*alignmentMatrix).clear(); + alignmentMatrix->clear(); + DoubleVector d; d.push_back(getDistanceFromMatrix(0,0, simMatrix)); printf("first distance\n"); @@ -647,8 +667,9 @@ -void TimeWarp::printBackwardsPath(int startIndex, int endIndex, IntMatrix* backPath){ +void TimeWarp::printBackwardsPath(int startIndex, int endIndex, const IntMatrix* backPath){ if (endIndex <= (*backPath)[0].size()){ + printf("size of path is %i by %i\n", (int) (*backPath).size(), (int) (*backPath)[0].size()); for (int i = startIndex;i < endIndex;i++){ printf("Path[%i]:: %i : %i \n", i, (*backPath)[0][i], (*backPath)[1][i]); }
--- a/src/TimeWarp.h Fri Nov 04 23:23:13 2011 +0000 +++ b/src/TimeWarp.h Mon Nov 07 17:24:52 2011 +0000 @@ -17,6 +17,8 @@ #include "sndfile.h" #include "ofxFileDialogOSX.h" +//11/2011 +//what is similarity and what chromaSimilarity? #define FRAMESIZE 512 #define ENERGY_LENGTH 80000 @@ -32,7 +34,7 @@ ~TimeWarp(); void initialiseVariables(); - + void clearVectors(); //variables typedef std::vector<double> DoubleVector; typedef std::vector<DoubleVector> DoubleMatrix; @@ -139,7 +141,7 @@ bool extendRestrictedAlignmentAlong(int endIndexX, DoubleMatrix* alignmentMatrix, DoubleMatrix* simMatrix); - void printBackwardsPath(int startIndex, int endIndex, IntMatrix* backPath); + void printBackwardsPath(int startIndex, int endIndex, const IntMatrix* backPath); void copyForwardsPathToBackwardsPath(); float diagonalPenalty;
--- a/src/testApp.cpp Fri Nov 04 23:23:13 2011 +0000 +++ b/src/testApp.cpp Mon Nov 07 17:24:52 2011 +0000 @@ -122,7 +122,6 @@ calculateSimilarityAndAlignment(); - printf("\n gettem hereafter!"); //set not to play audioPlaying = false; @@ -139,9 +138,11 @@ } + void testApp::calculateSimilarityAndAlignment(){ + //here is the main TimeWarp similarity matrix calc, the minimum alignment matrix via dtw and then the backwards path estimate double timeBefore = ofGetElapsedTimef(); tw.calculateChromaSimilarityMatrix(&tw.chromaMatrix, &tw.secondMatrix, &tw.chromaSimilarityMatrix); @@ -166,7 +167,7 @@ // tw.calculateAlignmentMatrix(tw.firstChromaEnergyMatrix, tw.secondChromaEnergyMatrix, &tw.alignmentMeasureMatrix); // tw.calculateMinimumAlignmentPath(&tw.alignmentMeasureMatrix, &tw.backwardsAlignmentPath, false); - + tw.forwardsAlignmentPath.clear(); //causal part int hopsize = 200; int frameSize = 400; @@ -184,7 +185,8 @@ //NEW FUNCTION - calls only the energy and uses the stored chromagram tw.calculatePartJointSimilarityMatrix(&tw.firstEnergyVector, &tw.secondEnergyVector, &tw.chromaSimilarityMatrix, &tw.tmpSimilarityMatrix, startFrameX, startFrameY, startFrameX+frameSize); - + + printf("TMP size of tmp sim is %i\n", (int)tw.tmpSimilarityMatrix.size()); elapsedTime = ofGetElapsedTimef() - timeBefore; @@ -196,6 +198,7 @@ //check if we can not calculate alignment matrix for chunks of the sim matrix where it is off diagonal tw.calculatePartAlignmentMatrix(tw.tmpSimilarityMatrix.size()-1, tw.tmpSimilarityMatrix[0].size()-1, &tw.tmpAlignmentMeasureMatrix, &tw.tmpSimilarityMatrix); + //get alignment measure minimum //find minimum path between only the section we are interested in //write new function to find minimum backwards path from the index we choose (not the final corner) @@ -212,6 +215,8 @@ printf("forwards path printed\n"); startFrameY = tw.forwardsAlignmentPath[1][(tw.forwardsAlignmentPath[0].size()-1)]; + + tw.printBackwardsPath(0, tw.forwardsAlignmentPath[0].size(), &tw.forwardsAlignmentPath); //pushSimCode()? }//end for startFrameX @@ -225,6 +230,8 @@ // 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()); 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); @@ -240,6 +247,7 @@ printf("backwards path size is [0]:%i, [1]%i, \n", (int)tw.backwardsAlignmentPath[0].size(), (int)tw.backwardsAlignmentPath[1].size()); printf("backwards path size is %i, FORWARDS SIZE IS %i\n", (int)tw.backwardsAlignmentPath[0].size(), (int)tw.forwardsAlignmentPath[0].size()); + printf("BACKWARDS PATH::\n"); tw.printBackwardsPath(0, (int)tw.backwardsAlignmentPath[0].size(), &tw.backwardsAlignmentPath); } @@ -259,6 +267,7 @@ audioPaused = true; tw.initialiseVariables(); + } @@ -272,12 +281,13 @@ // chordString = "Chord : "; // chordString += ofToString(rootChord[currentPlayingFrame/conversionFactor]);//CHROMA_CONVERSION_FACTOR]); + audioPosition = (*playingAudio).getPosition(); if (firstAudioFilePlaying){ - audioPosition = (*playingAudio).getPosition() * tw.firstEnergyVector.size(); + audioPosition *= tw.firstEnergyVector.size(); updateAlignmentPathIndex(0); } else { - audioPosition = (*playingAudio).getPosition() * tw.secondEnergyVector.size(); + audioPosition *= tw.secondEnergyVector.size(); updateAlignmentPathIndex(1); } @@ -299,7 +309,7 @@ if (tw.backwardsAlignmentPath.size() > 0){ //this is the alignment where we are currently playing - i.e. switching between files - int chromaPosition = audioPosition/conversionFactor;//CHROMA_CONVERSION_FACTOR; + int chromaPosition = audioPosition;///conversionFactor;//CHROMA_CONVERSION_FACTOR; while (tw.backwardsAlignmentPath[identifier][backwardsAlignmentIndex] < chromaPosition) { @@ -485,19 +495,19 @@ int startingXframe = tw.chromaSimilarityMatrix.size() / (scrollWidth/conversionFactor); int startingYframe = tw.chromaSimilarityMatrix[0].size() / (scrollWidth/conversionFactor); -// printf("DRAW SIM SIZE %i x %i \n", startingXframe, startingYframe); + if (tw.backwardsAlignmentPath.size() > 0){ startingXframe = tw.backwardsAlignmentPath[0][backwardsAlignmentIndex] / (scrollWidth/conversionFactor); startingYframe = tw.backwardsAlignmentPath[1][backwardsAlignmentIndex] / (scrollWidth/conversionFactor); -// printf("VERSUS DRAW SIM SIZE %i x %i \n", startingXframe, startingYframe); } - - - int startingFrame = findStartWidthFrame(); - startingFrame = numberOfScrollWidthsForFirstFile * scrollWidth/conversionFactor; - + startingXframe = startingXframe * scrollWidth/conversionFactor; startingYframe = startingYframe * scrollWidth/conversionFactor; + +// int startingFrame = findStartWidthFrame(); +// startingFrame = numberOfScrollWidthsForFirstFile * scrollWidth/conversionFactor; + + //need to fix for second file too int *indexOfAlignmentPathTested; @@ -555,8 +565,8 @@ textString += " height : "; textString += ofToString(simHeight); - textString += " startframe : "; - textString += ofToString(startingFrame); +// textString += " startframe : "; +// textString += ofToString(startingFrame); textString += " Xframe : "; textString += ofToString(startingXframe); @@ -613,21 +623,24 @@ //frames needed in energy still //in chromagram frames int startingXframe = (tw.firstEnergyVector.size() / scrollWidth); - int startingYframe = (tw.secondMatrix.size() / scrollWidth); + int startingYframe = (tw.secondEnergyVector.size() / scrollWidth);//secondMatrix // printf("DRAW SIM SIZE start frames %i x %i \n", startingXframe, startingYframe); - if (tw.backwardsAlignmentPath.size() > 0){ - startingXframe = (tw.backwardsAlignmentPath[0][backwardsAlignmentIndex]*conversionFactor / scrollWidth); - startingYframe = min(1, (tw.backwardsAlignmentPath[1][backwardsAlignmentIndex]*conversionFactor / scrollWidth)); + if (tw.backwardsAlignmentPath.size() > 0 ){ + startingXframe = (tw.backwardsAlignmentPath[0][backwardsAlignmentIndex]/ scrollWidth); + startingYframe = max(0, (int)(tw.backwardsAlignmentPath[1][backwardsAlignmentIndex]/ scrollWidth));//*conversionFactor //FIX THE 1 - ASDDED AS DEBUG // printf("alignment index %i, VERSUS DRAW SIM SIZE %i x %i \n", backwardsAlignmentIndex, startingXframe, startingYframe); } //PROBLEM IS THAT THE y value startYframe is not correctly incremented + //tmp +// startingXframe = 0; +// startingYframe = 0; - int startingFrame = findStartWidthFrame(); - startingFrame = numberOfScrollWidthsForFirstFile * scrollWidth/conversionFactor; +// int startingFrame = findStartWidthFrame(); +// startingFrame = numberOfScrollWidthsForFirstFile * scrollWidth/conversionFactor; startingXframe *= scrollWidth;// /conversionFactor; startingYframe *= scrollWidth;// /conversionFactor; @@ -684,6 +697,7 @@ ofSetColor(0,255,255); // drawAlignmentPath(startingXframe, startingYframe, &tw.tmpBackwardsPath); + drawForwardsAlignmentPathOnChromaSimilarity(startingXframe, startingYframe); @@ -697,8 +711,8 @@ textString += " height : "; textString += ofToString(simHeight); */ - textString += " startframe : "; - textString += ofToString(startingFrame); +// textString += " startframe : "; +// textString += ofToString(startingFrame); textString += " Xframe : "; textString += ofToString(startingXframe); @@ -781,10 +795,11 @@ int testApp::findStartWidthFrame(){ int startingFrame; + /* startingFrame = currentPlayingFrame / scrollWidth;//i.e. number of scroll widths in startingFrame *= scrollWidth;//starting frame in terms of energy frames startingFrame /= conversionFactor;// CHROMA_CONVERSION_FACTOR; - +*/ return startingFrame; } @@ -1159,6 +1174,8 @@ } if (key == 'o'){ + tw.clearVectors(); + openNewAudioFileWithdialogBox(); } @@ -1174,10 +1191,20 @@ loadSecondAudio(secondFileName); + initialiseVariables(); + backwardsAlignmentIndex = 0; + calculateSimilarityAndAlignment(); + + } + if (key == 'r'){ + tw.printBackwardsPath(0, (int) tw.forwardsAlignmentPath[0].size(), &tw.forwardsAlignmentPath); + } + + if (key == 's'){ drawSimilarity = !drawSimilarity; } @@ -1375,13 +1402,14 @@ } - void testApp::swapBetweenPlayingFilesUsingAlignmentMatch(){ + float tmpConvFac = conversionFactor; + conversionFactor = 1.0; ofSoundUpdate(); //swapping between files - //printf("current playing (energy scale) frame was %i \n", currentPlayingFrame); + //printf("current playing (energy scale) frame was %i \n", currentPlayingFrame); float oldPosition = (*playingAudio).getPosition(); - printf("playing position is %f \n", (*playingAudio).getPosition()); + printf("\n playing position is %f and c onv factor %f \n", (*playingAudio).getPosition(), conversionFactor); //(*playingAudio).stop(); (*playingAudio).setPaused(true); @@ -1395,12 +1423,13 @@ newIndicator = 0; } - printf("new indicator %i \n", newIndicator); + //printf("new indicator %i \n", newIndicator); printf("playing pos according to energy frames is %f \n ", - (currentPlayingFrame/((float)tw.backwardsAlignmentPath[1-newIndicator][0]* conversionFactor)) );//CHROMA_CONVERSION_FACTOR + (currentPlayingFrame/((float)tw.backwardsAlignmentPath[1-newIndicator][0])) );//* conversionFactor)) );//CHROMA_CONVERSION_FACTOR printf("predicts frame to be %f \n", (oldPosition*tw.backwardsAlignmentPath[1-newIndicator][0])); - currentChromaFrame = oldPosition * (float) tw.backwardsAlignmentPath[1-newIndicator][0]; +// currentChromaFrame = oldPosition * (float) tw.backwardsAlignmentPath[1-newIndicator][0]; + currentChromaFrame = currentPlayingFrame;// / conversionFactor; printf("current chroma frame %i and using energy frames would have been %i \n", currentChromaFrame, currentPlayingFrame / conversionFactor);//CHROMA_CONVERSION_FACTOR); int matchingFrame = findMatchFromAlignment(firstAudioFilePlaying); @@ -1415,7 +1444,7 @@ firstAudioFilePlaying = !firstAudioFilePlaying; - + conversionFactor = tmpConvFac; } int testApp::findMatchFromAlignment(bool whichFileToTest){ @@ -1470,25 +1499,26 @@ } -void testApp::printAlignmentMatrix(){ + +void testApp::printAlignmentMatrix(const DoubleMatrix& alignmentMatrix){ - int size = tw.alignmentMeasureMatrix.size(); + int size = alignmentMatrix.size(); printf("\n _ _ _ _\n"); printf("align size is %i \n", size); int i,j; DoubleVector d; - int rowSize = tw.alignmentMeasureMatrix.size(); - d = tw.alignmentMeasureMatrix[0];//choose initial size + int rowSize = alignmentMatrix.size(); + d = alignmentMatrix[0];//choose initial size for (int j = 0;j < d.size();j++){ printf("row %i : ", j); for (i = 0;i < rowSize;i++){ - d = tw.alignmentMeasureMatrix[i]; + d = alignmentMatrix[i]; // printf("row %i , col %i, val : %f \n", i, j, alignmentMeasureMatrix[i][j] ); - printf("%f , ", tw.alignmentMeasureMatrix[i][j] ); + printf("%f , ", alignmentMatrix[i][j] ); } printf("\n"); }
--- a/src/testApp.h Fri Nov 04 23:23:13 2011 +0000 +++ b/src/testApp.h Mon Nov 07 17:24:52 2011 +0000 @@ -49,7 +49,9 @@ void loadFirstAudioFile(); void initialiseVariables(); - + + void clearVectors(); + void calculateSimilarityAndAlignment(); typedef std::vector<double> DoubleVector; @@ -57,9 +59,7 @@ typedef std::vector<int> IntVector; typedef std::vector<IntVector> IntMatrix; - -// DoubleMatrix chromaMatrix; -// DoubleMatrix secondMatrix; + DoubleMatrix* matrixPtr; void drawDoubleMatrix(DoubleMatrix* dMatrix);//DoubleMatrix* dMatrix); WOULD BE NICE TO USE POINTER BUT NOT WORKING YET @@ -108,7 +108,7 @@ void calculateAlignmentMatrix(); // void performNextAlignment(); double getDistance(int i, int j); - void printAlignmentMatrix(); + void printAlignmentMatrix(const DoubleMatrix& alignmentMatrix); double getMinimum(int i, int j, float newValue); bool extendAlignmentUp(); bool extendAlignmentAlong(); @@ -202,7 +202,7 @@ Chromagram chromaG; OnsetDetectionFunction* onset; - int conversionFactor; + float conversionFactor; }; #endif
--- a/src/timeWarp.cpp Fri Nov 04 23:23:13 2011 +0000 +++ b/src/timeWarp.cpp Mon Nov 07 17:24:52 2011 +0000 @@ -33,7 +33,9 @@ //-------------------------------------------------------------- // destructor TimeWarp :: TimeWarp(){ + diagonalPenalty = 1;//favours diagonal over other paths diagonalPenalty = 2;//penalises diagonal so all path gradients equal weighting + } // destructor @@ -53,10 +55,26 @@ } + + +void TimeWarp::clearVectors(){ + firstEnergyVector.clear(); + secondEnergyVector.clear(); + chromaMatrix.clear(); + secondMatrix.clear(); + similarityMatrix.clear(); + chromaSimilarityMatrix.clear(); + tmpSimilarityMatrix.clear(); + alignmentMeasureMatrix.clear(); + tmpAlignmentMeasureMatrix.clear(); + minimumAlignmentPath.clear(); + partBackwardsAlignmentPath.clear(); +// forwardsAlignmentPath.clear(); + +} void TimeWarp::initialiseVariables(){ - diagonalPenalty = 1;//penalises diagonal so all path gradients equal weighting - + diagonalPenalty = 1; //chromoGramm.initialise(FRAMESIZE,2048);//framesize 512 and hopsize 2048 } @@ -146,7 +164,7 @@ void TimeWarp::calculateSimilarityMatrixWithPointers(DoubleMatrix* firstChromaMatrix, DoubleMatrix* secondChromaMatrix, DoubleMatrix* simMatrix){ printf("Calculate similarity : pointers : size %i x %i ", (int) (*firstChromaMatrix).size(), (int) (*secondChromaMatrix).size()); - (*simMatrix).clear(); + simMatrix->clear(); double distance, firstSum, secondSum; @@ -192,7 +210,7 @@ printf("RUNDED CONVERSION FACTOR IS %i\n", conversionFactor); printf("CHROMA SIM SIZE %i\n", (int) (*chromaSimilarityMatrix).size()); - (*simMatrix).clear(); + simMatrix->clear(); double energyProportion = 0.3; double chromaProportion = 1 - energyProportion; @@ -297,7 +315,8 @@ void TimeWarp::calculateAlignmentMatrix(DoubleMatrix firstMatrix, DoubleMatrix secondMatrix, DoubleMatrix* alignmentMatrix){//, DoubleMatrix simMatrix printf("starting Alignment calculation\n"); //initialise alignment - (*alignmentMatrix).clear(); + alignmentMatrix->clear(); + DoubleVector d; d.push_back(getDistance(0,0)); (*alignmentMatrix).push_back(d); @@ -369,7 +388,7 @@ void TimeWarp::calculatePartSimilarityMatrix(DoubleMatrix* firstChromaMatrix, DoubleMatrix* secondChromaMatrix, DoubleMatrix* simMatrix, int startX, int startY, int endX){ // printf("Calculate similarity : pointers : size %i x %i ", (int) firstChromaMatrix.size(), (int) secondChromaMatrix.size()); - (*simMatrix).clear(); + simMatrix->clear(); double distance, firstSum, secondSum; endX = min (endX, (int)(*firstChromaMatrix).size()-1);//in case out of size @@ -413,7 +432,7 @@ printf("PART SIM CALC Calculate similarity : pointers : size %i x %i ", startX, startY);//(int) (*firstEnergyVector).size(), (int) (*secondEnergyVector).size()); conversionFactor = (int) round((*firstEnergyVector).size() / (*chromaSimMatrix).size() ); - (*simMatrix).clear(); + simMatrix->clear(); double energyProportion = 0.5; double chromaProportion = 1 - energyProportion; @@ -457,7 +476,8 @@ void TimeWarp::calculatePartAlignmentMatrix(int endIndexX, int endIndexY, DoubleMatrix* alignmentMatrix, DoubleMatrix* simMatrix){ printf("starting PART Alignment calculation : sim matrix size %i %i\n", (int)(*simMatrix).size(), (int)(*simMatrix)[0].size()); //initialise alignment - (*alignmentMatrix).clear(); + alignmentMatrix->clear(); + DoubleVector d; d.push_back(getDistanceFromMatrix(0,0, simMatrix)); printf("first distance\n"); @@ -647,8 +667,9 @@ -void TimeWarp::printBackwardsPath(int startIndex, int endIndex, IntMatrix* backPath){ +void TimeWarp::printBackwardsPath(int startIndex, int endIndex, const IntMatrix* backPath){ if (endIndex <= (*backPath)[0].size()){ + printf("size of path is %i by %i\n", (int) (*backPath).size(), (int) (*backPath)[0].size()); for (int i = startIndex;i < endIndex;i++){ printf("Path[%i]:: %i : %i \n", i, (*backPath)[0][i], (*backPath)[1][i]); }
--- a/src/timeWarp.h Fri Nov 04 23:23:13 2011 +0000 +++ b/src/timeWarp.h Mon Nov 07 17:24:52 2011 +0000 @@ -17,6 +17,8 @@ #include "sndfile.h" #include "ofxFileDialogOSX.h" +//11/2011 +//what is similarity and what chromaSimilarity? #define FRAMESIZE 512 #define ENERGY_LENGTH 80000 @@ -32,7 +34,7 @@ ~TimeWarp(); void initialiseVariables(); - + void clearVectors(); //variables typedef std::vector<double> DoubleVector; typedef std::vector<DoubleVector> DoubleMatrix; @@ -139,7 +141,7 @@ bool extendRestrictedAlignmentAlong(int endIndexX, DoubleMatrix* alignmentMatrix, DoubleMatrix* simMatrix); - void printBackwardsPath(int startIndex, int endIndex, IntMatrix* backPath); + void printBackwardsPath(int startIndex, int endIndex, const IntMatrix* backPath); void copyForwardsPathToBackwardsPath(); float diagonalPenalty;