comparison transform/TransformFactory.cpp @ 1223:c2207877689d piper

Avoid instantiating all plugins (in piper client) on startup, using plugin static data instead. Problem of where to get the units field from is still pending.
author Chris Cannam
date Thu, 20 Oct 2016 14:06:58 +0100
parents 6b1af0f05f06
children ba16388b937d
comparison
equal deleted inserted replaced
1222:771a17925576 1223:c2207877689d
416 if (!factory) { 416 if (!factory) {
417 cerr << "WARNING: TransformFactory::populateTransforms: No feature extraction plugin factory for instance " << pluginId << endl; 417 cerr << "WARNING: TransformFactory::populateTransforms: No feature extraction plugin factory for instance " << pluginId << endl;
418 continue; 418 continue;
419 } 419 }
420 420
421 Vamp::Plugin *plugin = 421 piper_vamp::PluginStaticData psd = factory->getPluginStaticData(pluginId);
422 factory->instantiatePlugin(pluginId, 44100); 422
423 423 if (psd.pluginKey == "") {
424 if (!plugin) { 424 cerr << "WARNING: TransformFactory::populateTransforms: No plugin static data available for instance " << pluginId << endl;
425 cerr << "WARNING: TransformFactory::populateTransforms: Failed to instantiate plugin " << pluginId << endl; 425 continue;
426 continue; 426 }
427 } 427
428 428 QString pluginName = QString::fromStdString(psd.basic.name);
429 QString pluginName = plugin->getName().c_str();
430 QString category = factory->getPluginCategory(pluginId); 429 QString category = factory->getPluginCategory(pluginId);
431 430
432 Vamp::Plugin::OutputList outputs = 431 const auto &basicOutputs = psd.basicOutputInfo;
433 plugin->getOutputDescriptors(); 432
434 433 for (const auto &o: basicOutputs) {
435 for (int j = 0; j < (int)outputs.size(); ++j) { 434
435 QString outputName = QString::fromStdString(o.name);
436 436
437 QString transformId = QString("%1:%2") 437 QString transformId = QString("%1:%2")
438 .arg(pluginId).arg(outputs[j].identifier.c_str()); 438 .arg(pluginId).arg(QString::fromStdString(o.identifier));
439 439
440 QString userName; 440 QString userName;
441 QString friendlyName; 441 QString friendlyName;
442 QString units = outputs[j].unit.c_str(); 442 //!!! return to this QString units = outputs[j].unit.c_str();
443 QString description = plugin->getDescription().c_str(); 443 QString description = QString::fromStdString(psd.basic.description);
444 QString maker = plugin->getMaker().c_str(); 444 QString maker = QString::fromStdString(psd.maker);
445 if (maker == "") maker = tr("<unknown maker>"); 445 if (maker == "") maker = tr("<unknown maker>");
446 446
447 QString longDescription = description; 447 QString longDescription = description;
448 448
449 if (longDescription == "") { 449 if (longDescription == "") {
450 if (outputs.size() == 1) { 450 if (basicOutputs.size() == 1) {
451 longDescription = tr("Extract features using \"%1\" plugin (from %2)") 451 longDescription = tr("Extract features using \"%1\" plugin (from %2)")
452 .arg(pluginName).arg(maker); 452 .arg(pluginName).arg(maker);
453 } else { 453 } else {
454 longDescription = tr("Extract features using \"%1\" output of \"%2\" plugin (from %3)") 454 longDescription = tr("Extract features using \"%1\" output of \"%2\" plugin (from %3)")
455 .arg(outputs[j].name.c_str()).arg(pluginName).arg(maker); 455 .arg(outputName).arg(pluginName).arg(maker);
456 } 456 }
457 } else { 457 } else {
458 if (outputs.size() == 1) { 458 if (basicOutputs.size() == 1) {
459 longDescription = tr("%1 using \"%2\" plugin (from %3)") 459 longDescription = tr("%1 using \"%2\" plugin (from %3)")
460 .arg(longDescription).arg(pluginName).arg(maker); 460 .arg(longDescription).arg(pluginName).arg(maker);
461 } else { 461 } else {
462 longDescription = tr("%1 using \"%2\" output of \"%3\" plugin (from %4)") 462 longDescription = tr("%1 using \"%2\" output of \"%3\" plugin (from %4)")
463 .arg(longDescription).arg(outputs[j].name.c_str()).arg(pluginName).arg(maker); 463 .arg(longDescription).arg(outputName).arg(pluginName).arg(maker);
464 } 464 }
465 } 465 }
466 466
467 if (outputs.size() == 1) { 467 if (basicOutputs.size() == 1) {
468 userName = pluginName; 468 userName = pluginName;
469 friendlyName = pluginName; 469 friendlyName = pluginName;
470 } else { 470 } else {
471 userName = QString("%1: %2") 471 userName = QString("%1: %2").arg(pluginName).arg(outputName);
472 .arg(pluginName) 472 friendlyName = outputName;
473 .arg(outputs[j].name.c_str());
474 friendlyName = outputs[j].name.c_str();
475 } 473 }
476 474
477 bool configurable = (!plugin->getPrograms().empty() || 475 bool configurable = (!psd.programs.empty() ||
478 !plugin->getParameterDescriptors().empty()); 476 !psd.parameters.empty());
479 477
480 #ifdef DEBUG_TRANSFORM_FACTORY 478 #ifdef DEBUG_TRANSFORM_FACTORY
481 cerr << "Feature extraction plugin transform: " << transformId << " friendly name: " << friendlyName << endl; 479 cerr << "Feature extraction plugin transform: " << transformId << " friendly name: " << friendlyName << endl;
482 #endif 480 #endif
483 481
488 userName, 486 userName,
489 friendlyName, 487 friendlyName,
490 description, 488 description,
491 longDescription, 489 longDescription,
492 maker, 490 maker,
493 units, 491 //!!! units,
492 "",
494 configurable); 493 configurable);
495 } 494 }
496
497 delete plugin;
498 } 495 }
499 } 496 }
500 497
501 void 498 void
502 TransformFactory::populateRealTimePlugins(TransformDescriptionMap &transforms) 499 TransformFactory::populateRealTimePlugins(TransformDescriptionMap &transforms)