Mercurial > hg > svcore
changeset 132:06aba53ea0cf
* Update FeatureExtractionPluginTransform to use FFT fuzzy server. The results
seem to contain a lot of gaps -- investigate (with chromagram plugin)
author | Chris Cannam |
---|---|
date | Fri, 30 Jun 2006 11:47:52 +0000 |
parents | 69d50575c52a |
children | b18b07474e11 |
files | transform/FeatureExtractionPluginTransform.cpp |
diffstat | 1 files changed, 19 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/transform/FeatureExtractionPluginTransform.cpp Thu Jun 29 16:16:49 2006 +0000 +++ b/transform/FeatureExtractionPluginTransform.cpp Fri Jun 30 11:47:52 2006 +0000 @@ -26,8 +26,7 @@ #include "model/DenseThreeDimensionalModel.h" #include "model/DenseTimeValueModel.h" #include "model/NoteModel.h" - -#include "fileio/FFTDataServer.h" +#include "fileio/FFTFuzzyAdapter.h" #include <fftw3.h> @@ -242,40 +241,20 @@ buffers[ch] = new float[m_blockSize]; } -/*!!! - float *fftInput = 0; - fftwf_complex *fftOutput = 0; - fftwf_plan fftPlan = 0; - Window<float> windower(HanningWindow, m_blockSize); - - if (m_plugin->getInputDomain() == Vamp::Plugin::FrequencyDomain) { - - fftInput = (float *)fftwf_malloc(m_blockSize * sizeof(double)); - fftOutput = (fftwf_complex *)fftwf_malloc(m_blockSize * sizeof(fftwf_complex)); - fftPlan = fftwf_plan_dft_r2c_1d(m_blockSize, fftInput, fftOutput, - FFTW_ESTIMATE); - if (!fftPlan) { - std::cerr << "ERROR: FeatureExtractionPluginTransform::run(): fftw_plan failed! Results will be garbage" << std::endl; - } - } -*/ - bool frequencyDomain = (m_plugin->getInputDomain() == Vamp::Plugin::FrequencyDomain); - std::vector<FFTDataServer *> fftServers; - - //!!! use fuzzy fft server matching! + std::vector<FFTFuzzyAdapter *> fftAdapters; if (frequencyDomain) { for (size_t ch = 0; ch < channelCount; ++ch) { - fftServers.push_back(FFTDataServer::getInstance - (getInput(), - channelCount == 1 ? m_channel : ch, - HanningWindow, - m_blockSize, - m_stepSize, - m_blockSize, - false)); + fftAdapters.push_back(new FFTFuzzyAdapter + (getInput(), + channelCount == 1 ? m_channel : ch, + HanningWindow, + m_blockSize, + m_stepSize, + m_blockSize, + false)); } } @@ -303,14 +282,10 @@ // channelCount is either m_input->channelCount or 1 for (size_t ch = 0; ch < channelCount; ++ch) { -//!!! if (fftPlan) { -// getFrames(ch, channelCount, -// blockFrame - m_blockSize/2, m_blockSize, buffers[ch]); - if (frequencyDomain) { int column = (blockFrame - startFrame) / m_stepSize; for (size_t i = 0; i < m_blockSize/2; ++i) { - fftServers[ch]->getValuesAt + fftAdapters[ch]->getValuesAt (column, i, buffers[ch][i*2], buffers[ch][i*2+1]); } } else { @@ -318,26 +293,7 @@ blockFrame, m_blockSize, buffers[ch]); } } - /*!!! - if (fftPlan) { - for (size_t ch = 0; ch < channelCount; ++ch) { - for (size_t i = 0; i < m_blockSize; ++i) { - fftInput[i] = buffers[ch][i]; - } - windower.cut(fftInput); - for (size_t i = 0; i < m_blockSize/2; ++i) { - float temp = fftInput[i]; - fftInput[i] = fftInput[i + m_blockSize/2]; - fftInput[i + m_blockSize/2] = temp; - } - fftwf_execute(fftPlan); - for (size_t i = 0; i < m_blockSize/2; ++i) { - buffers[ch][i*2] = fftOutput[i][0]; - buffers[ch][i*2 + 1] = fftOutput[i][1]; - } - } - } - */ + Vamp::Plugin::FeatureSet features = m_plugin->process (buffers, Vamp::RealTime::frame2RealTime(blockFrame, sampleRate)); @@ -354,13 +310,7 @@ blockFrame += m_stepSize; } -/*!!! - if (fftPlan) { - fftwf_destroy_plan(fftPlan); - fftwf_free(fftInput); - fftwf_free(fftOutput); - } -*/ + Vamp::Plugin::FeatureSet features = m_plugin->getRemainingFeatures(); for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) { @@ -369,6 +319,12 @@ addFeature(blockFrame, feature); } + if (frequencyDomain) { + for (size_t ch = 0; ch < channelCount; ++ch) { + delete fftAdapters[ch]; + } + } + setCompletion(100); }