Mercurial > hg > qm-vamp-plugins
diff plugins/ChromagramPlugin.cpp @ 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 | b084e87b83e4 |
children | 49bd72df303c |
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);