# HG changeset patch # User Chris Cannam # Date 1336643144 -3600 # Node ID 8d046a9d36aaa9e838d48b8a0e816c0a01ffae7c # Parent 6f87e0cb5e5e0779a9abc947e545663e7258b7ad Back out rev 13:ac07c60aa798. Like an idiot, I committed a whole pile of unrelated changes in the guise of a single typo fix. Will re-commit in stages diff -r 6f87e0cb5e5e -r 8d046a9d36aa songparts/Makefile.linux64 --- a/songparts/Makefile.linux64 Thu May 10 10:32:29 2012 +0100 +++ b/songparts/Makefile.linux64 Thu May 10 10:45:44 2012 +0100 @@ -1,6 +1,5 @@ -#CFLAGS := -O3 -fPIC -ftree-vectorize -I../armadillo-2.4.4/include -I../../vamp-plugin-sdk -I../../qm-dsp -CFLAGS := -g -fPIC -I../armadillo-2.4.4/include -I../../vamp-plugin-sdk -I../../qm-dsp +CFLAGS := -O3 -fPIC -ftree-vectorize -I../armadillo-2.4.4/include -I../../vamp-plugin-sdk -I../../qm-dsp CXXFLAGS := $(CFLAGS) diff -r 6f87e0cb5e5e -r 8d046a9d36aa songparts/SongParts.cpp --- a/songparts/SongParts.cpp Thu May 10 10:32:29 2012 +0100 +++ b/songparts/SongParts.cpp Thu May 10 10:45:44 2012 +0100 @@ -50,9 +50,9 @@ // Result Struct typedef struct Part { int n; - vector indices; + vector indices; string letter; - int value; + unsigned value; int level; int nInd; }Part; @@ -1158,7 +1158,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 (unsigned i=medfilt_length/2; i < medfilt_length/2+v.size(); ++ i) { padV(i) = v(i-medfilt_length/2); } @@ -1166,7 +1166,7 @@ // Median filter arma::vec win = arma::zeros(medfilt_length); - for (int i=0; i < v.size(); ++i) + for (unsigned i=0; i < v.size(); ++i) { win = padV.subvec(i,i+halfWin*2); win = sort(win); @@ -1188,7 +1188,7 @@ x(0) = 0; x(n+1) = 100; - for (int i=1; i 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; @@ -1280,15 +1280,15 @@ if (parts[iPart].letter.compare("-")==0) { sort (parts[iPart].indices.begin(), parts[iPart].indices.end()); - int newpartind = -1; + unsigned newpartind = -1; vector indices; indices.push_back(-2); - for (int iIndex=0; iIndex 1) { @@ -1313,7 +1313,7 @@ } parts.erase (parts.end()); - for (int i=0; i songSegment(Vamp::Plugin::FeatureList quantisedChromagram) +vector songSegment(Vamp::Plugin::FeatureList quatisedChromagram) { @@ -1336,26 +1336,26 @@ // Collect Info - int nBeat = quantisedChromagram.size(); // Number of feature vector - int nFeatValues = quantisedChromagram[0].values.size(); // Number of values for each feature vector + int nBeat = quatisedChromagram.size(); // Number of feature vector + int nFeatValues = quatisedChromagram[0].values.size(); // Number of values for each feature vector arma::irowvec timeStamp = arma::zeros(1,nBeat); // Vector of Time Stamps // Save time stamp as a Vector - if (quantisedChromagram[0].hasTimestamp) + if (quatisedChromagram[0].hasTimestamp) { - for (int i = 0; i < nBeat; ++ i) - timeStamp[i] = quantisedChromagram[i].timestamp.nsec; + for (unsigned i = 0; i < nBeat; ++ i) + timeStamp[i] = quatisedChromagram[i].timestamp.nsec; } // Build a ObservationTOFeatures Matrix arma::mat featVal = arma::zeros(nBeat,nFeatValues/2); - for (int i = 0; i < nBeat; ++ i) - for (int j = 0; j < nFeatValues/2; ++ j) + for (unsigned i = 0; i < nBeat; ++ i) + for (unsigned j = 0; j < nFeatValues/2; ++ j) { - featVal(i,j) = (quantisedChromagram[i].values[j]+quantisedChromagram[i].values[j+12]) * 0.8; + featVal(i,j) = (quatisedChromagram[i].values[j]+quatisedChromagram[i].values[j+12]) * 0.8; } // Set to arbitrary value to feature vectors with low std @@ -1365,13 +1365,13 @@ arma::mat simmat0 = 1-arma::cor(arma::trans(featVal)); - for (int i = 0; i < nBeat; ++ i) + for (unsigned i = 0; i < nBeat; ++ i) { if (a(i)<0.000001) { featVal(i,1) = 1000; // arbitrary - for (int j = 0; j < nFeatValues/2; ++j) + for (unsigned j = 0; j < nFeatValues/2; ++j) { simmat0(i,j) = 1; simmat0(j,i) = 1; @@ -1382,8 +1382,8 @@ arma::mat simmat = 1-simmat0/2; // -------- To delate when the proble with the add of beat will be solved ------- - for (int i = 0; i < nBeat; ++ i) - for (int j = 0; j < nBeat; ++ j) + for (unsigned i = 0; i < nBeat; ++ i) + for (unsigned j = 0; j < nBeat; ++ j) if (!std::isfinite(simmat(i,j))) simmat(i,j)=0; // ------------------------------------------------------------------------------ @@ -1392,15 +1392,15 @@ // The median filter is for each diagonal of the Matrix arma::mat median_simmat = arma::zeros(nBeat,nBeat); - for (int i = 0; i < nBeat; ++ i) + for (unsigned i = 0; i < nBeat; ++ i) { arma::vec temp = medfilt1(simmat.diag(i),medfilt_length); median_simmat.diag(i) = temp; median_simmat.diag(-i) = temp; } - for (int i = 0; i < nBeat; ++ i) - for (int j = 0; j < nBeat; ++ j) + for (unsigned i = 0; i < nBeat; ++ i) + for (unsigned j = 0; j < nBeat; ++ j) if (!std::isfinite(median_simmat(i,j))) median_simmat(i,j) = 0; @@ -1418,10 +1418,10 @@ potential_duplicates.elem(dup) = arma::ones(dup.size()); potential_duplicates = trimatu(potential_duplicates); - int nPartlengths = round((maxlength-minlength)/4)+1; + unsigned nPartlengths = round((maxlength-minlength)/4)+1; arma::vec partlengths = zeros(nPartlengths); - for (int i = 0; i < nPartlengths; ++ i) + for (unsigned i = 0; i < nPartlengths; ++ i) partlengths(i) = (i*4)+ minlength; // initialise arrays @@ -1430,17 +1430,17 @@ int conta = 0; - //for (int iLength = 0; iLength < nPartlengths; ++ iLength) - for (int iLength = 0; iLength < 20; ++ iLength) + //for (unsigned iLength = 0; iLength < nPartlengths; ++ iLength) + for (unsigned iLength = 0; iLength < 20; ++ iLength) { - int len = partlengths(iLength); - int nUsedBeat = nBeat - len + 1; // number of potential rep beginnings: they can't overlap at the end of the song + unsigned len = partlengths(iLength); + unsigned nUsedBeat = nBeat - len + 1; // number of potential rep beginnings: they can't overlap at the end of the song - for (int iBeat = 0; iBeat < nUsedBeat; ++ iBeat) // looping over all columns (arbitrarily chosen columns) + for (unsigned iBeat = 0; iBeat < nUsedBeat; ++ iBeat) // looping over all columns (arbitrarily chosen columns) { 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++; @@ -1532,7 +1532,7 @@ // make a table of all valid sets of parts char partletters[] = {'A','B','C','D','E','F','G', 'H','I','J','K','L','M','N','O','P','Q','R','S'}; - int partvalues[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + unsigned partvalues[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; arma::vec valid_sets = arma::ones(bestval.n_rows); if (!bestval.is_empty()) @@ -1541,7 +1541,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; arma::rowvec mask = arma::zeros(bestLength*2-1); - for (int i=0; i 0); - for (int i=0; i(s*2-1); - for (int i=0; i(Ind.size()); - for (int i=0; i0) IndMap(i) = 2; @@ -1669,38 +1669,38 @@ -void songSegmentChroma(Vamp::Plugin::FeatureList quantisedChromagram, vector &parts) +void songSegmentChroma(Vamp::Plugin::FeatureList quatisedChromagram, vector &parts) { // Collect Info - int nBeat = quantisedChromagram.size(); // Number of feature vector - int nFeatValues = quantisedChromagram[0].values.size(); // Number of values for each feature vector + int nBeat = quatisedChromagram.size(); // Number of feature vector + int nFeatValues = quatisedChromagram[0].values.size(); // Number of values for each feature vector arma::mat synchTreble = arma::zeros(nBeat,nFeatValues/2); - for (int i = 0; i < nBeat; ++ i) - for (int j = 0; j < nFeatValues/2; ++ j) + for (unsigned i = 0; i < nBeat; ++ i) + for (unsigned j = 0; j < nFeatValues/2; ++ j) { - synchTreble(i,j) = quantisedChromagram[i].values[j]; + synchTreble(i,j) = quatisedChromagram[i].values[j]; } arma::mat synchBass = arma::zeros(nBeat,nFeatValues/2); - for (int i = 0; i < nBeat; ++ i) - for (int j = 0; j < nFeatValues/2; ++ j) + for (unsigned i = 0; i < nBeat; ++ i) + for (unsigned j = 0; j < nFeatValues/2; ++ j) { - synchBass(i,j) = quantisedChromagram[i].values[j+12]; + synchBass(i,j) = quatisedChromagram[i].values[j+12]; } // Process - arma::mat segTreble = arma::zeros(quantisedChromagram.size(),quantisedChromagram[0].values.size()/2); - arma::mat segBass = arma::zeros(quantisedChromagram.size(),quantisedChromagram[0].values.size()/2); + arma::mat segTreble = arma::zeros(quatisedChromagram.size(),quatisedChromagram[0].values.size()/2); + arma::mat segBass = arma::zeros(quatisedChromagram.size(),quatisedChromagram[0].values.size()/2); - for (int iPart=0; iPart newPartVector; vector partindices; - for (int iPart=0; iPart parts; vector finalParts; - parts = songSegment(quantisedChromagram); - songSegmentChroma(quantisedChromagram,parts); + parts = songSegment(quatisedChromagram); + songSegmentChroma(quatisedChromagram,parts); finalParts = songSegmentIntegration(parts); // TEMP ---- - /*for (int i=0;i values; vector letters; - for (int iPart=0; iPart