Mercurial > hg > qm-vamp-plugins
changeset 75:a99c43f470a5
* oh dear. fix some off-by-one errors leading to using uninitialised
values in chromagram, constant-q, and mfcc calculations.
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Thu, 24 Jul 2008 16:04:43 +0000 |
parents | 3d16c2f1998a |
children | 29afde113a5b |
files | plugins/ChromagramPlugin.cpp plugins/ConstantQSpectrogram.cpp plugins/MFCCPlugin.cpp qm-vamp-plugins.pro |
diffstat | 4 files changed, 31 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ChromagramPlugin.cpp Wed Jul 16 08:01:00 2008 +0000 +++ b/plugins/ChromagramPlugin.cpp Thu Jul 24 16:04:43 2008 +0000 @@ -318,7 +318,7 @@ ChromagramPlugin::FeatureSet ChromagramPlugin::process(const float *const *inputBuffers, - Vamp::RealTime /* timestamp */) + Vamp::RealTime timestamp) { if (!m_chromagram) { cerr << "ERROR: ChromagramPlugin::process: " @@ -330,13 +330,28 @@ double *real = new double[m_block]; double *imag = new double[m_block]; - for (size_t i = 0; i < m_block/2; ++i) { + for (size_t i = 0; i <= m_block/2; ++i) { real[i] = inputBuffers[0][i*2]; if (i > 0) real[m_block - i] = real[i]; imag[i] = inputBuffers[0][i*2+1]; if (i > 0) imag[m_block - i] = imag[i]; } +// cerr << "chromagram: timestamp = " << timestamp << endl; +/* + bool printThis = false; + + if (timestamp.sec == 3 && timestamp.nsec < 250000000) { + printThis = true; + } + if (printThis) { + cerr << "\n\nchromagram: timestamp " << timestamp << ": input data starts:" << endl; + for (int i = 0; i < m_block && i < 1000; ++i) { + cerr << real[i] << "," << imag[i] << " "; + } + cerr << endl << "values:" << endl; + } +*/ double *output = m_chromagram->process(real, imag); delete[] real; @@ -346,12 +361,22 @@ feature.hasTimestamp = false; for (size_t i = 0; i < m_config.BPO; ++i) { double value = output[i]; +/* + if (printThis) { + cerr << value << " "; + } +*/ if (isnan(value)) value = 0.0; m_binsums[i] += value; feature.values.push_back(value); } feature.label = ""; ++m_count; +/* + if (printThis) { + cerr << endl; + } +*/ FeatureSet returnFeatures; returnFeatures[0].push_back(feature);
--- a/plugins/ConstantQSpectrogram.cpp Wed Jul 16 08:01:00 2008 +0000 +++ b/plugins/ConstantQSpectrogram.cpp Thu Jul 24 16:04:43 2008 +0000 @@ -339,7 +339,7 @@ double *cqre = new double[m_bins]; double *cqim = new double[m_bins]; - for (size_t i = 0; i < m_block/2; ++i) { + for (size_t i = 0; i <= m_block/2; ++i) { real[i] = inputBuffers[0][i*2]; if (i > 0) real[m_block - i] = real[i]; imag[i] = inputBuffers[0][i*2+1];
--- a/plugins/MFCCPlugin.cpp Wed Jul 16 08:01:00 2008 +0000 +++ b/plugins/MFCCPlugin.cpp Thu Jul 24 16:04:43 2008 +0000 @@ -256,7 +256,7 @@ double *real = new double[m_block]; double *imag = new double[m_block]; - for (size_t i = 0; i < m_block/2; ++i) { + for (size_t i = 0; i <= m_block/2; ++i) { real[i] = inputBuffers[0][i*2]; if (i > 0) real[m_block - i] = real[i]; imag[i] = inputBuffers[0][i*2+1];
--- a/qm-vamp-plugins.pro Wed Jul 16 08:01:00 2008 +0000 +++ b/qm-vamp-plugins.pro Thu Jul 24 16:04:43 2008 +0000 @@ -1,10 +1,10 @@ TEMPLATE = lib -CONFIG += plugin warn_on release +CONFIG += plugin warn_on debug CONFIG -= qt -linux-g++:QMAKE_CXXFLAGS_RELEASE += -DNDEBUG -O3 -fno-exceptions -fPIC -march=pentium3 -mfpmath=sse -msse -ffast-math +linux-g++:QMAKE_CXXFLAGS_RELEASE += -DNDEBUG -O3 -fPIC -march=pentium3 -mfpmath=sse -msse OBJECTS_DIR = tmp_obj MOC_DIR = tmp_moc