Mercurial > hg > vamp-tempogram
comparison TempogramPlugin.cpp @ 32:023d12fb71b1
Some sample rate / parameter combinations result in min bin > max bin -- reject them
author | Chris Cannam |
---|---|
date | Thu, 04 Sep 2014 10:08:47 +0100 |
parents | 36cffe6493e4 |
children | 2b2e707c8c20 |
comparison
equal
deleted
inserted
replaced
31:f795b84c1ff2 | 32:023d12fb71b1 |
---|---|
599 } | 599 } |
600 | 600 |
601 float tempogramInputSampleRate = (float)m_inputSampleRate/m_inputStepSize; | 601 float tempogramInputSampleRate = (float)m_inputSampleRate/m_inputStepSize; |
602 m_tempogramMinBin = (max((int)floor(((m_tempogramMinBPM/60)/tempogramInputSampleRate)*m_tempogramFftLength), 0)); | 602 m_tempogramMinBin = (max((int)floor(((m_tempogramMinBPM/60)/tempogramInputSampleRate)*m_tempogramFftLength), 0)); |
603 m_tempogramMaxBin = (min((int)ceil(((m_tempogramMaxBPM/60)/tempogramInputSampleRate)*m_tempogramFftLength), (int)(m_tempogramFftLength/2))); | 603 m_tempogramMaxBin = (min((int)ceil(((m_tempogramMaxBPM/60)/tempogramInputSampleRate)*m_tempogramFftLength), (int)(m_tempogramFftLength/2))); |
604 | |
605 if (m_tempogramMaxBin < m_tempogramMinBin) { | |
606 cerr << "At audio sample rate " << m_inputSampleRate | |
607 << ", tempogram sample rate " << tempogramInputSampleRate | |
608 << " with bpm range " << m_tempogramMinBPM << " -> " | |
609 << m_tempogramMaxBPM << ", min bin = " << m_tempogramMinBin | |
610 << " > max bin " << m_tempogramMaxBin | |
611 << ": can't proceed, failing initialise" << endl; | |
612 return false; | |
613 } | |
604 | 614 |
605 m_tempogramMinLag = max((int)ceil((60/(m_inputStepSize * m_tempogramMaxBPM))*m_inputSampleRate), 0); | 615 m_tempogramMinLag = max((int)ceil((60/(m_inputStepSize * m_tempogramMaxBPM))*m_inputSampleRate), 0); |
606 m_tempogramMaxLag = min((int)floor((60/(m_inputStepSize * m_tempogramMinBPM))*m_inputSampleRate), (int)m_tempogramWindowLength); | 616 m_tempogramMaxLag = min((int)floor((60/(m_inputStepSize * m_tempogramMinBPM))*m_inputSampleRate), (int)m_tempogramWindowLength); |
617 | |
618 if (m_tempogramMaxLag < m_tempogramMinLag) { | |
619 cerr << "At audio sample rate " << m_inputSampleRate | |
620 << ", tempogram sample rate " << tempogramInputSampleRate | |
621 << " with bpm range " << m_tempogramMinBPM << " -> " | |
622 << m_tempogramMaxBPM << ", min bin = " << m_tempogramMinLag | |
623 << " > max bin " << m_tempogramMaxLag | |
624 << ": can't proceed, failing initialise" << endl; | |
625 return false; | |
626 } | |
607 | 627 |
608 if (m_tempogramMinBPM > m_cyclicTempogramMinBPM) m_cyclicTempogramMinBPM = m_tempogramMinBPM; //m_cyclicTempogram can't be less than default = 30 | 628 if (m_tempogramMinBPM > m_cyclicTempogramMinBPM) m_cyclicTempogramMinBPM = m_tempogramMinBPM; //m_cyclicTempogram can't be less than default = 30 |
609 float cyclicTempogramMaxBPM = 480; | 629 float cyclicTempogramMaxBPM = 480; |
610 if (m_tempogramMaxBPM < cyclicTempogramMaxBPM) cyclicTempogramMaxBPM = m_tempogramMaxBPM; | 630 if (m_tempogramMaxBPM < cyclicTempogramMaxBPM) cyclicTempogramMaxBPM = m_tempogramMaxBPM; |
611 | 631 |