Mercurial > hg > vamp-tempogram
changeset 36:4010960c659e
* Merge with Chris' changes
author | Carl Bussey <c.bussey@se10.qmul.ac.uk> |
---|---|
date | Thu, 04 Sep 2014 14:33:36 +0100 |
parents | c8dd1049b2d3 (current diff) 2b2e707c8c20 (diff) |
children | 44d8e5dc1902 |
files | |
diffstat | 3 files changed, 36 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/NoveltyCurveProcessor.cpp Thu Sep 04 14:12:03 2014 +0100 +++ b/NoveltyCurveProcessor.cpp Thu Sep 04 14:33:36 2014 +0100 @@ -37,9 +37,11 @@ for (unsigned int band = 1; band < m_numberOfBands; band++){ float lowFreq = 500*pow(2.5, (int)band-1); m_pBandBoundaries[band] = m_fftLength*lowFreq/m_samplingFrequency; + if (m_pBandBoundaries[band] > (int)m_blockSize) { + m_pBandBoundaries[band] = m_blockSize; + } } m_pBandBoundaries[m_numberOfBands] = m_blockSize; - m_pBandSum = new float [m_numberOfBands]; }
--- a/SpectrogramProcessor.h Thu Sep 04 14:12:03 2014 +0100 +++ b/SpectrogramProcessor.h Thu Sep 04 14:33:36 2014 +0100 @@ -11,7 +11,7 @@ #include <vector> #include <vamp-sdk/FFT.h> #include <cmath> -#include <stddef.h> +#include <cstddef> typedef std::vector <std::vector<float> > Spectrogram; typedef std::vector <std::vector<float> > SpectrogramTransposed;
--- a/TempogramPlugin.cpp Thu Sep 04 14:12:03 2014 +0100 +++ b/TempogramPlugin.cpp Thu Sep 04 14:33:36 2014 +0100 @@ -526,7 +526,18 @@ float sum = 0; for (int j = 0; j < m_cyclicTempogramNumberOfOctaves; j++){ - sum += tempogramDFT[block][logBins[j][i]]; + + if (block >= tempogramDFT.size()) { + cerr << "ERROR: at block = " << block << ", i = " << i << ", j = " << j << ": block " << block << " >= tempogramDFT.size() " << tempogramDFT.size() << endl; + } else if (j > logBins.size()) { + cerr << "ERROR: at block = " << block << ", i = " << i << ", j = " << j << ": j " << j << " >= logBins.size() " << logBins.size() << endl; + } else if (i > logBins[j].size()) { + cerr << "ERROR: at block = " << block << ", i = " << i << ", j = " << j << ": i " << i << " >= logBins[j].size() " << logBins[j].size() << endl; + } else if (logBins[j][i] >= tempogramDFT[block].size()) { + cerr << "ERROR: at block = " << block << ", i = " << i << ", j = " << j << ": logBins[j][i] " << logBins[j][i] << " >= tempogramDFT[block].size() " << tempogramDFT[block].size() << endl; + } else { + sum += tempogramDFT[block][logBins[j][i]]; + } } cyclicTempogramFeature.values.push_back(sum/m_cyclicTempogramNumberOfOctaves); assert(!isnan(cyclicTempogramFeature.values.back())); @@ -601,9 +612,29 @@ float tempogramInputSampleRate = (float)m_inputSampleRate/m_inputStepSize; m_tempogramMinBin = (max((int)floor(((m_tempogramMinBPM/60)/tempogramInputSampleRate)*m_tempogramFftLength), 0)); m_tempogramMaxBin = (min((int)ceil(((m_tempogramMaxBPM/60)/tempogramInputSampleRate)*m_tempogramFftLength), (int)(m_tempogramFftLength/2))); + + if (m_tempogramMaxBin < m_tempogramMinBin) { + cerr << "At audio sample rate " << m_inputSampleRate + << ", tempogram sample rate " << tempogramInputSampleRate + << " with bpm range " << m_tempogramMinBPM << " -> " + << m_tempogramMaxBPM << ", min bin = " << m_tempogramMinBin + << " > max bin " << m_tempogramMaxBin + << ": can't proceed, failing initialise" << endl; + return false; + } m_tempogramMinLag = max((int)ceil((60/(m_inputStepSize * m_tempogramMaxBPM))*m_inputSampleRate), 0); m_tempogramMaxLag = min((int)floor((60/(m_inputStepSize * m_tempogramMinBPM))*m_inputSampleRate), (int)m_tempogramWindowLength); + + if (m_tempogramMaxLag < m_tempogramMinLag) { + cerr << "At audio sample rate " << m_inputSampleRate + << ", tempogram sample rate " << tempogramInputSampleRate + << " with bpm range " << m_tempogramMinBPM << " -> " + << m_tempogramMaxBPM << ", min bin = " << m_tempogramMinLag + << " > max bin " << 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;