comparison transform/FeatureExtractionModelTransformer.cpp @ 687:06f13a3b9e9e debug-output

Convert many cerrs to DEBUGs
author Chris Cannam
date Mon, 16 May 2011 17:19:09 +0100
parents b4a8d8221eaf
children 1424aa29ae95
comparison
equal deleted inserted replaced
686:b4a8d8221eaf 687:06f13a3b9e9e
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 // std::cerr << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << std::endl; 46 // DEBUG << "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 std::cerr << "Initialising feature extraction plugin with channels = " 89 DEBUG << "Initialising feature extraction plugin with channels = "
90 << channelCount << ", step = " << m_transform.getStepSize() 90 << channelCount << ", step = " << m_transform.getStepSize()
91 << ", block = " << m_transform.getBlockSize() << std::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(),
95 m_transform.getBlockSize())) { 95 m_transform.getBlockSize())) {
96 96
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 // std::cerr << "comparing output " << i << " name \"" << outputs[i].identifier << "\" with expected \"" << m_transform.getOutput() << "\"" << std::endl; 155 // DEBUG << "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 // std::cerr << "FeatureExtractionModelTransformer::~FeatureExtractionModelTransformer()" << std::endl; 381 // DEBUG << "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 // std::cerr << "FeatureExtractionModelTransformer::getConformingInput: input model is " << getInputModel() << std::endl; 389 // DEBUG << "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 std::cerr << "FeatureExtractionModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << std::endl; 394 DEBUG << "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 std::cerr << "FeatureExtractionModelTransformer::run: Waiting for input model to be ready..." << std::endl; 408 DEBUG << "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 // std::cerr << "FeatureExtractionModelTransformer::run: blockFrame " 502 // DEBUG << "FeatureExtractionModelTransformer::run: blockFrame "
503 // << blockFrame << ", endFrame " << endFrame << ", blockSize " 503 // << blockFrame << ", endFrame " << endFrame << ", blockSize "
504 // << blockSize << std::endl; 504 // << blockSize << endl;
505 505
506 long completion = 506 long completion =
507 (((blockFrame - contextStart) / stepSize) * 99) / 507 (((blockFrame - contextStart) / stepSize) * 99) /
508 (contextDuration / stepSize + 1); 508 (contextDuration / stepSize + 1);
509 509
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 // std::cerr << "FeatureExtractionModelTransformer::addFeature(" 639 // DEBUG << "FeatureExtractionModelTransformer::addFeature("
640 // << blockFrame << ")" << std::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;
645 } 645 }
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 std::cerr << "FeatureExtractionModelTransformer::addFeature: Unknown output model type!" << std::endl; 780 DEBUG << "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 // std::cerr << "FeatureExtractionModelTransformer::setCompletion(" 792 // DEBUG << "FeatureExtractionModelTransformer::setCompletion("
793 // << completion << ")" << std::endl; 793 // << completion << ")" << endl;
794 794
795 if (isOutput<SparseOneDimensionalModel>()) { 795 if (isOutput<SparseOneDimensionalModel>()) {
796 796
797 SparseOneDimensionalModel *model = 797 SparseOneDimensionalModel *model =
798 getConformingOutput<SparseOneDimensionalModel>(); 798 getConformingOutput<SparseOneDimensionalModel>();