comparison transform/TransformFactory.cpp @ 66:7afcfe666910

* Modify to use Vamp SDK for proper feature extraction plugins. Requires that the vamp-plugin-sdk directory tree be present below plugin/ (it's separate in Subversion).
author Chris Cannam
date Fri, 31 Mar 2006 15:56:35 +0000
parents 4d59dc469b0f
children 2beca8ddcdc3
comparison
equal deleted inserted replaced
65:e1aad27029e3 66:7afcfe666910
18 #include "FeatureExtractionPluginTransform.h" 18 #include "FeatureExtractionPluginTransform.h"
19 #include "RealTimePluginTransform.h" 19 #include "RealTimePluginTransform.h"
20 20
21 #include "plugin/FeatureExtractionPluginFactory.h" 21 #include "plugin/FeatureExtractionPluginFactory.h"
22 #include "plugin/RealTimePluginFactory.h" 22 #include "plugin/RealTimePluginFactory.h"
23 #include "plugin/PluginXml.h"
23 24
24 #include "widgets/PluginParameterDialog.h" 25 #include "widgets/PluginParameterDialog.h"
25 26
26 #include "model/DenseTimeValueModel.h" 27 #include "model/DenseTimeValueModel.h"
27 28
137 if (!factory) { 138 if (!factory) {
138 std::cerr << "WARNING: TransformFactory::populateTransforms: No feature extraction plugin factory for instance " << pluginId.toLocal8Bit().data() << std::endl; 139 std::cerr << "WARNING: TransformFactory::populateTransforms: No feature extraction plugin factory for instance " << pluginId.toLocal8Bit().data() << std::endl;
139 continue; 140 continue;
140 } 141 }
141 142
142 FeatureExtractionPlugin *plugin = 143 Vamp::Plugin *plugin =
143 factory->instantiatePlugin(pluginId, 48000); 144 factory->instantiatePlugin(pluginId, 48000);
144 145
145 if (!plugin) { 146 if (!plugin) {
146 std::cerr << "WARNING: TransformFactory::populateTransforms: Failed to instantiate plugin " << pluginId.toLocal8Bit().data() << std::endl; 147 std::cerr << "WARNING: TransformFactory::populateTransforms: Failed to instantiate plugin " << pluginId.toLocal8Bit().data() << std::endl;
147 continue; 148 continue;
148 } 149 }
149 150
150 QString pluginDescription = plugin->getDescription().c_str(); 151 QString pluginDescription = plugin->getDescription().c_str();
151 FeatureExtractionPlugin::OutputList outputs = 152 Vamp::Plugin::OutputList outputs =
152 plugin->getOutputDescriptors(); 153 plugin->getOutputDescriptors();
153 154
154 for (size_t j = 0; j < outputs.size(); ++j) { 155 for (size_t j = 0; j < outputs.size(); ++j) {
155 156
156 QString transformName = QString("%1:%2") 157 QString transformName = QString("%1:%2")
303 { 304 {
304 QString id = name.section(':', 0, 2); 305 QString id = name.section(':', 0, 2);
305 306
306 if (FeatureExtractionPluginFactory::instanceFor(id)) { 307 if (FeatureExtractionPluginFactory::instanceFor(id)) {
307 308
308 FeatureExtractionPlugin *plugin = 309 Vamp::Plugin *plugin =
309 FeatureExtractionPluginFactory::instanceFor(id)-> 310 FeatureExtractionPluginFactory::instanceFor(id)->
310 instantiatePlugin(id, 48000); 311 instantiatePlugin(id, 48000);
311 if (!plugin) return false; 312 if (!plugin) return false;
312 313
313 min = plugin->getMinChannelCount(); 314 min = plugin->getMinChannelCount();
344 bool ok = false; 345 bool ok = false;
345 configurationXml = m_lastConfigurations[name]; 346 configurationXml = m_lastConfigurations[name];
346 347
347 std::cerr << "last configuration: " << configurationXml.toStdString() << std::endl; 348 std::cerr << "last configuration: " << configurationXml.toStdString() << std::endl;
348 349
349 PluginInstance *plugin = 0; 350 Vamp::PluginBase *plugin = 0;
350 351
351 if (FeatureExtractionPluginFactory::instanceFor(id)) { 352 if (FeatureExtractionPluginFactory::instanceFor(id)) {
352 353
353 plugin = FeatureExtractionPluginFactory::instanceFor(id)->instantiatePlugin 354 plugin = FeatureExtractionPluginFactory::instanceFor(id)->instantiatePlugin
354 (id, inputModel->getSampleRate()); 355 (id, inputModel->getSampleRate());
359 (id, 0, 0, inputModel->getSampleRate(), 1024, 1); 360 (id, 0, 0, inputModel->getSampleRate(), 1024, 1);
360 } 361 }
361 362
362 if (plugin) { 363 if (plugin) {
363 if (configurationXml != "") { 364 if (configurationXml != "") {
364 plugin->setParametersFromXml(configurationXml); 365 PluginXml(plugin).setParametersFromXml(configurationXml);
365 } 366 }
366 367
367 int sourceChannels = 1; 368 int sourceChannels = 1;
368 if (dynamic_cast<DenseTimeValueModel *>(inputModel)) { 369 if (dynamic_cast<DenseTimeValueModel *>(inputModel)) {
369 sourceChannels = dynamic_cast<DenseTimeValueModel *>(inputModel) 370 sourceChannels = dynamic_cast<DenseTimeValueModel *>(inputModel)
384 targetChannels, 385 targetChannels,
385 defaultChannel); 386 defaultChannel);
386 if (dialog->exec() == QDialog::Accepted) { 387 if (dialog->exec() == QDialog::Accepted) {
387 ok = true; 388 ok = true;
388 } 389 }
389 configurationXml = plugin->toXmlString(); 390 configurationXml = PluginXml(plugin).toXmlString();
390 channel = dialog->getChannel(); 391 channel = dialog->getChannel();
391 delete dialog; 392 delete dialog;
392 delete plugin; 393 delete plugin;
393 } 394 }
394 395