# HG changeset patch # User Chris Cannam # Date 1336647092 -3600 # Node ID cb9003bb0251e983704e6b08800c686272e2198a # Parent d28d79fe22b33deb50134878158ae803baa46966 Fix invalid accesses off both ends of the beats array diff -r d28d79fe22b3 -r cb9003bb0251 songparts/SongParts.cpp --- 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; } diff -r d28d79fe22b3 -r cb9003bb0251 songparts/SongParts.o Binary file songparts/SongParts.o has changed