# HG changeset patch # User maxzanoni76 # Date 1334145237 -3600 # Node ID fa8450e6f5a9f826b3881d874ee868eac80b1f6a # Parent e0ff3b0c7316a89bafa9774a0842d8aa508971cd In this version the corrections at the function beatQuantizer by Matthias has been integrated: the problem about the adding of extra beats is solved diff -r e0ff3b0c7316 -r fa8450e6f5a9 songparts/plugins/SongParts.cpp --- a/songparts/plugins/SongParts.cpp Wed Apr 11 09:58:31 2012 +0100 +++ b/songparts/plugins/SongParts.cpp Wed Apr 11 12:53:57 2012 +0100 @@ -1073,15 +1073,16 @@ /* ------ Beat Quantizer ------ */ -std::vector SongPartitioner::BeatQuantiser(Vamp::Plugin::FeatureList chromagram, Vamp::Plugin::FeatureList beats) +std::vector +SongPartitioner::BeatQuantiser(Vamp::Plugin::FeatureList chromagram, Vamp::Plugin::FeatureList beats) { std::vector returnVector; FeatureList fwQchromagram; // frame-wise beat-quantised chroma FeatureList bwQchromagram; // beat-wise beat-quantised chroma - size_t nChromaFrame = chromagram.size(); - size_t nBeat = beats.size(); + int nChromaFrame = (int) chromagram.size(); + int nBeat = (int) beats.size(); if (nBeat == 0 && nChromaFrame == 0) return returnVector; @@ -1093,15 +1094,23 @@ int currBeatCount = -1; // start before first beat int framesInBeat = 0; - for (size_t iChroma = 0; iChroma < nChromaFrame; ++iChroma) + for (int iChroma = 0; iChroma < nChromaFrame; ++iChroma) { - Vamp::RealTime chromaTimestamp = chromagram[iChroma].timestamp; - if (chromaTimestamp > beats[currBeatCount+1].timestamp || + Vamp::RealTime frameTimestamp = chromagram[iChroma].timestamp; + Vamp::RealTime tempBeatTimestamp; + + 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 - for (size_t 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; @@ -1132,8 +1141,6 @@ returnVector.push_back(bwQchromagram); } - - /* -------------------------------- */ /* ------ Support Functions ------ */ /* -------------------------------- */ @@ -1331,12 +1338,6 @@ int nBeat = quatisedChromagram.size(); // Number of feature vector int nFeatValues = quatisedChromagram[0].values.size(); // Number of values for each feature vector - // ----- TEMP ------ - /*if (nBeat > 255) - nBeat = 255; - std::cout << "CUT THE ERROR BEAT -> " << nBeat << std::endl;*/ - // ----------------- - arma::irowvec timeStamp = arma::zeros(1,nBeat); // Vector of Time Stamps // Save time stamp as a Vector diff -r e0ff3b0c7316 -r fa8450e6f5a9 songparts/plugins/SongParts.o Binary file songparts/plugins/SongParts.o has changed diff -r e0ff3b0c7316 -r fa8450e6f5a9 songparts/qm-vamp-plugins.dylib Binary file songparts/qm-vamp-plugins.dylib has changed