Mercurial > hg > vamp-tempogram
changeset 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 |
files | TempogramPlugin.cpp |
diffstat | 1 files changed, 32 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/TempogramPlugin.cpp Fri Sep 12 16:00:26 2014 +0100 +++ b/TempogramPlugin.cpp Fri Sep 12 18:02:08 2014 +0100 @@ -188,7 +188,7 @@ d5.unit = ""; d5.minValue = 6; d5.maxValue = 12; - d5.defaultValue = d2.defaultValue; + d5.defaultValue = 10; d5.isQuantized = true; d5.quantizeStep = 1; for (int i = d5.minValue; i <= d5.maxValue; i++){ @@ -329,7 +329,6 @@ float d_sampleRate; float tempogramInputSampleRate = (float)m_inputSampleRate/m_inputStepSize; - OutputDescriptor d1; d1.identifier = "cyclicTempogram"; d1.name = "Cyclic Tempogram"; @@ -557,8 +556,6 @@ logBins.push_back(octaveBins); } - //cerr << logBins.size() << endl; - return logBins; } @@ -583,9 +580,20 @@ bool TempogramPlugin::handleParameterValues(){ - if (m_tempogramLog2HopSize <= 0) return false; - if (m_tempogramLog2FftLength <= 0) return false; + if (m_tempogramLog2HopSize <= 0) { + cerr << "Tempogram log2 hop size " << m_tempogramLog2HopSize + << " <= 0, failing initialise" << endl; + return false; + } + if (m_tempogramLog2FftLength <= 0) { + cerr << "Tempogram log2 fft length " << m_tempogramLog2FftLength + << " <= 0, failing initialise" << endl; + return false; + } + if (m_tempogramMinBPM < 1) { + m_tempogramMinBPM = 1; + } if (m_tempogramMinBPM >= m_tempogramMaxBPM){ m_tempogramMinBPM = 30; m_tempogramMaxBPM = 480; @@ -621,18 +629,30 @@ if (m_tempogramMaxLag < m_tempogramMinLag) { cerr << "At audio sample rate " << m_inputSampleRate << ", tempogram sample rate " << tempogramInputSampleRate + << ", window length " << m_tempogramWindowLength << " with bpm range " << m_tempogramMinBPM << " -> " - << m_tempogramMaxBPM << ", min bin = " << m_tempogramMinLag - << " > max bin " << m_tempogramMaxLag + << m_tempogramMaxBPM << ", min lag = " << m_tempogramMinLag + << " > max lag " << m_tempogramMaxLag << ": can't proceed, failing initialise" << endl; return false; } - if (m_tempogramMinBPM > m_cyclicTempogramMinBPM) m_cyclicTempogramMinBPM = m_tempogramMinBPM; //m_cyclicTempogram can't be less than default = 30 - float cyclicTempogramMaxBPM = 480; - if (m_tempogramMaxBPM < cyclicTempogramMaxBPM) cyclicTempogramMaxBPM = m_tempogramMaxBPM; - + m_cyclicTempogramMinBPM = m_tempogramMinBPM; + float cyclicTempogramMaxBPM = m_tempogramMaxBPM; + m_cyclicTempogramNumberOfOctaves = floor(log2(cyclicTempogramMaxBPM/m_cyclicTempogramMinBPM)); + + if (m_cyclicTempogramNumberOfOctaves < 1) { + cerr << "At audio sample rate " << m_inputSampleRate + << ", tempogram sample rate " << tempogramInputSampleRate + << " with bpm range " << m_tempogramMinBPM << " -> " + << m_tempogramMaxBPM << ", cyclic tempogram min bpm = " + << m_cyclicTempogramMinBPM << " and max bpm = " + << cyclicTempogramMaxBPM << " giving number of octaves = " + << m_cyclicTempogramNumberOfOctaves + << ": can't proceed, failing initialise" << endl; + return false; + } return true; }