Mercurial > hg > qm-vamp-plugins
changeset 7:641ce27165bd
* Make chromagram take input in frequency domain. This means we can avoid
any bother with zero-padding at the front and end, etc, and misalignments
because the host provides fft windows properly centred in the first place.
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Mon, 15 May 2006 15:08:17 +0000 |
parents | d00c1bad7332 |
children | a8215973f030 |
files | plugins/ChromagramPlugin.cpp plugins/ChromagramPlugin.h |
diffstat | 2 files changed, 18 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ChromagramPlugin.cpp Mon May 15 12:07:44 2006 +0000 +++ b/plugins/ChromagramPlugin.cpp Mon May 15 15:08:17 2006 +0000 @@ -21,8 +21,7 @@ Vamp::Plugin(inputSampleRate), m_chromagram(0), m_step(0), - m_block(0), - m_stepDelay(0) + m_block(0) { m_minMIDIPitch = 12; m_maxMIDIPitch = 96; @@ -201,12 +200,8 @@ if (stepSize != m_step) return false; if (blockSize != m_block) return false; -// m_stepDelay = (blockSize - stepSize) / 2; -// m_stepDelay = m_stepDelay / stepSize; - m_stepDelay = (blockSize - stepSize) / stepSize; //!!! why? seems about right to look at, but... - std::cerr << "ChromagramPlugin::initialise: step " << stepSize << ", block " - << blockSize << ", delay " << m_stepDelay << std::endl; + << blockSize << std::endl; m_chromagram = new Chromagram(m_config); return true; @@ -219,7 +214,6 @@ delete m_chromagram; m_chromagram = new Chromagram(m_config); } - while (!m_pending.empty()) m_pending.pop(); } size_t @@ -252,7 +246,6 @@ OutputList list; OutputDescriptor d; -// d.name = "unnormalized"; d.name = "chromagram"; d.unit = ""; d.description = "Chromagram"; @@ -323,15 +316,21 @@ return FeatureSet(); } - // convert float* to double* - double *tempBuffer = new double[m_block]; - for (size_t i = 0; i < m_block; ++i) { - tempBuffer[i] = inputBuffers[0][i]; + double *real = new double[m_block]; + double *imag = new double[m_block]; + + for (size_t i = 0; i < m_block/2; ++i) { + real[i] = inputBuffers[0][i*2]; + real[m_block - i] = real[i]; + imag[i] = inputBuffers[0][i*2+1]; + imag[m_block - i] = imag[i]; } - double *output = m_chromagram->process(tempBuffer); - delete[] tempBuffer; - + double *output = m_chromagram->process(real, imag); + + delete[] real; + delete[] imag; + Feature feature; feature.hasTimestamp = false; for (size_t i = 0; i < m_config.BPO; ++i) { @@ -340,37 +339,13 @@ feature.label = ""; FeatureSet returnFeatures; - - if (m_stepDelay == 0) { - returnFeatures[0].push_back(feature); -// returnFeatures[1].push_back(normalize(feature)); - return returnFeatures; - } - - if (m_pending.size() == m_stepDelay) { - returnFeatures[0].push_back(m_pending.front()); -// returnFeatures[1].push_back(normalize(m_pending.front())); - m_pending.pop(); - } else { - returnFeatures[0].push_back(Feature()); -// returnFeatures[1].push_back(Feature()); - } - - m_pending.push(feature); + returnFeatures[0].push_back(feature); return returnFeatures; } ChromagramPlugin::FeatureSet ChromagramPlugin::getRemainingFeatures() { - FeatureSet returnFeatures; - - while (!m_pending.empty()) { - returnFeatures[0].push_back(m_pending.front()); -// returnFeatures[1].push_back(normalize(m_pending.front())); - m_pending.pop(); - } - - return returnFeatures; + return FeatureSet(); }
--- a/plugins/ChromagramPlugin.h Mon May 15 12:07:44 2006 +0000 +++ b/plugins/ChromagramPlugin.h Mon May 15 15:08:17 2006 +0000 @@ -24,7 +24,7 @@ bool initialise(size_t channels, size_t stepSize, size_t blockSize); void reset(); - InputDomain getInputDomain() const { return TimeDomain; } + InputDomain getInputDomain() const { return FrequencyDomain; } std::string getName() const; std::string getDescription() const; @@ -58,8 +58,6 @@ Chromagram *m_chromagram; mutable size_t m_step; mutable size_t m_block; - size_t m_stepDelay; - std::queue<Feature> m_pending; Feature normalize(const Feature &); };