comparison data/model/FFTModel.cpp @ 1218:6b847a59d908 msvc2015_64

MSVC build fixes
author Chris Cannam
date Tue, 18 Oct 2016 15:54:56 +0100
parents 6f7a440b6218
children d8d6d01505ed
comparison
equal deleted inserted replaced
1217:046f05fa31f3 1218:6b847a59d908
21 21
22 #include <algorithm> 22 #include <algorithm>
23 23
24 #include <cassert> 24 #include <cassert>
25 #include <deque> 25 #include <deque>
26
27 #ifndef __GNUC__
28 #include <alloca.h>
29 #endif
30 26
31 using namespace std; 27 using namespace std;
32 28
33 FFTModel::FFTModel(const DenseTimeValueModel *model, 29 FFTModel::FFTModel(const DenseTimeValueModel *model,
34 int channel, 30 int channel,
358 int minbin = ymin; 354 int minbin = ymin;
359 if (minbin > 0) minbin = minbin - 1; 355 if (minbin > 0) minbin = minbin - 1;
360 int maxbin = ymax; 356 int maxbin = ymax;
361 if (maxbin < getHeight() - 1) maxbin = maxbin + 1; 357 if (maxbin < getHeight() - 1) maxbin = maxbin + 1;
362 const int n = maxbin - minbin + 1; 358 const int n = maxbin - minbin + 1;
363 #ifdef __GNUC__ 359 float *values = new float[n];
364 float values[n];
365 #else
366 float *values = (float *)alloca(n * sizeof(float));
367 #endif
368 getMagnitudesAt(x, values, minbin, maxbin - minbin + 1); 360 getMagnitudesAt(x, values, minbin, maxbin - minbin + 1);
369 for (int bin = ymin; bin <= ymax; ++bin) { 361 for (int bin = ymin; bin <= ymax; ++bin) {
370 if (bin == minbin || bin == maxbin) continue; 362 if (bin == minbin || bin == maxbin) continue;
371 if (values[bin - minbin] > values[bin - minbin - 1] && 363 if (values[bin - minbin] > values[bin - minbin - 1] &&
372 values[bin - minbin] > values[bin - minbin + 1]) { 364 values[bin - minbin] > values[bin - minbin + 1]) {
373 peaks.insert(bin); 365 peaks.insert(bin);
374 } 366 }
375 } 367 }
368 delete[] values;
376 return peaks; 369 return peaks;
377 } 370 }
378 371
379 Column values = getColumn(x); 372 Column values = getColumn(x);
380 int nv = int(values.size()); 373 int nv = int(values.size());