Mercurial > hg > chp
comparison ConstrainedHarmonicPeak.cpp @ 14:de970142809f tip
Fix some warnings
author | Chris Cannam |
---|---|
date | Wed, 10 Jul 2019 10:39:57 +0100 |
parents | f82a28c2209f |
children |
comparison
equal
deleted
inserted
replaced
13:456842723db6 | 14:de970142809f |
---|---|
24 | 24 |
25 #include "ConstrainedHarmonicPeak.h" | 25 #include "ConstrainedHarmonicPeak.h" |
26 | 26 |
27 #include <cmath> | 27 #include <cmath> |
28 #include <cstdio> | 28 #include <cstdio> |
29 #include <climits> | |
29 | 30 |
30 using std::cerr; | 31 using std::cerr; |
31 using std::endl; | 32 using std::endl; |
32 using std::vector; | 33 using std::vector; |
33 | 34 |
156 if (identifier == "minfreq") { | 157 if (identifier == "minfreq") { |
157 return m_minFreq; | 158 return m_minFreq; |
158 } else if (identifier == "maxfreq") { | 159 } else if (identifier == "maxfreq") { |
159 return m_maxFreq; | 160 return m_maxFreq; |
160 } else if (identifier == "harmonics") { | 161 } else if (identifier == "harmonics") { |
161 return m_harmonics; | 162 return float(m_harmonics); |
162 } | 163 } |
163 return 0; | 164 return 0; |
164 } | 165 } |
165 | 166 |
166 void | 167 void |
187 { | 188 { |
188 return ""; // no programs | 189 return ""; // no programs |
189 } | 190 } |
190 | 191 |
191 void | 192 void |
192 ConstrainedHarmonicPeak::selectProgram(string name) | 193 ConstrainedHarmonicPeak::selectProgram(string) |
193 { | 194 { |
194 } | 195 } |
195 | 196 |
196 ConstrainedHarmonicPeak::OutputList | 197 ConstrainedHarmonicPeak::OutputList |
197 ConstrainedHarmonicPeak::getOutputDescriptors() const | 198 ConstrainedHarmonicPeak::getOutputDescriptors() const |
209 | 210 |
210 return list; | 211 return list; |
211 } | 212 } |
212 | 213 |
213 bool | 214 bool |
214 ConstrainedHarmonicPeak::initialise(size_t channels, size_t stepSize, size_t blockSize) | 215 ConstrainedHarmonicPeak::initialise(size_t channels, size_t, size_t blockSize) |
215 { | 216 { |
216 if (channels < getMinChannelCount() || | 217 if (channels < getMinChannelCount() || |
217 channels > getMaxChannelCount()) { | 218 channels > getMaxChannelCount()) { |
218 cerr << "ConstrainedHarmonicPeak::initialise: ERROR: channels " << channels | 219 cerr << "ConstrainedHarmonicPeak::initialise: ERROR: channels " << channels |
219 << " out of acceptable range " << getMinChannelCount() | 220 << " out of acceptable range " << getMinChannelCount() |
220 << " -> " << getMaxChannelCount() << endl; | 221 << " -> " << getMaxChannelCount() << endl; |
221 return false; | 222 return false; |
222 } | 223 } |
223 | 224 |
224 m_fftSize = blockSize; | 225 if (blockSize > INT_MAX) { |
226 return false; // arf | |
227 } | |
228 | |
229 m_fftSize = int(blockSize); | |
225 | 230 |
226 return true; | 231 return true; |
227 } | 232 } |
228 | 233 |
229 void | 234 void |
259 | 264 |
260 return double(peakbin) + p; | 265 return double(peakbin) + p; |
261 } | 266 } |
262 | 267 |
263 ConstrainedHarmonicPeak::FeatureSet | 268 ConstrainedHarmonicPeak::FeatureSet |
264 ConstrainedHarmonicPeak::process(const float *const *inputBuffers, Vamp::RealTime timestamp) | 269 ConstrainedHarmonicPeak::process(const float *const *inputBuffers, Vamp::RealTime) |
265 { | 270 { |
266 FeatureSet fs; | 271 FeatureSet fs; |
267 | 272 |
268 // This could be better. The procedure here is | 273 // This could be better. The procedure here is |
269 // | 274 // |
305 inputBuffers[0][i*2+1] * inputBuffers[0][i*2+1]); | 310 inputBuffers[0][i*2+1] * inputBuffers[0][i*2+1]); |
306 } | 311 } |
307 | 312 |
308 // bin freq is bin * samplerate / fftsize | 313 // bin freq is bin * samplerate / fftsize |
309 | 314 |
310 int minbin = int(floor((m_minFreq * m_fftSize) / m_inputSampleRate)); | 315 int minbin = int(floor((double(m_minFreq) * m_fftSize) / m_inputSampleRate)); |
311 int maxbin = int(ceil((m_maxFreq * m_fftSize) / m_inputSampleRate)); | 316 int maxbin = int(ceil((double(m_maxFreq) * m_fftSize) / m_inputSampleRate)); |
312 if (minbin > hs) minbin = hs; | 317 if (minbin > hs) minbin = hs; |
313 if (maxbin > hs) maxbin = hs; | 318 if (maxbin > hs) maxbin = hs; |
314 if (maxbin <= minbin) return fs; | 319 if (maxbin <= minbin) return fs; |
315 | 320 |
316 double *hps = new double[maxbin - minbin + 1]; | 321 double *hps = new double[maxbin - minbin + 1]; |
359 if (freq < m_minFreq || freq > m_maxFreq) { | 364 if (freq < m_minFreq || freq > m_maxFreq) { |
360 return fs; | 365 return fs; |
361 } | 366 } |
362 | 367 |
363 Feature f; | 368 Feature f; |
364 f.values.push_back(freq); | 369 f.values.push_back(float(freq)); |
365 fs[0].push_back(f); | 370 fs[0].push_back(f); |
366 | 371 |
367 return fs; | 372 return fs; |
368 } | 373 } |
369 | 374 |