Mercurial > hg > svcore
comparison transform/FeatureExtractionModelTransformer.cpp @ 690:1424aa29ae95
Seems to be a bad idea to use plain DEBUG symbol on OS/X (system wants it)
author | Chris Cannam |
---|---|
date | Tue, 14 Jun 2011 15:26:52 +0100 |
parents | 06f13a3b9e9e |
children | 7f76499ef4f2 |
comparison
equal
deleted
inserted
replaced
689:573d45e9487b | 690:1424aa29ae95 |
---|---|
41 ModelTransformer(in, transform), | 41 ModelTransformer(in, transform), |
42 m_plugin(0), | 42 m_plugin(0), |
43 m_descriptor(0), | 43 m_descriptor(0), |
44 m_outputFeatureNo(0) | 44 m_outputFeatureNo(0) |
45 { | 45 { |
46 // DEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << endl; | 46 // SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << endl; |
47 | 47 |
48 QString pluginId = transform.getPluginIdentifier(); | 48 QString pluginId = transform.getPluginIdentifier(); |
49 | 49 |
50 FeatureExtractionPluginFactory *factory = | 50 FeatureExtractionPluginFactory *factory = |
51 FeatureExtractionPluginFactory::instanceFor(pluginId); | 51 FeatureExtractionPluginFactory::instanceFor(pluginId); |
84 .arg(m_plugin->getMaxChannelCount()) | 84 .arg(m_plugin->getMaxChannelCount()) |
85 .arg(input->getChannelCount()); | 85 .arg(input->getChannelCount()); |
86 return; | 86 return; |
87 } | 87 } |
88 | 88 |
89 DEBUG << "Initialising feature extraction plugin with channels = " | 89 SVDEBUG << "Initialising feature extraction plugin with channels = " |
90 << channelCount << ", step = " << m_transform.getStepSize() | 90 << channelCount << ", step = " << m_transform.getStepSize() |
91 << ", block = " << m_transform.getBlockSize() << endl; | 91 << ", block = " << m_transform.getBlockSize() << endl; |
92 | 92 |
93 if (!m_plugin->initialise(channelCount, | 93 if (!m_plugin->initialise(channelCount, |
94 m_transform.getStepSize(), | 94 m_transform.getStepSize(), |
150 m_message = tr("Plugin \"%1\" has no outputs").arg(pluginId); | 150 m_message = tr("Plugin \"%1\" has no outputs").arg(pluginId); |
151 return; | 151 return; |
152 } | 152 } |
153 | 153 |
154 for (size_t i = 0; i < outputs.size(); ++i) { | 154 for (size_t i = 0; i < outputs.size(); ++i) { |
155 // DEBUG << "comparing output " << i << " name \"" << outputs[i].identifier << "\" with expected \"" << m_transform.getOutput() << "\"" << endl; | 155 // SVDEBUG << "comparing output " << i << " name \"" << outputs[i].identifier << "\" with expected \"" << m_transform.getOutput() << "\"" << endl; |
156 if (m_transform.getOutput() == "" || | 156 if (m_transform.getOutput() == "" || |
157 outputs[i].identifier == m_transform.getOutput().toStdString()) { | 157 outputs[i].identifier == m_transform.getOutput().toStdString()) { |
158 m_outputFeatureNo = i; | 158 m_outputFeatureNo = i; |
159 m_descriptor = new Vamp::Plugin::OutputDescriptor(outputs[i]); | 159 m_descriptor = new Vamp::Plugin::OutputDescriptor(outputs[i]); |
160 break; | 160 break; |
376 if (m_output) m_output->setSourceModel(input); | 376 if (m_output) m_output->setSourceModel(input); |
377 } | 377 } |
378 | 378 |
379 FeatureExtractionModelTransformer::~FeatureExtractionModelTransformer() | 379 FeatureExtractionModelTransformer::~FeatureExtractionModelTransformer() |
380 { | 380 { |
381 // DEBUG << "FeatureExtractionModelTransformer::~FeatureExtractionModelTransformer()" << endl; | 381 // SVDEBUG << "FeatureExtractionModelTransformer::~FeatureExtractionModelTransformer()" << endl; |
382 delete m_plugin; | 382 delete m_plugin; |
383 delete m_descriptor; | 383 delete m_descriptor; |
384 } | 384 } |
385 | 385 |
386 DenseTimeValueModel * | 386 DenseTimeValueModel * |
387 FeatureExtractionModelTransformer::getConformingInput() | 387 FeatureExtractionModelTransformer::getConformingInput() |
388 { | 388 { |
389 // DEBUG << "FeatureExtractionModelTransformer::getConformingInput: input model is " << getInputModel() << endl; | 389 // SVDEBUG << "FeatureExtractionModelTransformer::getConformingInput: input model is " << getInputModel() << endl; |
390 | 390 |
391 DenseTimeValueModel *dtvm = | 391 DenseTimeValueModel *dtvm = |
392 dynamic_cast<DenseTimeValueModel *>(getInputModel()); | 392 dynamic_cast<DenseTimeValueModel *>(getInputModel()); |
393 if (!dtvm) { | 393 if (!dtvm) { |
394 DEBUG << "FeatureExtractionModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << endl; | 394 SVDEBUG << "FeatureExtractionModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << endl; |
395 } | 395 } |
396 return dtvm; | 396 return dtvm; |
397 } | 397 } |
398 | 398 |
399 void | 399 void |
403 if (!input) return; | 403 if (!input) return; |
404 | 404 |
405 if (!m_output) return; | 405 if (!m_output) return; |
406 | 406 |
407 while (!input->isReady() && !m_abandoned) { | 407 while (!input->isReady() && !m_abandoned) { |
408 DEBUG << "FeatureExtractionModelTransformer::run: Waiting for input model to be ready..." << endl; | 408 SVDEBUG << "FeatureExtractionModelTransformer::run: Waiting for input model to be ready..." << endl; |
409 usleep(500000); | 409 usleep(500000); |
410 } | 410 } |
411 if (m_abandoned) return; | 411 if (m_abandoned) return; |
412 | 412 |
413 size_t sampleRate = input->getSampleRate(); | 413 size_t sampleRate = input->getSampleRate(); |
497 } else { | 497 } else { |
498 if (blockFrame >= | 498 if (blockFrame >= |
499 contextStart + contextDuration) break; | 499 contextStart + contextDuration) break; |
500 } | 500 } |
501 | 501 |
502 // DEBUG << "FeatureExtractionModelTransformer::run: blockFrame " | 502 // SVDEBUG << "FeatureExtractionModelTransformer::run: blockFrame " |
503 // << blockFrame << ", endFrame " << endFrame << ", blockSize " | 503 // << blockFrame << ", endFrame " << endFrame << ", blockSize " |
504 // << blockSize << endl; | 504 // << blockSize << endl; |
505 | 505 |
506 long completion = | 506 long completion = |
507 (((blockFrame - contextStart) / stepSize) * 99) / | 507 (((blockFrame - contextStart) / stepSize) * 99) / |
634 FeatureExtractionModelTransformer::addFeature(size_t blockFrame, | 634 FeatureExtractionModelTransformer::addFeature(size_t blockFrame, |
635 const Vamp::Plugin::Feature &feature) | 635 const Vamp::Plugin::Feature &feature) |
636 { | 636 { |
637 size_t inputRate = m_input.getModel()->getSampleRate(); | 637 size_t inputRate = m_input.getModel()->getSampleRate(); |
638 | 638 |
639 // DEBUG << "FeatureExtractionModelTransformer::addFeature(" | 639 // SVDEBUG << "FeatureExtractionModelTransformer::addFeature(" |
640 // << blockFrame << ")" << endl; | 640 // << blockFrame << ")" << endl; |
641 | 641 |
642 int binCount = 1; | 642 int binCount = 1; |
643 if (m_descriptor->hasFixedBinCount) { | 643 if (m_descriptor->hasFixedBinCount) { |
644 binCount = m_descriptor->binCount; | 644 binCount = m_descriptor->binCount; |
775 if (!model) return; | 775 if (!model) return; |
776 | 776 |
777 model->setColumn(frame / model->getResolution(), values); | 777 model->setColumn(frame / model->getResolution(), values); |
778 | 778 |
779 } else { | 779 } else { |
780 DEBUG << "FeatureExtractionModelTransformer::addFeature: Unknown output model type!" << endl; | 780 SVDEBUG << "FeatureExtractionModelTransformer::addFeature: Unknown output model type!" << endl; |
781 } | 781 } |
782 } | 782 } |
783 | 783 |
784 void | 784 void |
785 FeatureExtractionModelTransformer::setCompletion(int completion) | 785 FeatureExtractionModelTransformer::setCompletion(int completion) |
787 int binCount = 1; | 787 int binCount = 1; |
788 if (m_descriptor->hasFixedBinCount) { | 788 if (m_descriptor->hasFixedBinCount) { |
789 binCount = m_descriptor->binCount; | 789 binCount = m_descriptor->binCount; |
790 } | 790 } |
791 | 791 |
792 // DEBUG << "FeatureExtractionModelTransformer::setCompletion(" | 792 // SVDEBUG << "FeatureExtractionModelTransformer::setCompletion(" |
793 // << completion << ")" << endl; | 793 // << completion << ")" << endl; |
794 | 794 |
795 if (isOutput<SparseOneDimensionalModel>()) { | 795 if (isOutput<SparseOneDimensionalModel>()) { |
796 | 796 |
797 SparseOneDimensionalModel *model = | 797 SparseOneDimensionalModel *model = |