Mercurial > hg > segmenter-vamp-plugin
changeset 23:cb9003bb0251 slimline
Fix invalid accesses off both ends of the beats array
author | Chris Cannam |
---|---|
date | Thu, 10 May 2012 11:51:32 +0100 |
parents | d28d79fe22b3 |
children | 9e496d4732a7 |
files | songparts/SongParts.cpp songparts/SongParts.o |
diffstat | 2 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/songparts/SongParts.cpp Thu May 10 10:52:41 2012 +0100 +++ b/songparts/SongParts.cpp Thu May 10 11:51:32 2012 +0100 @@ -340,7 +340,7 @@ countNonzero++; } kernelFftIndex.push_back(iFFT); - kernelNoteIndex.push_back(iNote); + kernelNoteIndex.push_back(iNote); } } } @@ -1099,26 +1099,26 @@ for (int iChroma = 0; iChroma < nChromaFrame; ++iChroma) { Vamp::RealTime frameTimestamp = chromagram[iChroma].timestamp; - Vamp::RealTime tempBeatTimestamp; + Vamp::RealTime tempBeatTimestamp; - if (currBeatCount != beats.size()-1) tempBeatTimestamp = beats[currBeatCount+1].timestamp; - else tempBeatTimestamp = chromagram[nChromaFrame-1].timestamp; + if (currBeatCount != beats.size()-1) tempBeatTimestamp = beats[currBeatCount+1].timestamp; + else tempBeatTimestamp = chromagram[nChromaFrame-1].timestamp; if (frameTimestamp > tempBeatTimestamp || iChroma == nChromaFrame-1) { // new beat (or last chroma frame) // 1. finish all the old beat processing - if (framesInBeat > 0) - { - for (int i = 0; i < nBin; ++i) tempChroma[i] /= framesInBeat; // average - } + if (framesInBeat > 0) + { + for (int i = 0; i < nBin; ++i) tempChroma[i] /= framesInBeat; // average + } Feature bwQchromaFrame; bwQchromaFrame.hasTimestamp = true; bwQchromaFrame.timestamp = beatTimestamp; bwQchromaFrame.values = tempChroma; - bwQchromaFrame.duration = beats[currBeatCount+1].timestamp - beats[currBeatCount].timestamp; + bwQchromaFrame.duration = tempBeatTimestamp - beatTimestamp; bwQchromagram.push_back(bwQchromaFrame); for (int iFrame = -framesInBeat; iFrame < 0; ++iFrame) @@ -1132,7 +1132,7 @@ // 2. increments / resets for current (new) beat currBeatCount++; - beatTimestamp = beats[currBeatCount].timestamp; + beatTimestamp = tempBeatTimestamp; for (size_t i = 0; i < nBin; ++i) tempChroma[i] = 0; // average framesInBeat = 0; }