annotate transform/TransformFactory.cpp @ 479:f933062a7f80

* Make scale bar more accurate (if no more helpful) in log scaled colour 3d plot
author Chris Cannam
date Wed, 12 Nov 2008 16:39:29 +0000
parents e0784311a103
children a82645e788fc
rev   line source
Chris@330 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@330 2
Chris@330 3 /*
Chris@330 4 Sonic Visualiser
Chris@330 5 An audio file viewer and annotation editor.
Chris@330 6 Centre for Digital Music, Queen Mary, University of London.
Chris@330 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@330 8
Chris@330 9 This program is free software; you can redistribute it and/or
Chris@330 10 modify it under the terms of the GNU General Public License as
Chris@330 11 published by the Free Software Foundation; either version 2 of the
Chris@330 12 License, or (at your option) any later version. See the file
Chris@330 13 COPYING included with this distribution for more information.
Chris@330 14 */
Chris@330 15
Chris@330 16 #include "TransformFactory.h"
Chris@330 17
Chris@330 18 #include "plugin/FeatureExtractionPluginFactory.h"
Chris@330 19 #include "plugin/RealTimePluginFactory.h"
Chris@332 20 #include "plugin/RealTimePluginInstance.h"
Chris@330 21 #include "plugin/PluginXml.h"
Chris@330 22
Chris@475 23 #include <vamp-hostsdk/Plugin.h>
Chris@475 24 #include <vamp-hostsdk/PluginHostAdapter.h>
Chris@475 25 #include <vamp-hostsdk/PluginWrapper.h>
Chris@330 26
Chris@457 27 #include "rdf/PluginRDFIndexer.h"
Chris@457 28 #include "rdf/PluginRDFDescription.h"
Chris@457 29
Chris@446 30 #include "base/XmlExportable.h"
Chris@446 31
Chris@330 32 #include <iostream>
Chris@330 33 #include <set>
Chris@330 34
Chris@330 35 #include <QRegExp>
Chris@350 36 #include <QTextStream>
Chris@330 37
Chris@460 38 #include "base/Thread.h"
Chris@460 39
Chris@443 40 using std::cerr;
Chris@443 41 using std::endl;
Chris@443 42
Chris@330 43 TransformFactory *
Chris@330 44 TransformFactory::m_instance = new TransformFactory;
Chris@330 45
Chris@330 46 TransformFactory *
Chris@330 47 TransformFactory::getInstance()
Chris@330 48 {
Chris@330 49 return m_instance;
Chris@330 50 }
Chris@330 51
Chris@457 52 TransformFactory::TransformFactory() :
Chris@457 53 m_transformsPopulated(false),
Chris@477 54 m_uninstalledTransformsPopulated(false),
Chris@477 55 m_thread(0)
Chris@457 56 {
Chris@457 57 }
Chris@457 58
Chris@330 59 TransformFactory::~TransformFactory()
Chris@330 60 {
Chris@330 61 }
Chris@330 62
Chris@477 63 void
Chris@477 64 TransformFactory::startPopulationThread()
Chris@477 65 {
Chris@477 66 MutexLocker locker(&m_uninstalledTransformsMutex,
Chris@477 67 "TransformFactory::startPopulationThread");
Chris@477 68
Chris@477 69 if (m_thread) return;
Chris@477 70
Chris@477 71 m_thread = new UninstalledTransformsPopulateThread(this);
Chris@477 72 m_thread->start();
Chris@477 73 }
Chris@477 74
Chris@330 75 TransformList
Chris@350 76 TransformFactory::getAllTransformDescriptions()
Chris@330 77 {
Chris@460 78 populateTransforms();
Chris@330 79
Chris@330 80 std::set<TransformDescription> dset;
Chris@330 81 for (TransformDescriptionMap::const_iterator i = m_transforms.begin();
Chris@330 82 i != m_transforms.end(); ++i) {
Chris@443 83 // cerr << "inserting transform into set: id = " << i->second.identifier.toStdString() << endl;
Chris@330 84 dset.insert(i->second);
Chris@330 85 }
Chris@330 86
Chris@330 87 TransformList list;
Chris@330 88 for (std::set<TransformDescription>::const_iterator i = dset.begin();
Chris@330 89 i != dset.end(); ++i) {
Chris@443 90 // cerr << "inserting transform into list: id = " << i->identifier.toStdString() << endl;
Chris@330 91 list.push_back(*i);
Chris@330 92 }
Chris@330 93
Chris@330 94 return list;
Chris@330 95 }
Chris@330 96
Chris@350 97 TransformDescription
Chris@350 98 TransformFactory::getTransformDescription(TransformId id)
Chris@350 99 {
Chris@460 100 populateTransforms();
Chris@350 101
Chris@350 102 if (m_transforms.find(id) == m_transforms.end()) {
Chris@350 103 return TransformDescription();
Chris@350 104 }
Chris@350 105
Chris@350 106 return m_transforms[id];
Chris@350 107 }
Chris@350 108
Chris@457 109 TransformList
Chris@457 110 TransformFactory::getUninstalledTransformDescriptions()
Chris@457 111 {
Chris@479 112 m_populatingSlowly = false;
Chris@460 113 populateUninstalledTransforms();
Chris@457 114
Chris@457 115 std::set<TransformDescription> dset;
Chris@457 116 for (TransformDescriptionMap::const_iterator i = m_uninstalledTransforms.begin();
Chris@457 117 i != m_uninstalledTransforms.end(); ++i) {
Chris@457 118 // cerr << "inserting transform into set: id = " << i->second.identifier.toStdString() << endl;
Chris@457 119 dset.insert(i->second);
Chris@457 120 }
Chris@457 121
Chris@457 122 TransformList list;
Chris@457 123 for (std::set<TransformDescription>::const_iterator i = dset.begin();
Chris@457 124 i != dset.end(); ++i) {
Chris@460 125 // cerr << "inserting transform into uninstalled list: id = " << i->identifier.toStdString() << endl;
Chris@457 126 list.push_back(*i);
Chris@457 127 }
Chris@457 128
Chris@457 129 return list;
Chris@457 130 }
Chris@457 131
Chris@457 132 TransformDescription
Chris@457 133 TransformFactory::getUninstalledTransformDescription(TransformId id)
Chris@457 134 {
Chris@479 135 m_populatingSlowly = false;
Chris@460 136 populateUninstalledTransforms();
Chris@457 137
Chris@457 138 if (m_uninstalledTransforms.find(id) == m_uninstalledTransforms.end()) {
Chris@457 139 return TransformDescription();
Chris@457 140 }
Chris@457 141
Chris@457 142 return m_uninstalledTransforms[id];
Chris@457 143 }
Chris@457 144
Chris@457 145 TransformFactory::TransformInstallStatus
Chris@457 146 TransformFactory::getTransformInstallStatus(TransformId id)
Chris@457 147 {
Chris@460 148 populateTransforms();
Chris@457 149
Chris@457 150 if (m_transforms.find(id) != m_transforms.end()) {
Chris@457 151 return TransformInstalled;
Chris@457 152 }
Chris@473 153
Chris@473 154 if (!m_uninstalledTransformsMutex.tryLock()) {
Chris@473 155 // uninstalled transforms are being populated; this may take some time,
Chris@473 156 // and they aren't critical
Chris@473 157 return TransformUnknown;
Chris@473 158 }
Chris@473 159
Chris@473 160 if (!m_uninstalledTransformsPopulated) {
Chris@473 161 m_uninstalledTransformsMutex.unlock();
Chris@479 162 m_populatingSlowly = false;
Chris@473 163 populateUninstalledTransforms();
Chris@473 164 m_uninstalledTransformsMutex.lock();
Chris@473 165 }
Chris@473 166
Chris@457 167 if (m_uninstalledTransforms.find(id) != m_uninstalledTransforms.end()) {
Chris@457 168 return TransformNotInstalled;
Chris@457 169 }
Chris@473 170
Chris@473 171 m_uninstalledTransformsMutex.unlock();
Chris@473 172
Chris@457 173 return TransformUnknown;
Chris@457 174 }
Chris@457 175
Chris@457 176
Chris@330 177 std::vector<QString>
Chris@330 178 TransformFactory::getAllTransformTypes()
Chris@330 179 {
Chris@460 180 populateTransforms();
Chris@330 181
Chris@330 182 std::set<QString> types;
Chris@330 183 for (TransformDescriptionMap::const_iterator i = m_transforms.begin();
Chris@330 184 i != m_transforms.end(); ++i) {
Chris@330 185 types.insert(i->second.type);
Chris@330 186 }
Chris@330 187
Chris@330 188 std::vector<QString> rv;
Chris@330 189 for (std::set<QString>::iterator i = types.begin(); i != types.end(); ++i) {
Chris@330 190 rv.push_back(*i);
Chris@330 191 }
Chris@330 192
Chris@330 193 return rv;
Chris@330 194 }
Chris@330 195
Chris@330 196 std::vector<QString>
Chris@330 197 TransformFactory::getTransformCategories(QString transformType)
Chris@330 198 {
Chris@460 199 populateTransforms();
Chris@330 200
Chris@330 201 std::set<QString> categories;
Chris@330 202 for (TransformDescriptionMap::const_iterator i = m_transforms.begin();
Chris@330 203 i != m_transforms.end(); ++i) {
Chris@330 204 if (i->second.type == transformType) {
Chris@330 205 categories.insert(i->second.category);
Chris@330 206 }
Chris@330 207 }
Chris@330 208
Chris@330 209 bool haveEmpty = false;
Chris@330 210
Chris@330 211 std::vector<QString> rv;
Chris@330 212 for (std::set<QString>::iterator i = categories.begin();
Chris@330 213 i != categories.end(); ++i) {
Chris@330 214 if (*i != "") rv.push_back(*i);
Chris@330 215 else haveEmpty = true;
Chris@330 216 }
Chris@330 217
Chris@330 218 if (haveEmpty) rv.push_back(""); // make sure empty category sorts last
Chris@330 219
Chris@330 220 return rv;
Chris@330 221 }
Chris@330 222
Chris@330 223 std::vector<QString>
Chris@330 224 TransformFactory::getTransformMakers(QString transformType)
Chris@330 225 {
Chris@460 226 populateTransforms();
Chris@330 227
Chris@330 228 std::set<QString> makers;
Chris@330 229 for (TransformDescriptionMap::const_iterator i = m_transforms.begin();
Chris@330 230 i != m_transforms.end(); ++i) {
Chris@330 231 if (i->second.type == transformType) {
Chris@330 232 makers.insert(i->second.maker);
Chris@330 233 }
Chris@330 234 }
Chris@330 235
Chris@330 236 bool haveEmpty = false;
Chris@330 237
Chris@330 238 std::vector<QString> rv;
Chris@330 239 for (std::set<QString>::iterator i = makers.begin();
Chris@330 240 i != makers.end(); ++i) {
Chris@330 241 if (*i != "") rv.push_back(*i);
Chris@330 242 else haveEmpty = true;
Chris@330 243 }
Chris@330 244
Chris@330 245 if (haveEmpty) rv.push_back(""); // make sure empty category sorts last
Chris@330 246
Chris@330 247 return rv;
Chris@330 248 }
Chris@330 249
Chris@330 250 void
Chris@330 251 TransformFactory::populateTransforms()
Chris@330 252 {
Chris@460 253 MutexLocker locker(&m_transformsMutex,
Chris@460 254 "TransformFactory::populateTransforms");
Chris@460 255 if (m_transformsPopulated) {
Chris@460 256 return;
Chris@460 257 }
Chris@460 258
Chris@330 259 TransformDescriptionMap transforms;
Chris@330 260
Chris@330 261 populateFeatureExtractionPlugins(transforms);
Chris@330 262 populateRealTimePlugins(transforms);
Chris@330 263
Chris@330 264 // disambiguate plugins with similar names
Chris@330 265
Chris@330 266 std::map<QString, int> names;
Chris@330 267 std::map<QString, QString> pluginSources;
Chris@330 268 std::map<QString, QString> pluginMakers;
Chris@330 269
Chris@330 270 for (TransformDescriptionMap::iterator i = transforms.begin();
Chris@330 271 i != transforms.end(); ++i) {
Chris@330 272
Chris@330 273 TransformDescription desc = i->second;
Chris@330 274
Chris@330 275 QString td = desc.name;
Chris@330 276 QString tn = td.section(": ", 0, 0);
Chris@330 277 QString pn = desc.identifier.section(":", 1, 1);
Chris@330 278
Chris@330 279 if (pluginSources.find(tn) != pluginSources.end()) {
Chris@330 280 if (pluginSources[tn] != pn && pluginMakers[tn] != desc.maker) {
Chris@330 281 ++names[tn];
Chris@330 282 }
Chris@330 283 } else {
Chris@330 284 ++names[tn];
Chris@330 285 pluginSources[tn] = pn;
Chris@330 286 pluginMakers[tn] = desc.maker;
Chris@330 287 }
Chris@330 288 }
Chris@330 289
Chris@330 290 std::map<QString, int> counts;
Chris@330 291 m_transforms.clear();
Chris@330 292
Chris@330 293 for (TransformDescriptionMap::iterator i = transforms.begin();
Chris@330 294 i != transforms.end(); ++i) {
Chris@330 295
Chris@330 296 TransformDescription desc = i->second;
Chris@330 297 QString identifier = desc.identifier;
Chris@330 298 QString maker = desc.maker;
Chris@330 299
Chris@330 300 QString td = desc.name;
Chris@330 301 QString tn = td.section(": ", 0, 0);
Chris@330 302 QString to = td.section(": ", 1);
Chris@330 303
Chris@330 304 if (names[tn] > 1) {
Chris@330 305 maker.replace(QRegExp(tr(" [\\(<].*$")), "");
Chris@330 306 tn = QString("%1 [%2]").arg(tn).arg(maker);
Chris@330 307 }
Chris@330 308
Chris@330 309 if (to != "") {
Chris@330 310 desc.name = QString("%1: %2").arg(tn).arg(to);
Chris@330 311 } else {
Chris@330 312 desc.name = tn;
Chris@330 313 }
Chris@330 314
Chris@330 315 m_transforms[identifier] = desc;
Chris@330 316 }
Chris@457 317
Chris@457 318 m_transformsPopulated = true;
Chris@330 319 }
Chris@330 320
Chris@330 321 void
Chris@330 322 TransformFactory::populateFeatureExtractionPlugins(TransformDescriptionMap &transforms)
Chris@330 323 {
Chris@330 324 std::vector<QString> plugs =
Chris@330 325 FeatureExtractionPluginFactory::getAllPluginIdentifiers();
Chris@330 326
Chris@330 327 for (size_t i = 0; i < plugs.size(); ++i) {
Chris@330 328
Chris@330 329 QString pluginId = plugs[i];
Chris@330 330
Chris@330 331 FeatureExtractionPluginFactory *factory =
Chris@330 332 FeatureExtractionPluginFactory::instanceFor(pluginId);
Chris@330 333
Chris@330 334 if (!factory) {
Chris@443 335 cerr << "WARNING: TransformFactory::populateTransforms: No feature extraction plugin factory for instance " << pluginId.toLocal8Bit().data() << endl;
Chris@330 336 continue;
Chris@330 337 }
Chris@330 338
Chris@330 339 Vamp::Plugin *plugin =
Chris@350 340 factory->instantiatePlugin(pluginId, 44100);
Chris@330 341
Chris@330 342 if (!plugin) {
Chris@443 343 cerr << "WARNING: TransformFactory::populateTransforms: Failed to instantiate plugin " << pluginId.toLocal8Bit().data() << endl;
Chris@330 344 continue;
Chris@330 345 }
Chris@330 346
Chris@330 347 QString pluginName = plugin->getName().c_str();
Chris@330 348 QString category = factory->getPluginCategory(pluginId);
Chris@330 349
Chris@330 350 Vamp::Plugin::OutputList outputs =
Chris@330 351 plugin->getOutputDescriptors();
Chris@330 352
Chris@330 353 for (size_t j = 0; j < outputs.size(); ++j) {
Chris@330 354
Chris@330 355 QString transformId = QString("%1:%2")
Chris@330 356 .arg(pluginId).arg(outputs[j].identifier.c_str());
Chris@330 357
Chris@330 358 QString userName;
Chris@330 359 QString friendlyName;
Chris@330 360 QString units = outputs[j].unit.c_str();
Chris@330 361 QString description = plugin->getDescription().c_str();
Chris@330 362 QString maker = plugin->getMaker().c_str();
Chris@330 363 if (maker == "") maker = tr("<unknown maker>");
Chris@330 364
Chris@443 365 QString longDescription = description;
Chris@443 366
Chris@443 367 if (longDescription == "") {
Chris@330 368 if (outputs.size() == 1) {
Chris@443 369 longDescription = tr("Extract features using \"%1\" plugin (from %2)")
Chris@330 370 .arg(pluginName).arg(maker);
Chris@330 371 } else {
Chris@443 372 longDescription = tr("Extract features using \"%1\" output of \"%2\" plugin (from %3)")
Chris@330 373 .arg(outputs[j].name.c_str()).arg(pluginName).arg(maker);
Chris@330 374 }
Chris@330 375 } else {
Chris@330 376 if (outputs.size() == 1) {
Chris@443 377 longDescription = tr("%1 using \"%2\" plugin (from %3)")
Chris@443 378 .arg(longDescription).arg(pluginName).arg(maker);
Chris@330 379 } else {
Chris@443 380 longDescription = tr("%1 using \"%2\" output of \"%3\" plugin (from %4)")
Chris@443 381 .arg(longDescription).arg(outputs[j].name.c_str()).arg(pluginName).arg(maker);
Chris@330 382 }
Chris@330 383 }
Chris@330 384
Chris@330 385 if (outputs.size() == 1) {
Chris@330 386 userName = pluginName;
Chris@330 387 friendlyName = pluginName;
Chris@330 388 } else {
Chris@330 389 userName = QString("%1: %2")
Chris@330 390 .arg(pluginName)
Chris@330 391 .arg(outputs[j].name.c_str());
Chris@330 392 friendlyName = outputs[j].name.c_str();
Chris@330 393 }
Chris@330 394
Chris@330 395 bool configurable = (!plugin->getPrograms().empty() ||
Chris@330 396 !plugin->getParameterDescriptors().empty());
Chris@330 397
Chris@443 398 // cerr << "Feature extraction plugin transform: " << transformId.toStdString() << " friendly name: " << friendlyName.toStdString() << endl;
Chris@330 399
Chris@330 400 transforms[transformId] =
Chris@330 401 TransformDescription(tr("Analysis"),
Chris@332 402 category,
Chris@332 403 transformId,
Chris@332 404 userName,
Chris@332 405 friendlyName,
Chris@332 406 description,
Chris@443 407 longDescription,
Chris@332 408 maker,
Chris@332 409 units,
Chris@332 410 configurable);
Chris@330 411 }
Chris@330 412
Chris@330 413 delete plugin;
Chris@330 414 }
Chris@330 415 }
Chris@330 416
Chris@330 417 void
Chris@330 418 TransformFactory::populateRealTimePlugins(TransformDescriptionMap &transforms)
Chris@330 419 {
Chris@330 420 std::vector<QString> plugs =
Chris@330 421 RealTimePluginFactory::getAllPluginIdentifiers();
Chris@330 422
Chris@330 423 static QRegExp unitRE("[\\[\\(]([A-Za-z0-9/]+)[\\)\\]]$");
Chris@330 424
Chris@330 425 for (size_t i = 0; i < plugs.size(); ++i) {
Chris@330 426
Chris@330 427 QString pluginId = plugs[i];
Chris@330 428
Chris@330 429 RealTimePluginFactory *factory =
Chris@330 430 RealTimePluginFactory::instanceFor(pluginId);
Chris@330 431
Chris@330 432 if (!factory) {
Chris@443 433 cerr << "WARNING: TransformFactory::populateTransforms: No real time plugin factory for instance " << pluginId.toLocal8Bit().data() << endl;
Chris@330 434 continue;
Chris@330 435 }
Chris@330 436
Chris@330 437 const RealTimePluginDescriptor *descriptor =
Chris@330 438 factory->getPluginDescriptor(pluginId);
Chris@330 439
Chris@330 440 if (!descriptor) {
Chris@443 441 cerr << "WARNING: TransformFactory::populateTransforms: Failed to query plugin " << pluginId.toLocal8Bit().data() << endl;
Chris@330 442 continue;
Chris@330 443 }
Chris@330 444
Chris@330 445 //!!! if (descriptor->controlOutputPortCount == 0 ||
Chris@330 446 // descriptor->audioInputPortCount == 0) continue;
Chris@330 447
Chris@443 448 // std::cout << "TransformFactory::populateRealTimePlugins: plugin " << pluginId.toStdString() << " has " << descriptor->controlOutputPortCount << " control output ports, " << descriptor->audioOutputPortCount << " audio outputs, " << descriptor->audioInputPortCount << " audio inputs" << endl;
Chris@330 449
Chris@330 450 QString pluginName = descriptor->name.c_str();
Chris@330 451 QString category = factory->getPluginCategory(pluginId);
Chris@330 452 bool configurable = (descriptor->parameterCount > 0);
Chris@330 453 QString maker = descriptor->maker.c_str();
Chris@330 454 if (maker == "") maker = tr("<unknown maker>");
Chris@330 455
Chris@330 456 if (descriptor->audioInputPortCount > 0) {
Chris@330 457
Chris@330 458 for (size_t j = 0; j < descriptor->controlOutputPortCount; ++j) {
Chris@330 459
Chris@330 460 QString transformId = QString("%1:%2").arg(pluginId).arg(j);
Chris@330 461 QString userName;
Chris@330 462 QString units;
Chris@330 463 QString portName;
Chris@330 464
Chris@330 465 if (j < descriptor->controlOutputPortNames.size() &&
Chris@330 466 descriptor->controlOutputPortNames[j] != "") {
Chris@330 467
Chris@330 468 portName = descriptor->controlOutputPortNames[j].c_str();
Chris@330 469
Chris@330 470 userName = tr("%1: %2")
Chris@330 471 .arg(pluginName)
Chris@330 472 .arg(portName);
Chris@330 473
Chris@330 474 if (unitRE.indexIn(portName) >= 0) {
Chris@330 475 units = unitRE.cap(1);
Chris@330 476 }
Chris@330 477
Chris@330 478 } else if (descriptor->controlOutputPortCount > 1) {
Chris@330 479
Chris@330 480 userName = tr("%1: Output %2")
Chris@330 481 .arg(pluginName)
Chris@330 482 .arg(j + 1);
Chris@330 483
Chris@330 484 } else {
Chris@330 485
Chris@330 486 userName = pluginName;
Chris@330 487 }
Chris@330 488
Chris@330 489 QString description;
Chris@330 490
Chris@330 491 if (portName != "") {
Chris@330 492 description = tr("Extract \"%1\" data output from \"%2\" effect plugin (from %3)")
Chris@330 493 .arg(portName)
Chris@330 494 .arg(pluginName)
Chris@330 495 .arg(maker);
Chris@330 496 } else {
Chris@330 497 description = tr("Extract data output %1 from \"%2\" effect plugin (from %3)")
Chris@330 498 .arg(j + 1)
Chris@330 499 .arg(pluginName)
Chris@330 500 .arg(maker);
Chris@330 501 }
Chris@330 502
Chris@330 503 transforms[transformId] =
Chris@330 504 TransformDescription(tr("Effects Data"),
Chris@332 505 category,
Chris@332 506 transformId,
Chris@332 507 userName,
Chris@332 508 userName,
Chris@443 509 "",
Chris@332 510 description,
Chris@332 511 maker,
Chris@332 512 units,
Chris@332 513 configurable);
Chris@330 514 }
Chris@330 515 }
Chris@330 516
Chris@330 517 if (!descriptor->isSynth || descriptor->audioInputPortCount > 0) {
Chris@330 518
Chris@330 519 if (descriptor->audioOutputPortCount > 0) {
Chris@330 520
Chris@330 521 QString transformId = QString("%1:A").arg(pluginId);
Chris@330 522 QString type = tr("Effects");
Chris@330 523
Chris@330 524 QString description = tr("Transform audio signal with \"%1\" effect plugin (from %2)")
Chris@330 525 .arg(pluginName)
Chris@330 526 .arg(maker);
Chris@330 527
Chris@330 528 if (descriptor->audioInputPortCount == 0) {
Chris@330 529 type = tr("Generators");
Chris@330 530 QString description = tr("Generate audio signal using \"%1\" plugin (from %2)")
Chris@330 531 .arg(pluginName)
Chris@330 532 .arg(maker);
Chris@330 533 }
Chris@330 534
Chris@330 535 transforms[transformId] =
Chris@330 536 TransformDescription(type,
Chris@332 537 category,
Chris@332 538 transformId,
Chris@332 539 pluginName,
Chris@332 540 pluginName,
Chris@443 541 "",
Chris@332 542 description,
Chris@332 543 maker,
Chris@332 544 "",
Chris@332 545 configurable);
Chris@330 546 }
Chris@330 547 }
Chris@330 548 }
Chris@330 549 }
Chris@330 550
Chris@457 551 void
Chris@457 552 TransformFactory::populateUninstalledTransforms()
Chris@457 553 {
Chris@460 554 populateTransforms();
Chris@460 555
Chris@460 556 MutexLocker locker(&m_uninstalledTransformsMutex,
Chris@460 557 "TransformFactory::populateUninstalledTransforms");
Chris@460 558 if (m_uninstalledTransformsPopulated) return;
Chris@460 559
Chris@461 560 PluginRDFIndexer::getInstance()->indexConfiguredURLs();
Chris@457 561
Chris@457 562 //!!! This will be amazingly slow
Chris@457 563
Chris@457 564 QStringList ids = PluginRDFIndexer::getInstance()->getIndexedPluginIds();
Chris@457 565
Chris@457 566 for (QStringList::const_iterator i = ids.begin(); i != ids.end(); ++i) {
Chris@457 567
Chris@457 568 PluginRDFDescription desc(*i);
Chris@457 569
Chris@457 570 QString name = desc.getPluginName();
Chris@457 571 // if (name == "") {
Chris@457 572 // std::cerr << "TransformFactory::populateUninstalledTransforms: "
Chris@457 573 // << "No name available for plugin " << i->toStdString()
Chris@457 574 // << ", skipping" << std::endl;
Chris@457 575 // continue;
Chris@457 576 // }
Chris@457 577
Chris@457 578 QString description = desc.getPluginDescription();
Chris@457 579 QString maker = desc.getPluginMaker();
Chris@462 580 QString infoUrl = desc.getPluginInfoURL();
Chris@457 581
Chris@457 582 QStringList oids = desc.getOutputIds();
Chris@457 583
Chris@457 584 for (QStringList::const_iterator j = oids.begin(); j != oids.end(); ++j) {
Chris@457 585
Chris@457 586 TransformId tid = Transform::getIdentifierForPluginOutput(*i, *j);
Chris@457 587
Chris@457 588 if (m_transforms.find(tid) != m_transforms.end()) {
Chris@457 589 std::cerr << "TransformFactory::populateUninstalledTransforms: "
Chris@468 590 << tid.toStdString() << " is installed; adding info url if appropriate, skipping rest" << std::endl;
Chris@468 591 if (infoUrl != "") {
Chris@468 592 if (m_transforms[tid].infoUrl == "") {
Chris@468 593 m_transforms[tid].infoUrl = infoUrl;
Chris@468 594 }
Chris@468 595 }
Chris@457 596 continue;
Chris@457 597 }
Chris@457 598
Chris@457 599 std::cerr << "TransformFactory::populateUninstalledTransforms: "
Chris@457 600 << "adding " << tid.toStdString() << std::endl;
Chris@457 601
Chris@457 602 QString oname = desc.getOutputName(*j);
Chris@457 603 if (oname == "") oname = *j;
Chris@457 604
Chris@457 605 TransformDescription td;
Chris@457 606 td.type = tr("Analysis"); //!!! should be enum or something
Chris@457 607 td.category = "";
Chris@457 608 td.identifier = tid;
Chris@457 609
Chris@457 610 if (oids.size() == 1) {
Chris@457 611 td.name = name;
Chris@457 612 } else if (name != "") {
Chris@457 613 td.name = tr("%1: %2").arg(name).arg(oname);
Chris@457 614 }
Chris@457 615
Chris@462 616 QString longDescription = description;
Chris@462 617 //!!! basically duplicated from above
Chris@462 618 if (longDescription == "") {
Chris@462 619 if (oids.size() == 1) {
Chris@462 620 longDescription = tr("Extract features using \"%1\" plugin (from %2)")
Chris@462 621 .arg(name).arg(maker);
Chris@462 622 } else {
Chris@462 623 longDescription = tr("Extract features using \"%1\" output of \"%2\" plugin (from %3)")
Chris@462 624 .arg(oname).arg(name).arg(maker);
Chris@462 625 }
Chris@462 626 } else {
Chris@462 627 if (oids.size() == 1) {
Chris@462 628 longDescription = tr("%1 using \"%2\" plugin (from %3)")
Chris@462 629 .arg(longDescription).arg(name).arg(maker);
Chris@462 630 } else {
Chris@462 631 longDescription = tr("%1 using \"%2\" output of \"%3\" plugin (from %4)")
Chris@462 632 .arg(longDescription).arg(oname).arg(name).arg(maker);
Chris@462 633 }
Chris@462 634 }
Chris@462 635
Chris@457 636 td.friendlyName = name; //!!!???
Chris@457 637 td.description = description;
Chris@462 638 td.longDescription = longDescription;
Chris@457 639 td.maker = maker;
Chris@462 640 td.infoUrl = infoUrl;
Chris@457 641 td.units = "";
Chris@457 642 td.configurable = false;
Chris@457 643
Chris@457 644 m_uninstalledTransforms[tid] = td;
Chris@457 645 }
Chris@457 646 }
Chris@457 647
Chris@457 648 m_uninstalledTransformsPopulated = true;
Chris@460 649
Chris@460 650 std::cerr << "populateUninstalledTransforms exiting" << std::endl;
Chris@457 651 }
Chris@350 652
Chris@350 653 Transform
Chris@350 654 TransformFactory::getDefaultTransformFor(TransformId id, size_t rate)
Chris@350 655 {
Chris@350 656 Transform t;
Chris@350 657 t.setIdentifier(id);
Chris@350 658 if (rate != 0) t.setSampleRate(rate);
Chris@350 659
Chris@351 660 Vamp::PluginBase *plugin = instantiateDefaultPluginFor(id, rate);
Chris@350 661
Chris@350 662 if (plugin) {
Chris@366 663 t.setPluginVersion(QString("%1").arg(plugin->getPluginVersion()));
Chris@350 664 setParametersFromPlugin(t, plugin);
Chris@350 665 makeContextConsistentWithPlugin(t, plugin);
Chris@350 666 delete plugin;
Chris@350 667 }
Chris@350 668
Chris@350 669 return t;
Chris@350 670 }
Chris@350 671
Chris@350 672 Vamp::PluginBase *
Chris@351 673 TransformFactory::instantiatePluginFor(const Transform &transform)
Chris@351 674 {
Chris@351 675 Vamp::PluginBase *plugin = instantiateDefaultPluginFor
Chris@351 676 (transform.getIdentifier(), transform.getSampleRate());
Chris@351 677 if (plugin) {
Chris@351 678 setPluginParameters(transform, plugin);
Chris@351 679 }
Chris@351 680 return plugin;
Chris@351 681 }
Chris@351 682
Chris@351 683 Vamp::PluginBase *
Chris@351 684 TransformFactory::instantiateDefaultPluginFor(TransformId identifier, size_t rate)
Chris@350 685 {
Chris@350 686 Transform t;
Chris@350 687 t.setIdentifier(identifier);
Chris@350 688 if (rate == 0) rate = 44100;
Chris@350 689 QString pluginId = t.getPluginIdentifier();
Chris@350 690
Chris@350 691 Vamp::PluginBase *plugin = 0;
Chris@350 692
Chris@350 693 if (t.getType() == Transform::FeatureExtraction) {
Chris@350 694
Chris@350 695 FeatureExtractionPluginFactory *factory =
Chris@350 696 FeatureExtractionPluginFactory::instanceFor(pluginId);
Chris@350 697
Chris@439 698 if (factory) {
Chris@439 699 plugin = factory->instantiatePlugin(pluginId, rate);
Chris@439 700 }
Chris@350 701
Chris@350 702 } else {
Chris@350 703
Chris@350 704 RealTimePluginFactory *factory =
Chris@350 705 RealTimePluginFactory::instanceFor(pluginId);
Chris@439 706
Chris@439 707 if (factory) {
Chris@439 708 plugin = factory->instantiatePlugin(pluginId, 0, 0, rate, 1024, 1);
Chris@439 709 }
Chris@350 710 }
Chris@350 711
Chris@350 712 return plugin;
Chris@350 713 }
Chris@350 714
Chris@350 715 Vamp::Plugin *
Chris@350 716 TransformFactory::downcastVampPlugin(Vamp::PluginBase *plugin)
Chris@350 717 {
Chris@350 718 Vamp::Plugin *vp = dynamic_cast<Vamp::Plugin *>(plugin);
Chris@350 719 if (!vp) {
Chris@443 720 // cerr << "makeConsistentWithPlugin: not a Vamp::Plugin" << endl;
Chris@350 721 vp = dynamic_cast<Vamp::PluginHostAdapter *>(plugin); //!!! why?
Chris@350 722 }
Chris@350 723 if (!vp) {
Chris@443 724 // cerr << "makeConsistentWithPlugin: not a Vamp::PluginHostAdapter" << endl;
Chris@350 725 vp = dynamic_cast<Vamp::HostExt::PluginWrapper *>(plugin); //!!! no, I mean really why?
Chris@350 726 }
Chris@350 727 if (!vp) {
Chris@443 728 // cerr << "makeConsistentWithPlugin: not a Vamp::HostExt::PluginWrapper" << endl;
Chris@350 729 }
Chris@350 730 return vp;
Chris@350 731 }
Chris@350 732
Chris@330 733 bool
Chris@330 734 TransformFactory::haveTransform(TransformId identifier)
Chris@330 735 {
Chris@460 736 populateTransforms();
Chris@330 737 return (m_transforms.find(identifier) != m_transforms.end());
Chris@330 738 }
Chris@330 739
Chris@330 740 QString
Chris@330 741 TransformFactory::getTransformName(TransformId identifier)
Chris@330 742 {
Chris@330 743 if (m_transforms.find(identifier) != m_transforms.end()) {
Chris@330 744 return m_transforms[identifier].name;
Chris@330 745 } else return "";
Chris@330 746 }
Chris@330 747
Chris@330 748 QString
Chris@330 749 TransformFactory::getTransformFriendlyName(TransformId identifier)
Chris@330 750 {
Chris@330 751 if (m_transforms.find(identifier) != m_transforms.end()) {
Chris@330 752 return m_transforms[identifier].friendlyName;
Chris@330 753 } else return "";
Chris@330 754 }
Chris@330 755
Chris@330 756 QString
Chris@330 757 TransformFactory::getTransformUnits(TransformId identifier)
Chris@330 758 {
Chris@330 759 if (m_transforms.find(identifier) != m_transforms.end()) {
Chris@330 760 return m_transforms[identifier].units;
Chris@330 761 } else return "";
Chris@330 762 }
Chris@330 763
Chris@472 764 QString
Chris@472 765 TransformFactory::getTransformInfoUrl(TransformId identifier)
Chris@472 766 {
Chris@472 767 if (m_transforms.find(identifier) != m_transforms.end()) {
Chris@472 768 return m_transforms[identifier].infoUrl;
Chris@472 769 } else return "";
Chris@472 770 }
Chris@472 771
Chris@350 772 Vamp::Plugin::InputDomain
Chris@350 773 TransformFactory::getTransformInputDomain(TransformId identifier)
Chris@350 774 {
Chris@350 775 Transform transform;
Chris@350 776 transform.setIdentifier(identifier);
Chris@350 777
Chris@350 778 if (transform.getType() != Transform::FeatureExtraction) {
Chris@350 779 return Vamp::Plugin::TimeDomain;
Chris@350 780 }
Chris@350 781
Chris@350 782 Vamp::Plugin *plugin =
Chris@351 783 downcastVampPlugin(instantiateDefaultPluginFor(identifier, 0));
Chris@350 784
Chris@350 785 if (plugin) {
Chris@350 786 Vamp::Plugin::InputDomain d = plugin->getInputDomain();
Chris@350 787 delete plugin;
Chris@350 788 return d;
Chris@350 789 }
Chris@350 790
Chris@350 791 return Vamp::Plugin::TimeDomain;
Chris@350 792 }
Chris@350 793
Chris@330 794 bool
Chris@330 795 TransformFactory::isTransformConfigurable(TransformId identifier)
Chris@330 796 {
Chris@330 797 if (m_transforms.find(identifier) != m_transforms.end()) {
Chris@330 798 return m_transforms[identifier].configurable;
Chris@330 799 } else return false;
Chris@330 800 }
Chris@330 801
Chris@330 802 bool
Chris@330 803 TransformFactory::getTransformChannelRange(TransformId identifier,
Chris@330 804 int &min, int &max)
Chris@330 805 {
Chris@330 806 QString id = identifier.section(':', 0, 2);
Chris@330 807
Chris@330 808 if (FeatureExtractionPluginFactory::instanceFor(id)) {
Chris@330 809
Chris@330 810 Vamp::Plugin *plugin =
Chris@330 811 FeatureExtractionPluginFactory::instanceFor(id)->
Chris@350 812 instantiatePlugin(id, 44100);
Chris@330 813 if (!plugin) return false;
Chris@330 814
Chris@330 815 min = plugin->getMinChannelCount();
Chris@330 816 max = plugin->getMaxChannelCount();
Chris@330 817 delete plugin;
Chris@330 818
Chris@330 819 return true;
Chris@330 820
Chris@330 821 } else if (RealTimePluginFactory::instanceFor(id)) {
Chris@330 822
Chris@350 823 // don't need to instantiate
Chris@350 824
Chris@330 825 const RealTimePluginDescriptor *descriptor =
Chris@330 826 RealTimePluginFactory::instanceFor(id)->
Chris@330 827 getPluginDescriptor(id);
Chris@330 828 if (!descriptor) return false;
Chris@330 829
Chris@330 830 min = descriptor->audioInputPortCount;
Chris@330 831 max = descriptor->audioInputPortCount;
Chris@330 832
Chris@330 833 return true;
Chris@330 834 }
Chris@330 835
Chris@330 836 return false;
Chris@330 837 }
Chris@332 838
Chris@332 839 void
Chris@332 840 TransformFactory::setParametersFromPlugin(Transform &transform,
Chris@332 841 Vamp::PluginBase *plugin)
Chris@332 842 {
Chris@332 843 Transform::ParameterMap pmap;
Chris@332 844
Chris@350 845 //!!! record plugin & API version
Chris@350 846
Chris@350 847 //!!! check that this is the right plugin!
Chris@350 848
Chris@332 849 Vamp::PluginBase::ParameterList parameters =
Chris@332 850 plugin->getParameterDescriptors();
Chris@332 851
Chris@332 852 for (Vamp::PluginBase::ParameterList::const_iterator i = parameters.begin();
Chris@332 853 i != parameters.end(); ++i) {
Chris@332 854 pmap[i->identifier.c_str()] = plugin->getParameter(i->identifier);
Chris@332 855 }
Chris@332 856
Chris@332 857 transform.setParameters(pmap);
Chris@332 858
Chris@332 859 if (plugin->getPrograms().empty()) {
Chris@332 860 transform.setProgram("");
Chris@332 861 } else {
Chris@332 862 transform.setProgram(plugin->getCurrentProgram().c_str());
Chris@332 863 }
Chris@332 864
Chris@332 865 RealTimePluginInstance *rtpi =
Chris@332 866 dynamic_cast<RealTimePluginInstance *>(plugin);
Chris@332 867
Chris@332 868 Transform::ConfigurationMap cmap;
Chris@332 869
Chris@332 870 if (rtpi) {
Chris@332 871
Chris@332 872 RealTimePluginInstance::ConfigurationPairMap configurePairs =
Chris@332 873 rtpi->getConfigurePairs();
Chris@332 874
Chris@332 875 for (RealTimePluginInstance::ConfigurationPairMap::const_iterator i
Chris@332 876 = configurePairs.begin(); i != configurePairs.end(); ++i) {
Chris@332 877 cmap[i->first.c_str()] = i->second.c_str();
Chris@332 878 }
Chris@332 879 }
Chris@332 880
Chris@332 881 transform.setConfiguration(cmap);
Chris@332 882 }
Chris@332 883
Chris@332 884 void
Chris@350 885 TransformFactory::setPluginParameters(const Transform &transform,
Chris@350 886 Vamp::PluginBase *plugin)
Chris@350 887 {
Chris@350 888 //!!! check plugin & API version (see e.g. PluginXml::setParameters)
Chris@350 889
Chris@350 890 //!!! check that this is the right plugin!
Chris@350 891
Chris@350 892 RealTimePluginInstance *rtpi =
Chris@350 893 dynamic_cast<RealTimePluginInstance *>(plugin);
Chris@350 894
Chris@350 895 if (rtpi) {
Chris@350 896 const Transform::ConfigurationMap &cmap = transform.getConfiguration();
Chris@350 897 for (Transform::ConfigurationMap::const_iterator i = cmap.begin();
Chris@350 898 i != cmap.end(); ++i) {
Chris@350 899 rtpi->configure(i->first.toStdString(), i->second.toStdString());
Chris@350 900 }
Chris@350 901 }
Chris@350 902
Chris@350 903 if (transform.getProgram() != "") {
Chris@350 904 plugin->selectProgram(transform.getProgram().toStdString());
Chris@350 905 }
Chris@350 906
Chris@350 907 const Transform::ParameterMap &pmap = transform.getParameters();
Chris@350 908
Chris@350 909 Vamp::PluginBase::ParameterList parameters =
Chris@350 910 plugin->getParameterDescriptors();
Chris@350 911
Chris@350 912 for (Vamp::PluginBase::ParameterList::const_iterator i = parameters.begin();
Chris@350 913 i != parameters.end(); ++i) {
Chris@350 914 QString key = i->identifier.c_str();
Chris@350 915 Transform::ParameterMap::const_iterator pmi = pmap.find(key);
Chris@350 916 if (pmi != pmap.end()) {
Chris@350 917 plugin->setParameter(i->identifier, pmi->second);
Chris@350 918 }
Chris@350 919 }
Chris@350 920 }
Chris@350 921
Chris@350 922 void
Chris@332 923 TransformFactory::makeContextConsistentWithPlugin(Transform &transform,
Chris@332 924 Vamp::PluginBase *plugin)
Chris@332 925 {
Chris@350 926 const Vamp::Plugin *vp = downcastVampPlugin(plugin);
Chris@332 927
Chris@332 928 if (!vp) {
Chris@332 929 // time domain input for real-time effects plugin
Chris@332 930 if (!transform.getBlockSize()) {
Chris@332 931 if (!transform.getStepSize()) transform.setStepSize(1024);
Chris@332 932 transform.setBlockSize(transform.getStepSize());
Chris@332 933 } else {
Chris@332 934 transform.setStepSize(transform.getBlockSize());
Chris@332 935 }
Chris@332 936 } else {
Chris@332 937 Vamp::Plugin::InputDomain domain = vp->getInputDomain();
Chris@332 938 if (!transform.getStepSize()) {
Chris@332 939 transform.setStepSize(vp->getPreferredStepSize());
Chris@332 940 }
Chris@332 941 if (!transform.getBlockSize()) {
Chris@332 942 transform.setBlockSize(vp->getPreferredBlockSize());
Chris@332 943 }
Chris@332 944 if (!transform.getBlockSize()) {
Chris@332 945 transform.setBlockSize(1024);
Chris@332 946 }
Chris@332 947 if (!transform.getStepSize()) {
Chris@332 948 if (domain == Vamp::Plugin::FrequencyDomain) {
Chris@443 949 // cerr << "frequency domain, step = " << blockSize/2 << endl;
Chris@332 950 transform.setStepSize(transform.getBlockSize()/2);
Chris@332 951 } else {
Chris@443 952 // cerr << "time domain, step = " << blockSize/2 << endl;
Chris@332 953 transform.setStepSize(transform.getBlockSize());
Chris@332 954 }
Chris@332 955 }
Chris@332 956 }
Chris@332 957 }
Chris@332 958
Chris@350 959 QString
Chris@350 960 TransformFactory::getPluginConfigurationXml(const Transform &t)
Chris@332 961 {
Chris@350 962 QString xml;
Chris@350 963
Chris@351 964 Vamp::PluginBase *plugin = instantiateDefaultPluginFor
Chris@351 965 (t.getIdentifier(), 0);
Chris@350 966 if (!plugin) {
Chris@443 967 cerr << "TransformFactory::getPluginConfigurationXml: "
Chris@350 968 << "Unable to instantiate plugin for transform \""
Chris@443 969 << t.getIdentifier().toStdString() << "\"" << endl;
Chris@350 970 return xml;
Chris@332 971 }
Chris@332 972
Chris@351 973 setPluginParameters(t, plugin);
Chris@351 974
Chris@350 975 QTextStream out(&xml);
Chris@350 976 PluginXml(plugin).toXml(out);
Chris@350 977 delete plugin;
Chris@332 978
Chris@350 979 return xml;
Chris@350 980 }
Chris@332 981
Chris@350 982 void
Chris@350 983 TransformFactory::setParametersFromPluginConfigurationXml(Transform &t,
Chris@350 984 QString xml)
Chris@350 985 {
Chris@351 986 Vamp::PluginBase *plugin = instantiateDefaultPluginFor
Chris@351 987 (t.getIdentifier(), 0);
Chris@350 988 if (!plugin) {
Chris@443 989 cerr << "TransformFactory::setParametersFromPluginConfigurationXml: "
Chris@350 990 << "Unable to instantiate plugin for transform \""
Chris@443 991 << t.getIdentifier().toStdString() << "\"" << endl;
Chris@350 992 return;
Chris@332 993 }
Chris@332 994
Chris@350 995 PluginXml(plugin).setParametersFromXml(xml);
Chris@350 996 setParametersFromPlugin(t, plugin);
Chris@350 997 delete plugin;
Chris@332 998 }
Chris@332 999
Chris@443 1000 TransformFactory::SearchResults
Chris@443 1001 TransformFactory::search(QString keyword)
Chris@443 1002 {
Chris@443 1003 QStringList keywords;
Chris@443 1004 keywords << keyword;
Chris@443 1005 return search(keywords);
Chris@443 1006 }
Chris@443 1007
Chris@443 1008 TransformFactory::SearchResults
Chris@443 1009 TransformFactory::search(QStringList keywords)
Chris@443 1010 {
Chris@460 1011 populateTransforms();
Chris@443 1012
Chris@447 1013 if (keywords.size() > 1) {
Chris@447 1014 // Additional score for all keywords in a row
Chris@447 1015 keywords.push_back(keywords.join(" "));
Chris@447 1016 }
Chris@447 1017
Chris@443 1018 SearchResults results;
Chris@457 1019 TextMatcher matcher;
Chris@443 1020
Chris@443 1021 for (TransformDescriptionMap::const_iterator i = m_transforms.begin();
Chris@443 1022 i != m_transforms.end(); ++i) {
Chris@443 1023
Chris@457 1024 TextMatcher::Match match;
Chris@443 1025
Chris@457 1026 match.key = i->first;
Chris@443 1027
Chris@457 1028 matcher.test(match, keywords, i->second.type, tr("Plugin type"), 5);
Chris@457 1029 matcher.test(match, keywords, i->second.category, tr("Category"), 20);
Chris@457 1030 matcher.test(match, keywords, i->second.identifier, tr("System Identifier"), 6);
Chris@457 1031 matcher.test(match, keywords, i->second.name, tr("Name"), 30);
Chris@457 1032 matcher.test(match, keywords, i->second.description, tr("Description"), 20);
Chris@457 1033 matcher.test(match, keywords, i->second.maker, tr("Maker"), 10);
Chris@457 1034 matcher.test(match, keywords, i->second.units, tr("Units"), 10);
Chris@457 1035
Chris@457 1036 if (match.score > 0) results[i->first] = match;
Chris@457 1037 }
Chris@457 1038
Chris@460 1039 if (!m_uninstalledTransformsMutex.tryLock()) {
Chris@460 1040 // uninstalled transforms are being populated; this may take some time,
Chris@460 1041 // and they aren't critical
Chris@460 1042 std::cerr << "TransformFactory::search: Uninstalled transforms mutex is held, skipping" << std::endl;
Chris@460 1043 return results;
Chris@460 1044 }
Chris@460 1045
Chris@460 1046 if (!m_uninstalledTransformsPopulated) {
Chris@460 1047 std::cerr << "WARNING: TransformFactory::search: Uninstalled transforms are not populated yet" << endl
Chris@460 1048 << "and are not being populated either -- was the thread not started correctly?" << endl;
Chris@460 1049 m_uninstalledTransformsMutex.unlock();
Chris@460 1050 return results;
Chris@460 1051 }
Chris@460 1052
Chris@460 1053 m_uninstalledTransformsMutex.unlock();
Chris@457 1054
Chris@457 1055 for (TransformDescriptionMap::const_iterator i = m_uninstalledTransforms.begin();
Chris@457 1056 i != m_uninstalledTransforms.end(); ++i) {
Chris@457 1057
Chris@457 1058 TextMatcher::Match match;
Chris@457 1059
Chris@457 1060 match.key = i->first;
Chris@457 1061
Chris@457 1062 matcher.test(match, keywords, i->second.type, tr("Plugin type"), 2);
Chris@457 1063 matcher.test(match, keywords, i->second.category, tr("Category"), 10);
Chris@457 1064 matcher.test(match, keywords, i->second.identifier, tr("System Identifier"), 3);
Chris@457 1065 matcher.test(match, keywords, i->second.name, tr("Name"), 15);
Chris@457 1066 matcher.test(match, keywords, i->second.description, tr("Description"), 10);
Chris@457 1067 matcher.test(match, keywords, i->second.maker, tr("Maker"), 5);
Chris@457 1068 matcher.test(match, keywords, i->second.units, tr("Units"), 5);
Chris@443 1069
Chris@443 1070 if (match.score > 0) results[i->first] = match;
Chris@443 1071 }
Chris@443 1072
Chris@443 1073 return results;
Chris@443 1074 }
Chris@443 1075