Mercurial > hg > match-vamp
changeset 13:66082cc488c3
Pull out total energies into a separate vector (so that the frame vectors only contain the real features)
author | Chris Cannam |
---|---|
date | Fri, 10 Oct 2014 10:52:07 +0100 |
parents | a9378af18d98 |
children | cdead4a52755 |
files | Matcher.cpp Matcher.h |
diffstat | 2 files changed, 17 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/Matcher.cpp Fri Oct 10 10:51:49 2014 +0100 +++ b/Matcher.cpp Fri Oct 10 10:52:07 2014 +0100 @@ -137,7 +137,8 @@ initVector<double>(prevFrame, freqMapSize); initVector<double>(newFrame, freqMapSize); - initMatrix<double>(frames, blockSize, freqMapSize + 1); + initMatrix<double>(frames, blockSize, freqMapSize); + initVector<double>(totalEnergies, blockSize); int distSize = (MAX_RUN_COUNT + 1) * blockSize; @@ -314,7 +315,7 @@ totalEnergy += frames[frameIndex][i]; } } - frames[frameIndex][freqMapSize] = totalEnergy; + totalEnergies[frameIndex] = totalEnergy; double decay = frameCount >= 200 ? 0.99: (frameCount < 100? 0: (frameCount - 100) / 100.0); @@ -449,7 +450,12 @@ return (int)(scale * d / sum); // 0 <= d/sum <= 2 if (!normalise4) return (int)(scale * d); + + // note if this were to be restored, it would have to use + // totalEnergies vector instead of f1[freqMapSize] which used to + // store the total energy: // double weight = (5 + Math.log(f1[freqMapSize] + f2[freqMapSize]))/10.0; + double weight = (8 + log(sum)) / 10.0; // if (weight < mins) { // mins = weight;
--- a/Matcher.h Fri Oct 10 10:51:49 2014 +0100 +++ b/Matcher.h Fri Oct 10 10:52:07 2014 +0100 @@ -165,17 +165,23 @@ int freqMapSize; /** The most recent frame; used for calculating the frame to frame - * spectral difference. */ + * spectral difference. These are therefore frequency warped but + * not yet normalised. */ vector<double> prevFrame; vector<double> newFrame; /** A block of previously seen frames are stored in this structure * for calculation of the distance matrix as the new frames are * read in. One can think of the structure of the array as a - * circular buffer of vectors. The last element of each vector - * stores the total energy. */ + * circular buffer of vectors. These are the frames with all + * applicable processing applied (e.g. spectral difference, + * normalisation), unlike prevFrame and newFrame. The total + * energy of frames[i] is stored in totalEnergies[i]. */ vector<vector<double> > frames; + /** The total energy of each frame in the frames block. */ + vector<double> totalEnergies; + /** The best path cost matrix. */ int **bestPathCost;