comparison src/TuningDifference.cpp @ 69:c0b78dcc08e6 feature-alternatives tip

Some experimental feature adjustments - try using diffs between chroma cells (no better at first glance)
author Chris Cannam
date Fri, 16 Aug 2019 12:28:58 +0100
parents 7bdcc40deebe
children
comparison
equal deleted inserted replaced
68:8fd1c994f937 69:c0b78dcc08e6
330 } 330 }
331 331
332 template<typename T> 332 template<typename T>
333 void addTo(vector<T> &a, const vector<T> &b) 333 void addTo(vector<T> &a, const vector<T> &b)
334 { 334 {
335 transform(a.begin(), a.end(), b.begin(), a.begin(), plus<T>()); 335 int n = int(b.size());
336
337 for (int i = 0; i < n; ++i) {
338 int j = (i == 0 ? n-1 : i-1);
339 T diff = b[i] - b[j];
340 a[i] += diff;
341 }
336 } 342 }
337 343
338 template<typename T> 344 template<typename T>
339 T distance(const vector<T> &a, const vector<T> &b) 345 T distance(const vector<T> &a, const vector<T> &b)
340 { 346 {
346 TuningDifference::computeFeatureFromTotals(const TFeature &totals) const 352 TuningDifference::computeFeatureFromTotals(const TFeature &totals) const
347 { 353 {
348 if (m_frameCount == 0) return totals; 354 if (m_frameCount == 0) return totals;
349 355
350 TFeature feature(m_bpo); 356 TFeature feature(m_bpo);
351 double sum = 0.0; 357 double max = 0.0;
352 358
353 for (int i = 0; i < m_bpo; ++i) { 359 for (int i = 0; i < m_bpo; ++i) {
354 double value = totals[i] / m_frameCount; 360 double value = totals[i] / m_frameCount;
355 feature[i] += value; 361 feature[i] = value;
356 sum += value; 362 if (fabs(value) > max) {
357 } 363 max = fabs(value);
358 364 }
359 if (sum != 0.0) { 365 }
366
367 if (max > 0.0) {
360 for (int i = 0; i < m_bpo; ++i) { 368 for (int i = 0; i < m_bpo; ++i) {
361 feature[i] /= sum; 369 feature[i] /= max;
362 } 370 }
363 } 371 }
364 372
365 return feature; 373 return feature;
366 } 374 }