Mercurial > hg > sonic-visualiser
comparison transform/FeatureExtractionPluginTransform.cpp @ 61:963e3187d920
* Fix slowness in serving FFT values to feature extraction plugin transform
(failure to call resume() on FFT model)
* Fix failure to update completion from time/value model
author | Chris Cannam |
---|---|
date | Tue, 17 Oct 2006 13:49:31 +0000 |
parents | ca1e3f5657d5 |
children | 51f34d378a3a |
comparison
equal
deleted
inserted
replaced
60:06b3c3f437e6 | 61:963e3187d920 |
---|---|
249 Vamp::Plugin::FrequencyDomain); | 249 Vamp::Plugin::FrequencyDomain); |
250 std::vector<FFTModel *> fftModels; | 250 std::vector<FFTModel *> fftModels; |
251 | 251 |
252 if (frequencyDomain) { | 252 if (frequencyDomain) { |
253 for (size_t ch = 0; ch < channelCount; ++ch) { | 253 for (size_t ch = 0; ch < channelCount; ++ch) { |
254 fftModels.push_back(new FFTModel | 254 FFTModel *model = new FFTModel |
255 (getInput(), | 255 (getInput(), |
256 channelCount == 1 ? m_context.channel : ch, | 256 channelCount == 1 ? m_context.channel : ch, |
257 m_context.windowType, | 257 m_context.windowType, |
258 m_context.blockSize, | 258 m_context.blockSize, |
259 m_context.stepSize, | 259 m_context.stepSize, |
260 m_context.blockSize, | 260 m_context.blockSize, |
261 false)); | 261 false); |
262 model->resume(); | |
263 fftModels.push_back(model); | |
262 } | 264 } |
263 } | 265 } |
264 | 266 |
265 long startFrame = m_input->getStartFrame(); | 267 long startFrame = m_input->getStartFrame(); |
266 long endFrame = m_input->getEndFrame(); | 268 long endFrame = m_input->getEndFrame(); |
290 int column = (blockFrame - startFrame) / m_context.stepSize; | 292 int column = (blockFrame - startFrame) / m_context.stepSize; |
291 for (size_t i = 0; i < m_context.blockSize/2; ++i) { | 293 for (size_t i = 0; i < m_context.blockSize/2; ++i) { |
292 fftModels[ch]->getValuesAt | 294 fftModels[ch]->getValuesAt |
293 (column, i, buffers[ch][i*2], buffers[ch][i*2+1]); | 295 (column, i, buffers[ch][i*2], buffers[ch][i*2+1]); |
294 } | 296 } |
295 /*!!! | |
296 float sum = 0.0; | |
297 for (size_t i = 0; i < m_context.blockSize/2; ++i) { | |
298 sum += buffers[ch][i*2]; | |
299 } | |
300 if (fabs(sum) < 0.0001) { | |
301 std::cerr << "WARNING: small sum for column " << column << " (sum is " << sum << ")" << std::endl; | |
302 } | |
303 */ | |
304 } else { | 297 } else { |
305 getFrames(ch, channelCount, | 298 getFrames(ch, channelCount, |
306 blockFrame, m_context.blockSize, buffers[ch]); | 299 blockFrame, m_context.blockSize, buffers[ch]); |
307 } | 300 } |
308 } | 301 } |
475 | 468 |
476 if (binCount == 0) { | 469 if (binCount == 0) { |
477 | 470 |
478 SparseOneDimensionalModel *model = getOutput<SparseOneDimensionalModel>(); | 471 SparseOneDimensionalModel *model = getOutput<SparseOneDimensionalModel>(); |
479 if (!model) return; | 472 if (!model) return; |
480 std::cerr << "setting on SparseOneDimensionalModel" << std::endl; | |
481 model->setCompletion(completion); | 473 model->setCompletion(completion); |
482 | 474 |
483 } else if (binCount == 1) { | 475 } else if (binCount == 1) { |
484 | 476 |
485 SparseTimeValueModel *model = getOutput<SparseTimeValueModel>(); | 477 SparseTimeValueModel *model = getOutput<SparseTimeValueModel>(); |
486 if (!model) return; | 478 if (!model) return; |
487 std::cerr << "setting on SparseTimeValueModel" << std::endl; | |
488 model->setCompletion(completion); | 479 model->setCompletion(completion); |
489 | 480 |
490 } else if (m_descriptor->sampleType == | 481 } else if (m_descriptor->sampleType == |
491 Vamp::Plugin::OutputDescriptor::VariableSampleRate) { | 482 Vamp::Plugin::OutputDescriptor::VariableSampleRate) { |
492 | 483 |
493 NoteModel *model = getOutput<NoteModel>(); | 484 NoteModel *model = getOutput<NoteModel>(); |
494 if (!model) return; | 485 if (!model) return; |
495 std::cerr << "setting on NoteModel" << std::endl; | |
496 model->setCompletion(completion); | 486 model->setCompletion(completion); |
497 | 487 |
498 } else { | 488 } else { |
499 | 489 |
500 EditableDenseThreeDimensionalModel *model = | 490 EditableDenseThreeDimensionalModel *model = |
501 getOutput<EditableDenseThreeDimensionalModel>(); | 491 getOutput<EditableDenseThreeDimensionalModel>(); |
502 if (!model) return; | 492 if (!model) return; |
503 std::cerr << "setting on EditableDenseThreeDimensionalModel" << std::endl; | |
504 model->setCompletion(completion); | 493 model->setCompletion(completion); |
505 } | 494 } |
506 } | 495 } |
507 | 496 |