comparison examples/FixedTempoEstimator.cpp @ 244:8042ab66f707

* tidy
author cannam
date Mon, 10 Nov 2008 22:10:20 +0000
parents 3cf5bd155e5b
children 5bfed156b45d
comparison
equal deleted inserted replaced
243:3cf5bd155e5b 244:8042ab66f707
365 } 365 }
366 366
367 void 367 void
368 FixedTempoEstimator::D::calculate() 368 FixedTempoEstimator::D::calculate()
369 { 369 {
370 cerr << "FixedTempoEstimator::calculate: m_n = " << m_n << endl;
371
372 if (m_r) { 370 if (m_r) {
373 cerr << "FixedTempoEstimator::calculate: calculation already happened?" << endl; 371 cerr << "FixedTempoEstimator::calculate: calculation already happened?" << endl;
374 return; 372 return;
375 } 373 }
376 374
445 } 443 }
446 } 444 }
447 445
448 m_t[i] /= div; 446 m_t[i] /= div;
449 447
450 // if (div > 1) {
451 // cerr << "adjusting tempo from " << lag2tempo(i) << " to "
452 // << m_t[i] << " for fr = " << m_fr[i] << " (div = " << div << ")" << endl;
453 // }
454
455 m_fr[i] += m_fr[i] * (weight / 3); 448 m_fr[i] += m_fr[i] * (weight / 3);
456 } 449 }
457 } 450 }
458 451
459 FixedTempoEstimator::FeatureSet 452 FixedTempoEstimator::FeatureSet
497 int p0 = tempo2lag(t1); 490 int p0 = tempo2lag(t1);
498 int p1 = tempo2lag(t0); 491 int p1 = tempo2lag(t0);
499 492
500 std::map<float, int> candidates; 493 std::map<float, int> candidates;
501 494
502 std::cerr << "minbpm = " << m_minbpm << ", p0 = " << p0 << ", p1 = " << p1 << std::endl;
503
504 for (int i = p0; i <= p1 && i < n/2-1; ++i) { 495 for (int i = p0; i <= p1 && i < n/2-1; ++i) {
505 496
506 if (m_fr[i] > m_fr[i-1] && 497 if (m_fr[i] > m_fr[i-1] &&
507 m_fr[i] > m_fr[i+1]) { 498 m_fr[i] > m_fr[i+1]) {
508 candidates[m_fr[i]] = i; 499 candidates[m_fr[i]] = i;
515 if (i == p1 || i == n/2-2) feature.label = ""; 506 if (i == p1 || i == n/2-2) feature.label = "";
516 else feature.label = buffer; 507 else feature.label = buffer;
517 fs[FilteredACFOutput].push_back(feature); 508 fs[FilteredACFOutput].push_back(feature);
518 } 509 }
519 510
520 // cerr << "maxpi = " << maxpi << " for tempo " << lag2tempo(maxpi) << " (value = " << maxp << ")" << endl;
521
522 if (candidates.empty()) { 511 if (candidates.empty()) {
523 cerr << "No tempo candidates!" << endl; 512 cerr << "No tempo candidates!" << endl;
524 return fs; 513 return fs;
525 } 514 }
526 515
550 539
551 feature.values.clear(); 540 feature.values.clear();
552 feature.label = ""; 541 feature.label = "";
553 542
554 while (feature.values.size() < 8) { 543 while (feature.values.size() < 8) {
555 // cerr << "adding tempo value from lag " << ci->second << endl;
556 if (m_t[ci->second] > 0) { 544 if (m_t[ci->second] > 0) {
557 feature.values.push_back(m_t[ci->second]); 545 feature.values.push_back(m_t[ci->second]);
558 } else { 546 } else {
559 feature.values.push_back(lag2tempo(ci->second)); 547 feature.values.push_back(lag2tempo(ci->second));
560 } 548 }