Mercurial > hg > qm-vamp-plugins
changeset 17:d4a92aab8147
* Fix a buffer overrun and some compile warnings
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Thu, 30 Nov 2006 14:53:29 +0000 |
parents | 2fbfe5e42ad4 |
children | 99dadc93042e |
files | plugins/ChromagramPlugin.cpp plugins/ConstantQSpectrogram.cpp |
diffstat | 2 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ChromagramPlugin.cpp Fri Oct 13 12:28:44 2006 +0000 +++ b/plugins/ChromagramPlugin.cpp Thu Nov 30 14:53:29 2006 +0000 @@ -268,7 +268,7 @@ int ipc = m_minMIDIPitch % 12; int index = (i + ipc) % 12; d.binNames.push_back(names[index]); - for (int j = 0; j < d.binCount / 12 - 1; ++j) { + for (int j = 0; j < int(d.binCount) / 12 - 1; ++j) { d.binNames.push_back(""); } } @@ -323,9 +323,9 @@ for (size_t i = 0; i < m_block/2; ++i) { real[i] = inputBuffers[0][i*2]; - real[m_block - i] = real[i]; + if (i > 0) real[m_block - i] = real[i]; imag[i] = inputBuffers[0][i*2+1]; - imag[m_block - i] = imag[i]; + if (i > 0) imag[m_block - i] = imag[i]; } double *output = m_chromagram->process(real, imag);
--- a/plugins/ConstantQSpectrogram.cpp Fri Oct 13 12:28:44 2006 +0000 +++ b/plugins/ConstantQSpectrogram.cpp Thu Nov 30 14:53:29 2006 +0000 @@ -19,10 +19,10 @@ ConstantQSpectrogram::ConstantQSpectrogram(float inputSampleRate) : Vamp::Plugin(inputSampleRate), + m_bins(1), m_cq(0), m_step(0), - m_block(0), - m_bins(1) + m_block(0) { m_minMIDIPitch = 12; m_maxMIDIPitch = 96; @@ -267,7 +267,7 @@ { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; if (m_bpo == 12) { - for (int i = 0; i < d.binCount; ++i) { + for (int i = 0; i < int(d.binCount); ++i) { int ipc = m_minMIDIPitch % 12; int index = (i + ipc) % 12; d.binNames.push_back(names[index]); @@ -325,9 +325,9 @@ for (size_t i = 0; i < m_block/2; ++i) { real[i] = inputBuffers[0][i*2]; - real[m_block - i] = real[i]; + if (i > 0) real[m_block - i] = real[i]; imag[i] = inputBuffers[0][i*2+1]; - imag[m_block - i] = imag[i]; + if (i > 0) imag[m_block - i] = imag[i]; } m_cq->process(real, imag, cqre, cqim); @@ -337,7 +337,7 @@ Feature feature; feature.hasTimestamp = false; - for (size_t i = 0; i < m_bins; ++i) { + for (int i = 0; i < m_bins; ++i) { double re = cqre[i]; double im = cqim[i]; if (isnan(re)) re = 0.0;