# HG changeset patch # User Chris Cannam # Date 1337165767 -3600 # Node ID 4a92113e9798c9b81ab484baa651c2350de45701 # Parent cc18e9a13fe862f24257eb282e0da8e1f578502c Eliminate a couple more potential unsigned underflows, fix compiler warnings diff -r cc18e9a13fe8 -r 4a92113e9798 songparts/SongParts.cpp --- a/songparts/SongParts.cpp Wed May 16 11:44:39 2012 +0100 +++ b/songparts/SongParts.cpp Wed May 16 11:56:07 2012 +0100 @@ -116,7 +116,7 @@ int frameCount; int nBPS; Vamp::Plugin::FeatureList logSpectrum; - size_t blockSize; + int blockSize; int lengthOfNoteIndex; vector meanTunings; vector localTunings; @@ -137,7 +137,7 @@ vector cosvalues; Window window; FFTReal fft; - size_t inputSampleRate; + int inputSampleRate; /* --- METHODS --- */ @@ -205,7 +205,7 @@ // FFTReal wants doubles, so we need to make a local copy of inputBuffers double *inputBuffersDouble = new double[blockSize]; - for (size_t i = 0; i < blockSize; i++) inputBuffersDouble[i] = inputBuffers[i]; + for (int i = 0; i < blockSize; i++) inputBuffersDouble[i] = inputBuffers[i]; fft.process(false, inputBuffersDouble, fftReal, fftImag); @@ -296,15 +296,15 @@ { dictionaryMatrix(dict, s); - // make things for tuning estimation - for (int iBPS = 0; iBPS < nBPS; ++iBPS) { + // make things for tuning estimation + for (int iBPS = 0; iBPS < nBPS; ++iBPS) { sinvalues.push_back(sin(2*M_PI*(iBPS*1.0/nBPS))); cosvalues.push_back(cos(2*M_PI*(iBPS*1.0/nBPS))); } - // make hamming window of length 1/2 octave - int hamwinlength = nBPS * 6 + 1; + // make hamming window of length 1/2 octave + int hamwinlength = nBPS * 6 + 1; float hamwinsum = 0; for (int i = 0; i < hamwinlength; ++i) { hw.push_back(0.54 - 0.46 * cos((2*M_PI*i)/(hamwinlength-1))); @@ -346,6 +346,8 @@ } } delete [] tempkernel; + + return true; } }; @@ -358,8 +360,8 @@ /* --- ATTRIBUTES --- */ float SongPartitioner::m_stepSecs = 0.01161; // 512 samples at 44100 -size_t SongPartitioner::m_chromaFramesizeFactor = 16; // 16 times as long as beat tracker's -size_t SongPartitioner::m_chromaStepsizeFactor = 4; // 4 times as long as beat tracker's +int SongPartitioner::m_chromaFramesizeFactor = 16; // 16 times as long as beat tracker's +int SongPartitioner::m_chromaStepsizeFactor = 4; // 4 times as long as beat tracker's /* --- METHODS --- */ @@ -526,7 +528,7 @@ SongPartitioner::OutputList SongPartitioner::getOutputDescriptors() const { OutputList list; - size_t outputCounter = 0; + int outputCounter = 0; OutputDescriptor beat; beat.identifier = "beats"; @@ -766,7 +768,7 @@ FeatureSet masterFeatureset = beatTrack(); FeatureList chromaList = chromaFeatures(); - for (size_t i = 0; i < chromaList.size(); ++i) + for (int i = 0; i < (int)chromaList.size(); ++i) { masterFeatureset[m_bothchromaOutputNumber].push_back(chromaList[i]); } @@ -793,7 +795,7 @@ vector beatPeriod; vector tempi; - for (size_t i = 2; i < m_d->dfOutput.size(); ++i) { // discard first two elts + for (int i = 2; i < (int)m_d->dfOutput.size(); ++i) { // discard first two elts df.push_back(m_d->dfOutput[i]); beatPeriod.push_back(0.0); } @@ -832,11 +834,11 @@ if (beat == m_bpb) beat = 0; } - for (size_t i = 0; i < beats.size(); ++i) { + for (int i = 0; i < (int)beats.size(); ++i) { - size_t frame = beats[i] * m_d->dfConfig.stepSize; + int frame = beats[i] * m_d->dfConfig.stepSize; - if (dbi < downbeats.size() && i == downbeats[dbi]) { + if (dbi < (int)downbeats.size() && i == downbeats[dbi]) { beat = 0; ++bar; ++dbi; @@ -863,7 +865,7 @@ feature.values.push_back(beat + 1); returnFeatures[m_beatcountsOutputNumber].push_back(feature); // beat function - if (i > 0 && i <= beatsd.size()) { + if (i > 0 && i <= (int)beatsd.size()) { feature.values.clear(); feature.values.push_back(beatsd[i-1]); feature.label = ""; @@ -1097,7 +1099,7 @@ if (nBeat == 0 && nChromaFrame == 0) return returnVector; - size_t nBin = chromagram[0].values.size(); + int nBin = chromagram[0].values.size(); vector tempChroma = vector(nBin); @@ -1110,8 +1112,11 @@ Vamp::RealTime frameTimestamp = chromagram[iChroma].timestamp; Vamp::RealTime newBeatTimestamp; - if (currBeatCount != beats.size()-1) newBeatTimestamp = beats[currBeatCount+1].timestamp; - else newBeatTimestamp = chromagram[nChromaFrame-1].timestamp; + if (currBeatCount != (int)beats.size() - 1) { + newBeatTimestamp = beats[currBeatCount+1].timestamp; + } else { + newBeatTimestamp = chromagram[nChromaFrame-1].timestamp; + } if (frameTimestamp > newBeatTimestamp || iChroma == nChromaFrame-1) @@ -1142,11 +1147,11 @@ // 2. increments / resets for current (new) beat currBeatCount++; beatTimestamp = newBeatTimestamp; - for (size_t i = 0; i < nBin; ++i) tempChroma[i] = 0; // average + for (int i = 0; i < nBin; ++i) tempChroma[i] = 0; // average framesInBeat = 0; } framesInBeat++; - for (size_t i = 0; i < nBin; ++i) tempChroma[i] += chromagram[iChroma].values[i]; + for (int i = 0; i < nBin; ++i) tempChroma[i] += chromagram[iChroma].values[i]; } returnVector.push_back(fwQchromagram); returnVector.push_back(bwQchromagram); @@ -1168,7 +1173,7 @@ // padding arma::vec padV = arma::zeros(v.size()+medfilt_length-1); - for (int i=medfilt_length/2; i < medfilt_length/2+v.size(); ++ i) + for (int i=medfilt_length/2; i < medfilt_length/2+(int)v.size(); ++ i) { padV(i) = v(i-medfilt_length/2); } @@ -1176,7 +1181,7 @@ // Median filter arma::vec win = arma::zeros(medfilt_length); - for (int i=0; i < v.size(); ++i) + for (int i=0; i < (int)v.size(); ++i) { win = padV.subvec(i,i+halfWin*2); win = sort(win); @@ -1223,7 +1228,7 @@ { arma::mat outmat = inmat; - for (int i=0; i 0) { @@ -1236,7 +1241,7 @@ else startWin = i-len; - if (inmat.n_rows-1 < i+len-1) + if ((int)inmat.n_rows-1 < i+len-1) endWin = inmat.n_rows-1; else endWin = i+len-1; @@ -1253,10 +1258,10 @@ Part nullpart(vector parts, arma::vec barline) { arma::uvec nullindices = arma::ones(barline.size()); - for (int iPart=0; iPart 0); - for (int i=0; i &parts) { - for (int iPart=0; iPart newVectorPart; @@ -1295,10 +1300,10 @@ vector indices; indices.push_back(-2); - for (int iIndex=0; iIndex 1) { @@ -1323,7 +1328,7 @@ } parts.erase (parts.end()); - for (int i=0; i(nBeat,nBeat,nPartlengths); arma::cube decisionArray2 = zeros(nBeat,nBeat,nPartlengths); - int conta = 0; - //for (int iLength = 0; iLength < nPartlengths; ++ iLength) for (int iLength = 0; iLength < 20; ++ iLength) { @@ -1465,7 +1468,7 @@ { arma::uvec help2 = find(potential_duplicates(span(0,nUsedBeat-1),iBeat)==1); - for (int i=0; i(simArray.n_rows, simArray.n_cols); temp(span::all, span(0,nUsedBeat-1)) = simArray.slice(iLength)(span::all,span(0,nUsedBeat-1)); - for (int i=0; i(decisionArray2.n_rows,decisionArray2.n_cols); - for (int rows=0; rows 0) temp(rows,cols) = 1; arma::vec currLogicSum = arma::sum(temp,1); - for (int iBeat=0; iBeat 1) { arma::vec t = decisionArray2.slice(iLength)(span::all,iBeat); double currSum = sum(t); int count = 0; - for (int i=0; i0) count++; @@ -1566,7 +1569,7 @@ // In questo punto viene introdotto un errore alla 3 cifra decimale arma::colvec t = arma::zeros(bestval.n_rows); - for (int i=0; i(bestval2.n_rows, bestval2.n_cols); - for (int i=0; i(bestIndices.size()); - for (int i=0; i0) bestIndicesMap(i) = 1; @@ -1617,7 +1620,7 @@ newPart.n = bestLength; uvec q1 = find(bestIndices > 0); - for (int i=0; i(Ind.size()); - for (int i=0; i0) IndMap(i) = 2; @@ -1721,7 +1724,7 @@ arma::mat segTreble = arma::zeros(quantisedChromagram.size(),quantisedChromagram[0].values.size()/2); arma::mat segBass = arma::zeros(quantisedChromagram.size(),quantisedChromagram[0].values.size()/2); - for (int iPart=0; iPart newPartVector; vector partindices; - for (int iPart=0; iPart parts; vector finalParts; @@ -1838,11 +1841,11 @@ Feature seg; arma::vec indices; - int idx=0; +// int idx=0; vector values; vector letters; - for (int iPart=0; iPart 0) { + int ind = finalParts[finalParts.size()-1].indices[0]; + seg.hasTimestamp = true; + seg.timestamp = quantisedChromagram[ind].timestamp; + seg.hasDuration = true; + seg.duration = quantisedChromagram[quantisedChromagram.size()-1].timestamp-quantisedChromagram[ind].timestamp; + seg.values.clear(); + seg.values.push_back(finalParts[finalParts.size()-1].value); + seg.label = finalParts[finalParts.size()-1].letter; - results.push_back(seg); + results.push_back(seg); + } return results; } diff -r cc18e9a13fe8 -r 4a92113e9798 songparts/SongParts.h --- a/songparts/SongParts.h Wed May 16 11:44:39 2012 +0100 +++ b/songparts/SongParts.h Wed May 16 11:56:07 2012 +0100 @@ -55,8 +55,8 @@ BeatTrackerData *m_d; ChromaData *m_chromadata; static float m_stepSecs; - static size_t m_chromaFramesizeFactor; - static size_t m_chromaStepsizeFactor; + static int m_chromaFramesizeFactor; + static int m_chromaStepsizeFactor; int m_bpb; int m_pluginFrameCount; FeatureSet beatTrack();