# HG changeset patch # User Chris Cannam # Date 1415958356 0 # Node ID 8cbc15519d2c582f7733f7fa8dbaa2340c0d6a2b # Parent e43220da49d14403ee0f4600b38ffde7ce07733c Fix narrowing float conversions diff -r e43220da49d1 -r 8cbc15519d2c src/Finder.cpp --- a/src/Finder.cpp Fri Nov 14 09:40:49 2014 +0000 +++ b/src/Finder.cpp Fri Nov 14 09:45:56 2014 +0000 @@ -72,14 +72,14 @@ Matcher::Advance Finder::getExpandDirection(int row, int col, bool check) { - int min = getPathCost(row, col); + float min = getPathCost(row, col); bestRow = row; bestCol = col; getRowRange(col, rowRange); if (rowRange[1] > row+1) rowRange[1] = row+1; // don't cheat by looking at future :) for (int index = rowRange[0]; index < rowRange[1]; index++) { - int tmp = getPathCost(index, col); + float tmp = getPathCost(index, col); if (tmp < min) { min = tmp; bestRow = index; @@ -89,7 +89,7 @@ if (colRange[1] > col+1) colRange[1] = col+1; // don't cheat by looking at future :) for (int index = colRange[0]; index < colRange[1]; index++) { - int tmp = getPathCost(row, index); + float tmp = getPathCost(row, index); if (tmp < min) { min = tmp; bestCol = index; @@ -223,10 +223,10 @@ for (c = thisRowStart; c <= c2; c++) { if (find(r,c)) { int i2 = index2; - int newCost = pm1->m_distance[r][i2]; + float newCost = pm1->m_distance[r][i2]; Matcher::Advance dir = Matcher::AdvanceNone; if (r > r1) { // not first row - int min = -1; + float min = -1; if ((c > prevRowStart) && (c <= prevRowStop)) { // diagonal from (r-1,c-1) min = pm1->m_bestPathCost[r-1][c-pm1->m_first[r-1]-1] + @@ -235,7 +235,7 @@ } if ((c >= prevRowStart) && (c < prevRowStop)) { // vertical from (r-1,c) - int cost = pm1->m_bestPathCost[r-1][c-pm1->m_first[r-1]] + + float cost = pm1->m_bestPathCost[r-1][c-pm1->m_first[r-1]] + newCost; if ((min == -1) || (cost < min)) { min = cost; @@ -244,7 +244,7 @@ } if (c > thisRowStart) { // horizontal from (r,c-1) - int cost =pm1->m_bestPathCost[r][i2-1]+newCost; + float cost =pm1->m_bestPathCost[r][i2-1]+newCost; if ((min == -1) || (cost < min)) { min = cost; dir = Matcher::AdvanceOther; @@ -271,7 +271,7 @@ { int x = pm2->getFrameCount() - 1; int y = pm1->getFrameCount() - 1; - + pathx.clear(); pathy.clear(); diff -r e43220da49d1 -r 8cbc15519d2c src/MatchVampPlugin.cpp --- a/src/MatchVampPlugin.cpp Fri Nov 14 09:40:49 2014 +0000 +++ b/src/MatchVampPlugin.cpp Fri Nov 14 09:45:56 2014 +0000 @@ -45,11 +45,11 @@ // sample rates static float sampleRateMin = 5000.f; -static float defaultStepTime = 0.020; +static float defaultStepTime = 0.020f; MatchVampPlugin::MatchVampPlugin(float inputSampleRate) : Plugin(inputSampleRate), - m_stepSize(inputSampleRate * defaultStepTime + 0.001), + m_stepSize(int(inputSampleRate * defaultStepTime + 0.001)), m_stepTime(defaultStepTime), m_blockSize(2048), m_serialise(false), @@ -219,7 +219,7 @@ desc.description = "Width of the search zone (error margin) either side of the ongoing match position, in seconds"; desc.minValue = 1; desc.maxValue = 60; - desc.defaultValue = m_defaultParams.blockTime; + desc.defaultValue = (float)m_defaultParams.blockTime; desc.isQuantized = true; desc.quantizeStep = 1; desc.unit = "s"; @@ -255,7 +255,7 @@ } else if (name == "gradientlimit") { return m_params.maxRunCount; } else if (name == "zonewidth") { - return m_params.blockTime; + return (float)m_params.blockTime; } else if (name == "smooth") { return m_smooth ? 1.0 : 0.0; } @@ -288,7 +288,7 @@ size_t MatchVampPlugin::getPreferredStepSize() const { - return m_inputSampleRate * defaultStepTime; + return int(m_inputSampleRate * defaultStepTime + 0.001); } size_t @@ -354,7 +354,7 @@ { OutputList list; - float outRate = 1.0 / m_stepTime; + float outRate = 1.0f / m_stepTime; OutputDescriptor desc; desc.identifier = "path"; @@ -483,7 +483,7 @@ for (int i = 0; i < (int)ff.f1.size(); ++i) { f.values.clear(); for (int j = 0; j < (int)ff.f1[i].size(); ++j) { - f.values.push_back(ff.f1[i][j]); + f.values.push_back(float(ff.f1[i][j])); } returnFeatures[m_aFeaturesOutNo].push_back(f); } @@ -491,7 +491,7 @@ for (int i = 0; i < (int)ff.f2.size(); ++i) { f.values.clear(); for (int j = 0; j < (int)ff.f2[i].size(); ++j) { - f.values.push_back(ff.f2[i][j]); + f.values.push_back(float(ff.f2[i][j])); } returnFeatures[m_bFeaturesOutNo].push_back(f); } @@ -529,7 +529,7 @@ feature.hasTimestamp = true; feature.timestamp = m_startTime + xt; feature.values.clear(); - feature.values.push_back(yt.sec + double(yt.nsec)/1.0e9); + feature.values.push_back(float(yt.sec + double(yt.nsec)/1.0e9)); returnFeatures[m_pathOutNo].push_back(feature); if (x != prevx) { @@ -537,12 +537,12 @@ feature.hasTimestamp = true; feature.timestamp = m_startTime + xt; feature.values.clear(); - feature.values.push_back(yt.sec + yt.msec()/1000.0); + feature.values.push_back(float(yt.sec + yt.msec()/1000.0)); returnFeatures[m_abOutNo].push_back(feature); Vamp::RealTime diff = yt - xt; feature.values.clear(); - feature.values.push_back(diff.sec + diff.msec()/1000.0); + feature.values.push_back(float(diff.sec + diff.msec()/1000.0)); returnFeatures[m_abDivOutNo].push_back(feature); if (i > 0) { @@ -565,7 +565,7 @@ feature.hasTimestamp = true; feature.timestamp = m_startTime + yt; feature.values.clear(); - feature.values.push_back(xt.sec + xt.msec()/1000.0); + feature.values.push_back(float(xt.sec + xt.msec()/1000.0)); returnFeatures[m_baOutNo].push_back(feature); } diff -r e43220da49d1 -r 8cbc15519d2c src/Matcher.cpp --- a/src/Matcher.cpp Fri Nov 14 09:40:49 2014 +0000 +++ b/src/Matcher.cpp Fri Nov 14 09:45:56 2014 +0000 @@ -182,7 +182,7 @@ float mx= -1; for ( ; index < stop; index++) { - float dMN = m_metric.calcDistance + float dMN = (float) m_metric.calcDistance (m_frames[frameIndex], m_otherMatcher->m_frames[index % m_blockSize]);