Mercurial > hg > constant-q-cpp
changeset 150:242bf7bc38ce
Avoid failing if min and max frequency are identical
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Thu, 10 Jul 2014 15:27:19 +0100 |
parents | 2705ca19245c |
children | 459beada2635 |
files | src/CQInverse.cpp src/ConstantQ.cpp vamp/CQChromaVamp.cpp |
diffstat | 3 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/CQInverse.cpp Thu Jul 10 15:27:09 2014 +0100 +++ b/src/CQInverse.cpp Thu Jul 10 15:27:19 2014 +0100 @@ -87,6 +87,12 @@ CQInverse::initialise() { m_octaves = int(ceil(log2(m_maxFrequency / m_minFrequency))); + + if (m_octaves < 1) { + m_kernel = 0; // incidentally causing isValid() to return false + return; + } + m_kernel = new CQKernel(m_inparams); m_p = m_kernel->getProperties();
--- a/src/ConstantQ.cpp Thu Jul 10 15:27:09 2014 +0100 +++ b/src/ConstantQ.cpp Thu Jul 10 15:27:19 2014 +0100 @@ -89,6 +89,12 @@ ConstantQ::initialise() { m_octaves = int(ceil(log2(m_maxFrequency / m_minFrequency))); + + if (m_octaves < 1) { + m_kernel = 0; // incidentally causing isValid() to return false + return; + } + m_kernel = new CQKernel(m_inparams); m_p = m_kernel->getProperties();
--- a/vamp/CQChromaVamp.cpp Thu Jul 10 15:27:09 2014 +0100 +++ b/vamp/CQChromaVamp.cpp Thu Jul 10 15:27:19 2014 +0100 @@ -241,8 +241,6 @@ void CQChromaVamp::reset() { - cerr << "reset: rate " << m_inputSampleRate << ", minf " << m_minFrequency << ", maxf " << m_maxFrequency << ", bpo " << m_bpo << endl; - delete m_cq; CQParameters p(m_inputSampleRate, m_minFrequency, m_maxFrequency, m_bpo); m_cq = new CQSpectrogram(p, CQSpectrogram::InterpolateLinear);