Mercurial > hg > svcore
diff data/model/FFTModel.cpp @ 1154:aa588c391d1a 3.0-integration
Convert 3d model column type from QVector to std::vector; replace another user of ResizeableBitset
author | Chris Cannam |
---|---|
date | Fri, 22 Jan 2016 13:39:45 +0000 |
parents | e994747fb9dd |
children | 546d4e417346 |
line wrap: on
line diff
--- a/data/model/FFTModel.cpp Fri Jan 22 12:46:42 2016 +0000 +++ b/data/model/FFTModel.cpp Fri Jan 22 13:39:45 2016 +0000 @@ -98,9 +98,9 @@ { auto cplx = getFFTColumn(x); Column col; - col.reserve(int(cplx.size())); + col.reserve(cplx.size()); for (auto c: cplx) col.push_back(abs(c)); - return col; + return move(col); } float @@ -116,7 +116,8 @@ { Column col(getColumn(x)); float max = 0.f; - for (int i = 0; i < col.size(); ++i) { + int n = int(col.size()); + for (int i = 0; i < n; ++i) { if (col[i] > max) max = col[i]; } return max; @@ -313,7 +314,7 @@ } m_cached.push_back(sc); - return col; + return move(col); } bool @@ -388,10 +389,11 @@ } Column values = getColumn(x); + int nv = int(values.size()); float mean = 0.f; - for (int i = 0; i < values.size(); ++i) mean += values[i]; - if (values.size() > 0) mean = mean / float(values.size()); + for (int i = 0; i < nv; ++i) mean += values[i]; + if (nv > 0) mean = mean / float(values.size()); // For peak picking we use a moving median window, picking the // highest value within each continuous region of values that @@ -412,8 +414,8 @@ else binmin = 0; int binmax; - if (ymax + halfWin < values.size()) binmax = ymax + halfWin; - else binmax = values.size()-1; + if (ymax + halfWin < nv) binmax = ymax + halfWin; + else binmax = nv - 1; int prevcentre = 0; @@ -434,8 +436,8 @@ int actualSize = int(window.size()); if (type == MajorPitchAdaptivePeaks) { - if (ymax + halfWin < values.size()) binmax = ymax + halfWin; - else binmax = values.size()-1; + if (ymax + halfWin < nv) binmax = ymax + halfWin; + else binmax = nv - 1; } deque<float> sorted(window); @@ -455,7 +457,7 @@ inrange.push_back(centrebin); } - if (centre <= median || centrebin+1 == values.size()) { + if (centre <= median || centrebin+1 == nv) { if (!inrange.empty()) { int peakbin = 0; float peakval = 0.f;