comparison transform/FeatureExtractionPluginTransform.cpp @ 79:c1318aac18d2

* Fix apparent (but not actual) failure to save session file * Fix doofusness in FFT model (N/2 vs N/2+1) -- need to review use of this model in spectrogram
author Chris Cannam
date Fri, 08 Dec 2006 18:17:29 +0000
parents bedc7517b6e8
children dd11619b73ba
comparison
equal deleted inserted replaced
78:9918c8a3f904 79:c1318aac18d2
29 #include "data/model/FFTModel.h" 29 #include "data/model/FFTModel.h"
30 #include "data/model/WaveFileModel.h" 30 #include "data/model/WaveFileModel.h"
31 31
32 #include <QMessageBox> 32 #include <QMessageBox>
33 33
34 #include <fftw3.h>
35
36 #include <iostream> 34 #include <iostream>
37 35
38 FeatureExtractionPluginTransform::FeatureExtractionPluginTransform(Model *inputModel, 36 FeatureExtractionPluginTransform::FeatureExtractionPluginTransform(Model *inputModel,
39 QString pluginId, 37 QString pluginId,
40 const ExecutionContext &context, 38 const ExecutionContext &context,
242 channelCount = 1; 240 channelCount = 1;
243 } 241 }
244 242
245 float **buffers = new float*[channelCount]; 243 float **buffers = new float*[channelCount];
246 for (size_t ch = 0; ch < channelCount; ++ch) { 244 for (size_t ch = 0; ch < channelCount; ++ch) {
247 buffers[ch] = new float[m_context.blockSize]; 245 buffers[ch] = new float[m_context.blockSize + 2];
248 } 246 }
249 247
250 bool frequencyDomain = (m_plugin->getInputDomain() == 248 bool frequencyDomain = (m_plugin->getInputDomain() ==
251 Vamp::Plugin::FrequencyDomain); 249 Vamp::Plugin::FrequencyDomain);
252 std::vector<FFTModel *> fftModels; 250 std::vector<FFTModel *> fftModels;
299 // channelCount is either m_input->channelCount or 1 297 // channelCount is either m_input->channelCount or 1
300 298
301 for (size_t ch = 0; ch < channelCount; ++ch) { 299 for (size_t ch = 0; ch < channelCount; ++ch) {
302 if (frequencyDomain) { 300 if (frequencyDomain) {
303 int column = (blockFrame - startFrame) / m_context.stepSize; 301 int column = (blockFrame - startFrame) / m_context.stepSize;
304 for (size_t i = 0; i < m_context.blockSize/2; ++i) { 302 for (size_t i = 0; i <= m_context.blockSize/2; ++i) {
305 fftModels[ch]->getValuesAt 303 fftModels[ch]->getValuesAt
306 (column, i, buffers[ch][i*2], buffers[ch][i*2+1]); 304 (column, i, buffers[ch][i*2], buffers[ch][i*2+1]);
307 } 305 }
308 } else { 306 } else {
309 getFrames(ch, channelCount, 307 getFrames(ch, channelCount,