comparison transform/TransformFactory.cpp @ 34:8ad306d8a568

* Pull transforms out of Layer menu (again) and into a separate Transforms menu * Add Recent Transforms submenu * Add effects and generators to the transforms menu (not yet implemented) as well as analysis plugins and data-from-effects (control output ports) * Add a nice dictionary-volume-style alphabetic subdivision of plugin names in plugins By Name menus
author Chris Cannam
date Fri, 22 Sep 2006 16:12:23 +0000
parents 544ab25d2372
children 06787742542a
comparison
equal deleted inserted replaced
33:544ab25d2372 34:8ad306d8a568
49 TransformFactory::TransformList 49 TransformFactory::TransformList
50 TransformFactory::getAllTransforms() 50 TransformFactory::getAllTransforms()
51 { 51 {
52 if (m_transforms.empty()) populateTransforms(); 52 if (m_transforms.empty()) populateTransforms();
53 53
54 TransformList list; 54 std::set<TransformDesc> dset;
55 for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); 55 for (TransformDescriptionMap::const_iterator i = m_transforms.begin();
56 i != m_transforms.end(); ++i) { 56 i != m_transforms.end(); ++i) {
57 list.push_back(i->second); 57 dset.insert(i->second);
58 }
59
60 TransformList list;
61 for (std::set<TransformDesc>::const_iterator i = dset.begin();
62 i != dset.end(); ++i) {
63 list.push_back(*i);
58 } 64 }
59 65
60 return list; 66 return list;
61 } 67 }
62 68
231 237
232 bool configurable = (!plugin->getPrograms().empty() || 238 bool configurable = (!plugin->getPrograms().empty() ||
233 !plugin->getParameterDescriptors().empty()); 239 !plugin->getParameterDescriptors().empty());
234 240
235 transforms[transformName] = 241 transforms[transformName] =
236 TransformDesc(tr("Analysis Plugins"), 242 TransformDesc(tr("Analysis"),
237 category, 243 category,
238 transformName, 244 transformName,
239 userDescription, 245 userDescription,
240 friendlyName, 246 friendlyName,
241 plugin->getMaker().c_str(), 247 plugin->getMaker().c_str(),
249 TransformFactory::populateRealTimePlugins(TransformDescriptionMap &transforms) 255 TransformFactory::populateRealTimePlugins(TransformDescriptionMap &transforms)
250 { 256 {
251 std::vector<QString> plugs = 257 std::vector<QString> plugs =
252 RealTimePluginFactory::getAllPluginIdentifiers(); 258 RealTimePluginFactory::getAllPluginIdentifiers();
253 259
254 QRegExp unitRE("[\\[\\(]([A-Za-z0-9/]+)[\\)\\]]$"); 260 static QRegExp unitRE("[\\[\\(]([A-Za-z0-9/]+)[\\)\\]]$");
255 261
256 for (size_t i = 0; i < plugs.size(); ++i) { 262 for (size_t i = 0; i < plugs.size(); ++i) {
257 263
258 QString pluginId = plugs[i]; 264 QString pluginId = plugs[i];
259 265
271 if (!descriptor) { 277 if (!descriptor) {
272 std::cerr << "WARNING: TransformFactory::populateTransforms: Failed to query plugin " << pluginId.toLocal8Bit().data() << std::endl; 278 std::cerr << "WARNING: TransformFactory::populateTransforms: Failed to query plugin " << pluginId.toLocal8Bit().data() << std::endl;
273 continue; 279 continue;
274 } 280 }
275 281
276 if (descriptor->controlOutputPortCount == 0 || 282 //!!! if (descriptor->controlOutputPortCount == 0 ||
277 descriptor->audioInputPortCount == 0) continue; 283 // descriptor->audioInputPortCount == 0) continue;
278 284
279 // std::cout << "TransformFactory::populateRealTimePlugins: plugin " << pluginId.toStdString() << " has " << descriptor->controlOutputPortCount << " output ports" << std::endl; 285 std::cout << "TransformFactory::populateRealTimePlugins: plugin " << pluginId.toStdString() << " has " << descriptor->controlOutputPortCount << " control output ports, " << descriptor->audioOutputPortCount << " audio outputs, " << descriptor->audioInputPortCount << " audio inputs" << std::endl;
280 286
281 QString pluginDescription = descriptor->name.c_str(); 287 QString pluginDescription = descriptor->name.c_str();
282 QString category = factory->getPluginCategory(pluginId); 288 QString category = factory->getPluginCategory(pluginId);
283 289 bool configurable = (descriptor->parameterCount > 0);
284 for (size_t j = 0; j < descriptor->controlOutputPortCount; ++j) { 290
285 291 if (descriptor->audioInputPortCount > 0) {
286 QString transformName = QString("%1:%2").arg(pluginId).arg(j); 292
287 QString userDescription; 293 for (size_t j = 0; j < descriptor->controlOutputPortCount; ++j) {
288 QString units; 294
289 295 QString transformName = QString("%1:%2").arg(pluginId).arg(j);
290 if (j < descriptor->controlOutputPortNames.size() && 296 QString userDescription;
291 descriptor->controlOutputPortNames[j] != "") { 297 QString units;
292 298
293 QString portName = descriptor->controlOutputPortNames[j].c_str(); 299 if (j < descriptor->controlOutputPortNames.size() &&
294 300 descriptor->controlOutputPortNames[j] != "") {
295 userDescription = tr("%1: %2") 301
296 .arg(pluginDescription) 302 QString portName = descriptor->controlOutputPortNames[j].c_str();
297 .arg(portName); 303
298 304 userDescription = tr("%1: %2")
299 if (unitRE.indexIn(portName) >= 0) { 305 .arg(pluginDescription)
300 units = unitRE.cap(1); 306 .arg(portName);
307
308 if (unitRE.indexIn(portName) >= 0) {
309 units = unitRE.cap(1);
310 }
311
312 } else if (descriptor->controlOutputPortCount > 1) {
313
314 userDescription = tr("%1: Output %2")
315 .arg(pluginDescription)
316 .arg(j + 1);
317
318 } else {
319
320 userDescription = pluginDescription;
301 } 321 }
302 322
303 } else if (descriptor->controlOutputPortCount > 1) { 323
304 324 transforms[transformName] =
305 userDescription = tr("%1: Output %2") 325 TransformDesc(tr("Effects Measurements"),
306 .arg(pluginDescription) 326 category,
307 .arg(j + 1); 327 transformName,
308 328 userDescription,
309 } else { 329 userDescription,
310 330 descriptor->maker.c_str(),
311 userDescription = pluginDescription; 331 units,
332 configurable);
312 } 333 }
313 334 }
314 335
315 bool configurable = (descriptor->parameterCount > 0); 336 if (!descriptor->isSynth || descriptor->audioInputPortCount > 0) {
316 337
317 transforms[transformName] = 338 if (descriptor->audioOutputPortCount > 0) {
318 TransformDesc(tr("Other Plugins"), 339
319 category, 340 QString transformName = QString("%1:A").arg(pluginId);
320 transformName, 341 QString type = tr("Effects");
321 userDescription, 342 if (descriptor->audioInputPortCount == 0) {
322 userDescription, 343 type = tr("Generators");
323 descriptor->maker.c_str(), 344 }
324 units, 345
325 configurable); 346 transforms[transformName] =
326 } 347 TransformDesc(type,
348 category,
349 transformName,
350 pluginDescription,
351 pluginDescription,
352 descriptor->maker.c_str(),
353 "",
354 configurable);
355 }
356 }
327 } 357 }
328 } 358 }
329 359
330 QString 360 QString
331 TransformFactory::getTransformDescription(TransformName name) 361 TransformFactory::getTransformDescription(TransformName name)
514 transform = new RealTimePluginTransform(inputModel, 544 transform = new RealTimePluginTransform(inputModel,
515 id, 545 id,
516 context, 546 context,
517 configurationXml, 547 configurationXml,
518 getTransformUnits(name), 548 getTransformUnits(name),
549 output == "A" ? -1 :
519 output.toInt()); 550 output.toInt());
520 } else { 551 } else {
521 std::cerr << "TransformFactory::createTransform: Unknown transform \"" 552 std::cerr << "TransformFactory::createTransform: Unknown transform \""
522 << name.toStdString() << "\"" << std::endl; 553 << name.toStdString() << "\"" << std::endl;
523 return transform; 554 return transform;