comparison examples/SpectralCentroid.cpp @ 210:a5187dad96cd

* Add example plugins VC project -- though it doesn't produce a working library yet
author cannam
date Fri, 17 Oct 2008 21:59:35 +0000
parents 1982246a3902
children
comparison
equal deleted inserted replaced
209:0f6616ef0e18 210:a5187dad96cd
39 using std::string; 39 using std::string;
40 using std::vector; 40 using std::vector;
41 using std::cerr; 41 using std::cerr;
42 using std::endl; 42 using std::endl;
43 43
44 #include <cmath> 44 #include <math.h>
45 45
46 #ifdef WIN32
47 #define isnan(x) false
48 #define isinf(x) false
49 #endif
46 50
47 SpectralCentroid::SpectralCentroid(float inputSampleRate) : 51 SpectralCentroid::SpectralCentroid(float inputSampleRate) :
48 Plugin(inputSampleRate), 52 Plugin(inputSampleRate),
49 m_stepSize(0), 53 m_stepSize(0),
50 m_blockSize(0) 54 m_blockSize(0)
167 float centroidLin = float(numLin / denom); 171 float centroidLin = float(numLin / denom);
168 float centroidLog = powf(10, float(numLog / denom)); 172 float centroidLog = powf(10, float(numLog / denom));
169 173
170 Feature feature; 174 Feature feature;
171 feature.hasTimestamp = false; 175 feature.hasTimestamp = false;
172 if (!std::isnan(centroidLog) && !std::isinf(centroidLog)) { 176 if (!isnan(centroidLog) && !isinf(centroidLog)) {
173 feature.values.push_back(centroidLog); 177 feature.values.push_back(centroidLog);
174 } 178 }
175 returnFeatures[0].push_back(feature); 179 returnFeatures[0].push_back(feature);
176 180
177 feature.values.clear(); 181 feature.values.clear();
178 if (!std::isnan(centroidLin) && !std::isinf(centroidLin)) { 182 if (!isnan(centroidLin) && !isinf(centroidLin)) {
179 feature.values.push_back(centroidLin); 183 feature.values.push_back(centroidLin);
180 } 184 }
181 returnFeatures[1].push_back(feature); 185 returnFeatures[1].push_back(feature);
182 } 186 }
183 187
184 return returnFeatures; 188 return returnFeatures;
185 } 189 }