comparison TempogramPlugin.cpp @ 47:cb79f27f0748

Clamp cyclic tempogram min and max BPM to the BPM equivalents of the actual underlying min and max tempogram bins, rather than the "input" min and max BPM (fixed root cause of #1054)
author Chris Cannam
date Mon, 29 Sep 2014 16:20:16 +0100
parents eafb3a7f80fb
children 8c151a9ca202
comparison
equal deleted inserted replaced
46:eafb3a7f80fb 47:cb79f27f0748
554 554
555 vector< vector<unsigned int> > TempogramPlugin::calculateTempogramNearestNeighbourLogBins() const 555 vector< vector<unsigned int> > TempogramPlugin::calculateTempogramNearestNeighbourLogBins() const
556 { 556 {
557 vector< vector<unsigned int> > logBins; 557 vector< vector<unsigned int> > logBins;
558 558
559 cerr << "calculateTempogramNearestNeighbourLogBins: octaves = "
560 << m_cyclicTempogramNumberOfOctaves << endl;
561
559 for (int octave = 0; octave < (int)m_cyclicTempogramNumberOfOctaves; octave++){ 562 for (int octave = 0; octave < (int)m_cyclicTempogramNumberOfOctaves; octave++){
560 vector<unsigned int> octaveBins; 563 vector<unsigned int> octaveBins;
561 564
565 cerr << "octave " << octave << ":" << endl;
566
562 for (int bin = 0; bin < (int)m_cyclicTempogramOctaveDivider; bin++){ 567 for (int bin = 0; bin < (int)m_cyclicTempogramOctaveDivider; bin++){
563 float bpm = m_cyclicTempogramMinBPM*pow(2.0f, octave+(float)bin/m_cyclicTempogramOctaveDivider); 568 float bpm = m_cyclicTempogramMinBPM*pow(2.0f, octave+(float)bin/m_cyclicTempogramOctaveDivider);
564 octaveBins.push_back(bpmToBin(bpm)); 569 octaveBins.push_back(bpmToBin(bpm));
570 cerr << bpmToBin(bpm) << " ";
565 //cout << octaveBins.back() << endl; 571 //cout << octaveBins.back() << endl;
566 } 572 }
573 cerr << endl;
567 logBins.push_back(octaveBins); 574 logBins.push_back(octaveBins);
575
568 } 576 }
569 577
570 return logBins; 578 return logBins;
571 } 579 }
572 580
646 << " > max lag " << m_tempogramMaxLag 654 << " > max lag " << m_tempogramMaxLag
647 << ": can't proceed, failing initialise" << endl; 655 << ": can't proceed, failing initialise" << endl;
648 return false; 656 return false;
649 } 657 }
650 658
651 m_cyclicTempogramMinBPM = m_tempogramMinBPM; 659 m_cyclicTempogramMinBPM = max(binToBPM(m_tempogramMinBin), m_tempogramMinBPM);
652 float cyclicTempogramMaxBPM = m_tempogramMaxBPM; 660 float cyclicTempogramMaxBPM = min(binToBPM(m_tempogramMaxBin), m_tempogramMaxBPM);
661
662 cerr << "tempogram min bpm = " << m_tempogramMinBPM << ", cyclic min = "
663 << m_cyclicTempogramMinBPM << endl;
664 cerr << "tempogram max bpm = " << m_tempogramMaxBPM << ", cyclic max = "
665 << cyclicTempogramMaxBPM << endl;
653 666
654 m_cyclicTempogramNumberOfOctaves = floor(log2(cyclicTempogramMaxBPM/m_cyclicTempogramMinBPM)); 667 m_cyclicTempogramNumberOfOctaves = floor(log2(cyclicTempogramMaxBPM/m_cyclicTempogramMinBPM));
655 668
656 if (m_cyclicTempogramNumberOfOctaves < 1) { 669 if (m_cyclicTempogramNumberOfOctaves < 1) {
657 cerr << "At audio sample rate " << m_inputSampleRate 670 cerr << "At audio sample rate " << m_inputSampleRate