Mercurial > hg > match-vamp
diff src/FeatureExtractor.cpp @ 180:d1bc89794cd4 tuning-rescale
Build with -Wconversion
author | Chris Cannam |
---|---|
date | Thu, 19 Feb 2015 16:14:33 +0000 |
parents | 1440773da492 |
children | 24ddab06aace |
line wrap: on
line diff
--- a/src/FeatureExtractor.cpp Mon Feb 16 15:38:42 2015 +0000 +++ b/src/FeatureExtractor.cpp Thu Feb 19 16:14:33 2015 +0000 @@ -88,10 +88,10 @@ // frequency-domain audio frames before applying the map to them. double refFreq = 440.; // See above -- *not* the parameter! - double binWidth = m_params.sampleRate / m_params.fftSize; + double binWidth = double(m_params.sampleRate) / m_params.fftSize; int crossoverBin = (int)(2 / (pow(2, 1/12.0) - 1)); - int crossoverMidi = lrint(log(crossoverBin * binWidth / refFreq)/ - log(2.0) * 12 + 69); + int crossoverMidi = int(log(crossoverBin * binWidth / refFreq)/ + log(2.0) * 12 + 69 + 0.5); int i = 0; while (i <= crossoverBin) { @@ -111,7 +111,7 @@ } else { double midi = log(freq / refFreq) / log(2.0) * 12 + 69; if (midi > 127) midi = 127; - int target = crossoverBin + lrint(midi) - crossoverMidi; + int target = crossoverBin + int(midi + 0.5) - crossoverMidi; if (target >= m_featureSize) target = m_featureSize - 1; m_freqMap[i++] = target; } @@ -132,7 +132,7 @@ FeatureExtractor::makeChromaFrequencyMap() { double refFreq = m_params.referenceFrequency; - double binWidth = m_params.sampleRate / m_params.fftSize; + double binWidth = double(m_params.sampleRate) / m_params.fftSize; int crossoverBin = (int)(1 / (pow(2, 1/12.0) - 1)); int i = 0; while (i <= crossoverBin) { @@ -149,7 +149,7 @@ m_freqMap[i++] = -1; } else { double midi = log(freq / refFreq) / log(2.0) * 12 + 69; - m_freqMap[i++] = (lrint(midi)) % 12 + 1; + m_freqMap[i++] = (int(midi + 0.5)) % 12 + 1; } } } @@ -221,7 +221,7 @@ double ratio = 440. / m_params.referenceFrequency; - int n = mags.size(); + int n = static_cast<int>(mags.size()); vector<double> scaled(n, 0.0);