Mercurial > hg > beatroot-vamp
changeset 22:6afcb5edd7ab
Fix compiler warnings, etc
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2013 16:50:40 +0100 |
parents | d98bc465a116 |
children | 633ec097fa56 |
files | Agent.h AgentList.cpp BeatRootProcessor.cpp BeatRootProcessor.h BeatRootVampPlugin.cpp Peaks.cpp |
diffstat | 6 files changed, 34 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/Agent.h Wed Aug 28 16:50:22 2013 +0100 +++ b/Agent.h Wed Aug 28 16:50:40 2013 +0100 @@ -182,11 +182,6 @@ */ void fillBeats(double start); - // for sorting AgentList - bool operator<(const Agent &a) const { - return beatInterval < a.beatInterval; - } - }; // class Agent #endif
--- a/AgentList.cpp Wed Aug 28 16:50:22 2013 +0100 +++ b/AgentList.cpp Wed Aug 28 16:50:40 2013 +0100 @@ -23,6 +23,9 @@ { sort(); for (iterator itr = begin(); itr != end(); ++itr) { +#ifdef DEBUG_BEATROOT + std::cerr << "removeDuplicates: considering agent " << (*itr)->idNumber << std::endl; +#endif if ((*itr)->phaseScore < 0.0) // already flagged for deletion continue; iterator itr2 = itr; @@ -32,11 +35,17 @@ if (fabs((*itr)->beatTime - (*itr2)->beatTime) > DEFAULT_BT) continue; if ((*itr)->phaseScore < (*itr2)->phaseScore) { +#ifdef DEBUG_BEATROOT + std::cerr << "agent " << (*itr)->idNumber << " is similar to but lower-scoring than agent " << (*itr2)->idNumber << ", marking for deletion" << std::endl; +#endif (*itr)->phaseScore = -1.0; // flag for deletion if ((*itr2)->topScoreTime < (*itr)->topScoreTime) (*itr2)->topScoreTime = (*itr)->topScoreTime; break; } else { +#ifdef DEBUG_BEATROOT + std::cerr << "agent " << (*itr2)->idNumber << " is similar to but lower-scoring than agent " << (*itr)->idNumber << ", marking for deletion" << std::endl; +#endif (*itr2)->phaseScore = -1.0; // flag for deletion if ((*itr)->topScoreTime < (*itr2)->topScoreTime) (*itr)->topScoreTime = (*itr2)->topScoreTime; @@ -115,7 +124,6 @@ Agent *bestAg = 0; for (iterator itr = begin(); itr != end(); ++itr) { if ((*itr)->events.empty()) continue; - double startTime = (*itr)->events.begin()->time; double conf = ((*itr)->phaseScore + (*itr)->tempoScore) / (useAverageSalience? (double)(*itr)->beatCount: 1.0); if (conf > best) {
--- a/BeatRootProcessor.cpp Wed Aug 28 16:50:22 2013 +0100 +++ b/BeatRootProcessor.cpp Wed Aug 28 16:50:40 2013 +0100 @@ -49,7 +49,7 @@ vector<int>::iterator it = peaks.begin(); onsetList.clear(); double minSalience = Peaks::min(spectralFlux); - for (int i = 0; i < onsets.size(); i++) { + for (int i = 0; i < (int)onsets.size(); i++) { int index = *it; ++it; onsets[i] = index * hop;
--- a/BeatRootProcessor.h Wed Aug 28 16:50:22 2013 +0100 +++ b/BeatRootProcessor.h Wed Aug 28 16:50:40 2013 +0100 @@ -117,10 +117,15 @@ protected: /** Allocates memory for arrays, based on parameter settings */ void init() { +#ifdef DEBUG_BEATROOT + std::cerr << "BeatRootProcessor::init()" << std::endl; +#endif makeFreqMap(fftSize, sampleRate); prevFrame.clear(); for (int i = 0; i <= fftSize/2; i++) prevFrame.push_back(0); spectralFlux.clear(); + onsets.clear(); + onsetList.clear(); } // init() /** Creates a map of FFT frequency bins to comparison bins. @@ -137,13 +142,16 @@ int crossoverMidi = (int)lrint(log(crossoverBin*binWidth/440)/ log(2) * 12 + 69); int i = 0; - while (i <= crossoverBin && i <= fftSize/2) - freqMap[i++] = i; + while (i <= crossoverBin && i <= fftSize/2) { + freqMap[i] = i; + ++i; + } while (i <= fftSize/2) { double midi = log(i*binWidth/440) / log(2) * 12 + 69; if (midi > 127) midi = 127; - freqMap[i++] = crossoverBin + (int)lrint(midi) - crossoverMidi; + freqMap[i] = crossoverBin + (int)lrint(midi) - crossoverMidi; + ++i; } freqMapSize = freqMap[i-1] + 1; } // makeFreqMap()
--- a/BeatRootVampPlugin.cpp Wed Aug 28 16:50:22 2013 +0100 +++ b/BeatRootVampPlugin.cpp Wed Aug 28 16:50:40 2013 +0100 @@ -209,7 +209,7 @@ BeatRootVampPlugin::getRemainingFeatures() { EventList el = m_processor->beatTrack(); - + Feature f; f.hasTimestamp = true; f.hasDuration = false;
--- a/Peaks.cpp Wed Aug 28 16:50:22 2013 +0100 +++ b/Peaks.cpp Wed Aug 28 16:50:40 2013 +0100 @@ -29,7 +29,7 @@ if (i < 0) i = 0; int stop = mid + width + 1; - if (stop > data.size()) + if (stop > (int)data.size()) stop = data.size(); maxp = i; for (i++; i < stop; i++) @@ -40,12 +40,12 @@ for (j = peakCount; j > 0; j--) { if (data[maxp] <= data[peaks[j-1]]) break; - else if (j < peaks.size()) + else if (j < (int)peaks.size()) peaks[j] = peaks[j-1]; } - if (j != peaks.size()) + if (j != (int)peaks.size()) peaks[j] = maxp; - if (peakCount != peaks.size()) + if (peakCount != (int)peaks.size()) peakCount++; } mid++; @@ -69,7 +69,7 @@ if (i < 0) i = 0; int stop = mid + width + 1; - if (stop > data.size()) + if (stop > (int)data.size()) stop = data.size(); maxp = i; for (i++; i < stop; i++) @@ -106,7 +106,7 @@ if (iStart < 0) iStart = 0; int iStop = index + post * width; - if (iStop > data.size()) + if (iStop > (int)data.size()) iStop = data.size(); double sum = 0; int count = iStop - iStart; @@ -120,7 +120,7 @@ void Peaks::normalise(vector<double> &data) { double sx = 0; double sxx = 0; - for (int i = 0; i < data.size(); i++) { + for (int i = 0; i < (int)data.size(); i++) { sx += data[i]; sxx += data[i] * data[i]; } @@ -128,7 +128,7 @@ double sd = sqrt((sxx - sx * mean) / data.size()); if (sd == 0) sd = 1; // all data[i] == mean -> 0; avoids div by 0 - for (int i = 0; i < data.size(); i++) { + for (int i = 0; i < (int)data.size(); i++) { data[i] = (data[i] - mean) / sd; } } // normalise() @@ -154,18 +154,18 @@ double delta = n * sxx - sx * sx; for ( ; j < n / 2; j++) slope[j] = (n * sxy - sx * sy) / delta; - for ( ; j < data.size() - (n + 1) / 2; j++, i++) { + for ( ; j < (int)data.size() - (n + 1) / 2; j++, i++) { slope[j] = (n * sxy - sx * sy) / delta; sy += data[i] - data[i - n]; sxy += hop * (n * data[i] - sy); } - for ( ; j < data.size(); j++) + for ( ; j < (int)data.size(); j++) slope[j] = (n * sxy - sx * sy) / delta; } // getSlope() int Peaks::imin(const vector<double> &arr) { int i = 0; - for (int j = 1; j < arr.size(); j++) + for (int j = 1; j < (int)arr.size(); j++) if (arr[j] < arr[i]) i = j; return i; @@ -173,7 +173,7 @@ int Peaks::imax(const vector<double> &arr) { int i = 0; - for (int j = 1; j < arr.size(); j++) + for (int j = 1; j < (int)arr.size(); j++) if (arr[j] > arr[i]) i = j; return i;