Mercurial > hg > vamp-tempogram
comparison TempogramPlugin.cpp @ 42:d4b74059a005
Fix an incorrect default value; add some checks and warnings
author | Chris Cannam |
---|---|
date | Fri, 12 Sep 2014 18:02:08 +0100 |
parents | 89af6709f562 |
children | 4cf2d163127b |
comparison
equal
deleted
inserted
replaced
41:89af6709f562 | 42:d4b74059a005 |
---|---|
186 d5.name = "Tempogram FFT Length"; | 186 d5.name = "Tempogram FFT Length"; |
187 d5.description = "FFT length when analysing the novelty curve and extracting the tempogram time-frequency function. This parameter determines the amount of zero padding."; | 187 d5.description = "FFT length when analysing the novelty curve and extracting the tempogram time-frequency function. This parameter determines the amount of zero padding."; |
188 d5.unit = ""; | 188 d5.unit = ""; |
189 d5.minValue = 6; | 189 d5.minValue = 6; |
190 d5.maxValue = 12; | 190 d5.maxValue = 12; |
191 d5.defaultValue = d2.defaultValue; | 191 d5.defaultValue = 10; |
192 d5.isQuantized = true; | 192 d5.isQuantized = true; |
193 d5.quantizeStep = 1; | 193 d5.quantizeStep = 1; |
194 for (int i = d5.minValue; i <= d5.maxValue; i++){ | 194 for (int i = d5.minValue; i <= d5.maxValue; i++){ |
195 d5.valueNames.push_back(floatToString(pow((float)2,(float)i))); | 195 d5.valueNames.push_back(floatToString(pow((float)2,(float)i))); |
196 } | 196 } |
327 // See OutputDescriptor documentation for the possibilities here. | 327 // See OutputDescriptor documentation for the possibilities here. |
328 // Every plugin must have at least one output. | 328 // Every plugin must have at least one output. |
329 | 329 |
330 float d_sampleRate; | 330 float d_sampleRate; |
331 float tempogramInputSampleRate = (float)m_inputSampleRate/m_inputStepSize; | 331 float tempogramInputSampleRate = (float)m_inputSampleRate/m_inputStepSize; |
332 | |
333 OutputDescriptor d1; | 332 OutputDescriptor d1; |
334 d1.identifier = "cyclicTempogram"; | 333 d1.identifier = "cyclicTempogram"; |
335 d1.name = "Cyclic Tempogram"; | 334 d1.name = "Cyclic Tempogram"; |
336 d1.description = "Cyclic Tempogram"; | 335 d1.description = "Cyclic Tempogram"; |
337 d1.unit = ""; | 336 d1.unit = ""; |
555 //cout << octaveBins.back() << endl; | 554 //cout << octaveBins.back() << endl; |
556 } | 555 } |
557 logBins.push_back(octaveBins); | 556 logBins.push_back(octaveBins); |
558 } | 557 } |
559 | 558 |
560 //cerr << logBins.size() << endl; | |
561 | |
562 return logBins; | 559 return logBins; |
563 } | 560 } |
564 | 561 |
565 unsigned int TempogramPlugin::bpmToBin(const float &bpm) const | 562 unsigned int TempogramPlugin::bpmToBin(const float &bpm) const |
566 { | 563 { |
581 return (bin*sampleRate/m_tempogramFftLength)*60; | 578 return (bin*sampleRate/m_tempogramFftLength)*60; |
582 } | 579 } |
583 | 580 |
584 bool TempogramPlugin::handleParameterValues(){ | 581 bool TempogramPlugin::handleParameterValues(){ |
585 | 582 |
586 if (m_tempogramLog2HopSize <= 0) return false; | 583 if (m_tempogramLog2HopSize <= 0) { |
587 if (m_tempogramLog2FftLength <= 0) return false; | 584 cerr << "Tempogram log2 hop size " << m_tempogramLog2HopSize |
588 | 585 << " <= 0, failing initialise" << endl; |
586 return false; | |
587 } | |
588 if (m_tempogramLog2FftLength <= 0) { | |
589 cerr << "Tempogram log2 fft length " << m_tempogramLog2FftLength | |
590 << " <= 0, failing initialise" << endl; | |
591 return false; | |
592 } | |
593 | |
594 if (m_tempogramMinBPM < 1) { | |
595 m_tempogramMinBPM = 1; | |
596 } | |
589 if (m_tempogramMinBPM >= m_tempogramMaxBPM){ | 597 if (m_tempogramMinBPM >= m_tempogramMaxBPM){ |
590 m_tempogramMinBPM = 30; | 598 m_tempogramMinBPM = 30; |
591 m_tempogramMaxBPM = 480; | 599 m_tempogramMaxBPM = 480; |
592 } | 600 } |
593 | 601 |
619 m_tempogramMaxLag = min((int)floor((60/(m_inputStepSize * m_tempogramMinBPM))*m_inputSampleRate), (int)m_tempogramWindowLength); | 627 m_tempogramMaxLag = min((int)floor((60/(m_inputStepSize * m_tempogramMinBPM))*m_inputSampleRate), (int)m_tempogramWindowLength); |
620 | 628 |
621 if (m_tempogramMaxLag < m_tempogramMinLag) { | 629 if (m_tempogramMaxLag < m_tempogramMinLag) { |
622 cerr << "At audio sample rate " << m_inputSampleRate | 630 cerr << "At audio sample rate " << m_inputSampleRate |
623 << ", tempogram sample rate " << tempogramInputSampleRate | 631 << ", tempogram sample rate " << tempogramInputSampleRate |
632 << ", window length " << m_tempogramWindowLength | |
624 << " with bpm range " << m_tempogramMinBPM << " -> " | 633 << " with bpm range " << m_tempogramMinBPM << " -> " |
625 << m_tempogramMaxBPM << ", min bin = " << m_tempogramMinLag | 634 << m_tempogramMaxBPM << ", min lag = " << m_tempogramMinLag |
626 << " > max bin " << m_tempogramMaxLag | 635 << " > max lag " << m_tempogramMaxLag |
627 << ": can't proceed, failing initialise" << endl; | 636 << ": can't proceed, failing initialise" << endl; |
628 return false; | 637 return false; |
629 } | 638 } |
630 | 639 |
631 if (m_tempogramMinBPM > m_cyclicTempogramMinBPM) m_cyclicTempogramMinBPM = m_tempogramMinBPM; //m_cyclicTempogram can't be less than default = 30 | 640 m_cyclicTempogramMinBPM = m_tempogramMinBPM; |
632 float cyclicTempogramMaxBPM = 480; | 641 float cyclicTempogramMaxBPM = m_tempogramMaxBPM; |
633 if (m_tempogramMaxBPM < cyclicTempogramMaxBPM) cyclicTempogramMaxBPM = m_tempogramMaxBPM; | 642 |
634 | |
635 m_cyclicTempogramNumberOfOctaves = floor(log2(cyclicTempogramMaxBPM/m_cyclicTempogramMinBPM)); | 643 m_cyclicTempogramNumberOfOctaves = floor(log2(cyclicTempogramMaxBPM/m_cyclicTempogramMinBPM)); |
644 | |
645 if (m_cyclicTempogramNumberOfOctaves < 1) { | |
646 cerr << "At audio sample rate " << m_inputSampleRate | |
647 << ", tempogram sample rate " << tempogramInputSampleRate | |
648 << " with bpm range " << m_tempogramMinBPM << " -> " | |
649 << m_tempogramMaxBPM << ", cyclic tempogram min bpm = " | |
650 << m_cyclicTempogramMinBPM << " and max bpm = " | |
651 << cyclicTempogramMaxBPM << " giving number of octaves = " | |
652 << m_cyclicTempogramNumberOfOctaves | |
653 << ": can't proceed, failing initialise" << endl; | |
654 return false; | |
655 } | |
636 | 656 |
637 return true; | 657 return true; |
638 } | 658 } |
639 | 659 |
640 string TempogramPlugin::floatToString(float value) const | 660 string TempogramPlugin::floatToString(float value) const |