comparison TestDefaults.cpp @ 67:fa66ee7dcf08

VC build projects and fixes therefore. Interestingly the alloca() calls I'm replacing were all wrong
author Chris Cannam
date Wed, 07 Feb 2018 17:54:27 +0000
parents 4bd0cd3c60f3
children
comparison
equal deleted inserted replaced
66:63d6776904df 67:fa66ee7dcf08
46 using namespace std; 46 using namespace std;
47 47
48 #include <cmath> 48 #include <cmath>
49 #include <time.h> 49 #include <time.h>
50 50
51 #ifndef __GNUC__
52 #include <alloca.h>
53 #endif
54
55 Tester::TestRegistrar<TestDefaultProgram> 51 Tester::TestRegistrar<TestDefaultProgram>
56 TestDefaultProgram::m_registrar("E1", "Inconsistent default program"); 52 TestDefaultProgram::m_registrar("E1", "Inconsistent default program");
57 53
58 Tester::TestRegistrar<TestDefaultParameters> 54 Tester::TestRegistrar<TestDefaultParameters>
59 TestDefaultParameters::m_registrar("E2", "Inconsistent default parameters"); 55 TestDefaultParameters::m_registrar("E2", "Inconsistent default parameters");
80 p->selectProgram(p->getCurrentProgram()); 76 p->selectProgram(p->getCurrentProgram());
81 } 77 }
82 if (!initAdapted(p.get(), channels, _step, _step, r)) return r; 78 if (!initAdapted(p.get(), channels, _step, _step, r)) return r;
83 if (!data) data = createTestAudio(channels, _step, count); 79 if (!data) data = createTestAudio(channels, _step, count);
84 for (size_t i = 0; i < count; ++i) { 80 for (size_t i = 0; i < count; ++i) {
85 #ifdef __GNUC__ 81 float **ptr = new float *[channels];
86 float *ptr[channels];
87 #else
88 float **ptr = (float **)alloca(channels * sizeof(float));
89 #endif
90 size_t idx = i * _step; 82 size_t idx = i * _step;
91 for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx; 83 for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx;
92 RealTime timestamp = RealTime::frame2RealTime(idx, rate); 84 RealTime timestamp = RealTime::frame2RealTime(idx, rate);
93 Plugin::FeatureSet fs = p->process(ptr, timestamp); 85 Plugin::FeatureSet fs = p->process(ptr, timestamp);
86 delete[] ptr;
94 appendFeatures(f[run], fs); 87 appendFeatures(f[run], fs);
95 } 88 }
96 Plugin::FeatureSet fs = p->getRemainingFeatures(); 89 Plugin::FeatureSet fs = p->getRemainingFeatures();
97 appendFeatures(f[run], fs); 90 appendFeatures(f[run], fs);
98 } 91 }
140 } 133 }
141 } 134 }
142 if (!initAdapted(p.get(), channels, _step, _step, r)) return r; 135 if (!initAdapted(p.get(), channels, _step, _step, r)) return r;
143 if (!data) data = createTestAudio(channels, _step, count); 136 if (!data) data = createTestAudio(channels, _step, count);
144 for (size_t i = 0; i < count; ++i) { 137 for (size_t i = 0; i < count; ++i) {
145 #ifdef __GNUC__ 138 float **ptr = new float *[channels];
146 float *ptr[channels];
147 #else
148 float **ptr = (float **)alloca(channels * sizeof(float));
149 #endif
150 size_t idx = i * _step; 139 size_t idx = i * _step;
151 for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx; 140 for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx;
152 RealTime timestamp = RealTime::frame2RealTime(idx, rate); 141 RealTime timestamp = RealTime::frame2RealTime(idx, rate);
153 Plugin::FeatureSet fs = p->process(ptr, timestamp); 142 Plugin::FeatureSet fs = p->process(ptr, timestamp);
143 delete[] ptr;
154 appendFeatures(f[run], fs); 144 appendFeatures(f[run], fs);
155 } 145 }
156 Plugin::FeatureSet fs = p->getRemainingFeatures(); 146 Plugin::FeatureSet fs = p->getRemainingFeatures();
157 appendFeatures(f[run], fs); 147 appendFeatures(f[run], fs);
158 } 148 }
254 // We expect these to produce the same results 244 // We expect these to produce the same results
255 if (run == 1) p->reset(); 245 if (run == 1) p->reset();
256 246
257 if (!data) data = createTestAudio(channels, _step, count); 247 if (!data) data = createTestAudio(channels, _step, count);
258 for (size_t i = 0; i < count; ++i) { 248 for (size_t i = 0; i < count; ++i) {
259 #ifdef __GNUC__ 249 float **ptr = new float *[channels];
260 float *ptr[channels];
261 #else
262 float **ptr = (float **)alloca(channels * sizeof(float));
263 #endif
264 size_t idx = i * _step; 250 size_t idx = i * _step;
265 for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx; 251 for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx;
266 RealTime timestamp = RealTime::frame2RealTime(idx, rate); 252 RealTime timestamp = RealTime::frame2RealTime(idx, rate);
267 Plugin::FeatureSet fs = p->process(ptr, timestamp); 253 Plugin::FeatureSet fs = p->process(ptr, timestamp);
254 delete[] ptr;
268 appendFeatures(f[run], fs); 255 appendFeatures(f[run], fs);
269 } 256 }
270 Plugin::FeatureSet fs = p->getRemainingFeatures(); 257 Plugin::FeatureSet fs = p->getRemainingFeatures();
271 appendFeatures(f[run], fs); 258 appendFeatures(f[run], fs);
272 } 259 }