comparison data/model/FFTModel.cpp @ 608:d7f3dfe6f9a4

* solaris build fixes
author Chris Cannam
date Thu, 10 Sep 2009 18:44:45 +0000
parents 408e56d30f58
children e802e550a1f2
comparison
equal deleted inserted replaced
607:a67651386253 608:d7f3dfe6f9a4
21 #include "base/Pitch.h" 21 #include "base/Pitch.h"
22 22
23 #include <algorithm> 23 #include <algorithm>
24 24
25 #include <cassert> 25 #include <cassert>
26
27 #ifndef __GNUC__
28 #include <alloca.h>
29 #endif
26 30
27 FFTModel::FFTModel(const DenseTimeValueModel *model, 31 FFTModel::FFTModel(const DenseTimeValueModel *model,
28 int channel, 32 int channel,
29 WindowType windowType, 33 WindowType windowType,
30 size_t windowSize, 34 size_t windowSize,
170 174
171 result.clear(); 175 result.clear();
172 size_t h = getHeight(); 176 size_t h = getHeight();
173 result.reserve(h); 177 result.reserve(h);
174 178
179 #ifdef __GNUC__
175 float magnitudes[h]; 180 float magnitudes[h];
181 #else
182 float *magnitudes = (float *)alloca(h * sizeof(float));
183 #endif
176 184
177 if (m_server->getMagnitudesAt(x << m_xshift, magnitudes)) { 185 if (m_server->getMagnitudesAt(x << m_xshift, magnitudes)) {
178 186
179 for (size_t y = 0; y < h; ++y) { 187 for (size_t y = 0; y < h; ++y) {
180 result.push_back(magnitudes[y]); 188 result.push_back(magnitudes[y]);
254 int minbin = ymin; 262 int minbin = ymin;
255 if (minbin > 0) minbin = minbin - 1; 263 if (minbin > 0) minbin = minbin - 1;
256 int maxbin = ymax; 264 int maxbin = ymax;
257 if (maxbin < getHeight() - 1) maxbin = maxbin + 1; 265 if (maxbin < getHeight() - 1) maxbin = maxbin + 1;
258 const int n = maxbin - minbin + 1; 266 const int n = maxbin - minbin + 1;
267 #ifdef __GNUC__
259 float values[n]; 268 float values[n];
269 #else
270 float *values = (float *)alloca(n * sizeof(float));
271 #endif
260 getMagnitudesAt(x, values, minbin, maxbin - minbin + 1); 272 getMagnitudesAt(x, values, minbin, maxbin - minbin + 1);
261 for (size_t bin = ymin; bin <= ymax; ++bin) { 273 for (size_t bin = ymin; bin <= ymax; ++bin) {
262 if (bin == minbin || bin == maxbin) continue; 274 if (bin == minbin || bin == maxbin) continue;
263 if (values[bin - minbin] > values[bin - minbin - 1] && 275 if (values[bin - minbin] > values[bin - minbin - 1] &&
264 values[bin - minbin] > values[bin - minbin + 1]) { 276 values[bin - minbin] > values[bin - minbin + 1]) {