Mercurial > hg > sonic-visualiser
comparison transform/TransformFactory.cpp @ 53:94f1c2747de4
* Tidy up plugin parameter dialog by switching it to a simple constructor
with separate methods for passing in the additional options if necessary
* Fix sizing problem on advanced pane toggle in plugin parameter dialog
* Make a start on passing in list of candidate input models for transform
author | Chris Cannam |
---|---|
date | Wed, 11 Oct 2006 16:18:51 +0000 |
parents | 527598e2fa10 |
children | ec77936c268e |
comparison
equal
deleted
inserted
replaced
52:527598e2fa10 | 53:94f1c2747de4 |
---|---|
439 } else { | 439 } else { |
440 return getTransformChannelRange(name, minChannels, maxChannels); | 440 return getTransformChannelRange(name, minChannels, maxChannels); |
441 } | 441 } |
442 } | 442 } |
443 | 443 |
444 bool | 444 Model * |
445 TransformFactory::getConfigurationForTransform(TransformName name, | 445 TransformFactory::getConfigurationForTransform(TransformName name, |
446 Model *inputModel, | 446 const std::vector<Model *> &candidateInputModels, |
447 PluginTransform::ExecutionContext &context, | 447 PluginTransform::ExecutionContext &context, |
448 QString &configurationXml, | 448 QString &configurationXml, |
449 AudioCallbackPlaySource *source) | 449 AudioCallbackPlaySource *source) |
450 { | 450 { |
451 if (candidateInputModels.empty()) return 0; | |
452 | |
453 Model *inputModel = candidateInputModels[0]; //!!! for now | |
454 | |
451 QString id = name.section(':', 0, 2); | 455 QString id = name.section(':', 0, 2); |
452 QString output = name.section(':', 3); | 456 QString output = name.section(':', 3); |
457 QString outputLabel = ""; | |
453 | 458 |
454 bool ok = false; | 459 bool ok = false; |
455 configurationXml = m_lastConfigurations[name]; | 460 configurationXml = m_lastConfigurations[name]; |
456 | 461 |
457 // std::cerr << "last configuration: " << configurationXml.toStdString() << std::endl; | 462 // std::cerr << "last configuration: " << configurationXml.toStdString() << std::endl; |
464 if (FeatureExtractionPluginFactory::instanceFor(id)) { | 469 if (FeatureExtractionPluginFactory::instanceFor(id)) { |
465 | 470 |
466 Vamp::Plugin *vp = | 471 Vamp::Plugin *vp = |
467 FeatureExtractionPluginFactory::instanceFor(id)->instantiatePlugin | 472 FeatureExtractionPluginFactory::instanceFor(id)->instantiatePlugin |
468 (id, inputModel->getSampleRate()); | 473 (id, inputModel->getSampleRate()); |
474 | |
469 if (vp) { | 475 if (vp) { |
476 | |
470 plugin = vp; | 477 plugin = vp; |
471 frequency = (vp->getInputDomain() == Vamp::Plugin::FrequencyDomain); | 478 frequency = (vp->getInputDomain() == Vamp::Plugin::FrequencyDomain); |
479 | |
480 std::vector<Vamp::Plugin::OutputDescriptor> od = | |
481 vp->getOutputDescriptors(); | |
482 if (od.size() > 1) { | |
483 for (size_t i = 0; i < od.size(); ++i) { | |
484 if (od[i].name == output.toStdString()) { | |
485 outputLabel = od[i].description.c_str(); | |
486 break; | |
487 } | |
488 } | |
489 } | |
472 } | 490 } |
473 | 491 |
474 } else if (RealTimePluginFactory::instanceFor(id)) { | 492 } else if (RealTimePluginFactory::instanceFor(id)) { |
475 | 493 |
476 RealTimePluginFactory *factory = RealTimePluginFactory::instanceFor(id); | 494 RealTimePluginFactory *factory = RealTimePluginFactory::instanceFor(id); |
478 | 496 |
479 if (desc->audioInputPortCount > 0 && | 497 if (desc->audioInputPortCount > 0 && |
480 desc->audioOutputPortCount > 0 && | 498 desc->audioOutputPortCount > 0 && |
481 !desc->isSynth) { | 499 !desc->isSynth) { |
482 effect = true; | 500 effect = true; |
501 } | |
502 | |
503 if (output != "A") { | |
504 int outputNo = output.toInt(); | |
505 if (outputNo >= 0 && outputNo < desc->controlOutputPortCount) { | |
506 outputLabel = desc->controlOutputPortNames[outputNo].c_str(); | |
507 } | |
483 } | 508 } |
484 | 509 |
485 size_t sampleRate = inputModel->getSampleRate(); | 510 size_t sampleRate = inputModel->getSampleRate(); |
486 size_t blockSize = 1024; | 511 size_t blockSize = 1024; |
487 size_t channels = 1; | 512 size_t channels = 1; |
524 if (sourceChannels > maxChannels) targetChannels = maxChannels; | 549 if (sourceChannels > maxChannels) targetChannels = maxChannels; |
525 } | 550 } |
526 | 551 |
527 int defaultChannel = context.channel; | 552 int defaultChannel = context.channel; |
528 | 553 |
529 PluginParameterDialog *dialog = new PluginParameterDialog(plugin, | 554 PluginParameterDialog *dialog = new PluginParameterDialog(plugin); |
530 sourceChannels, | 555 |
531 targetChannels, | 556 dialog->setChannelArrangement(sourceChannels, targetChannels, |
532 defaultChannel, | 557 defaultChannel); |
533 output, | 558 |
534 true, | 559 dialog->setOutputLabel(outputLabel); |
535 frequency); | 560 |
561 dialog->setShowProcessingOptions(true, frequency); | |
562 | |
536 if (dialog->exec() == QDialog::Accepted) { | 563 if (dialog->exec() == QDialog::Accepted) { |
537 ok = true; | 564 ok = true; |
538 } | 565 } |
539 | 566 |
540 configurationXml = PluginXml(plugin).toXmlString(); | 567 configurationXml = PluginXml(plugin).toXmlString(); |
555 } | 582 } |
556 } | 583 } |
557 | 584 |
558 if (ok) m_lastConfigurations[name] = configurationXml; | 585 if (ok) m_lastConfigurations[name] = configurationXml; |
559 | 586 |
560 return ok; | 587 return ok ? inputModel : 0; |
561 } | 588 } |
562 | 589 |
563 Transform * | 590 Transform * |
564 TransformFactory::createTransform(TransformName name, Model *inputModel, | 591 TransformFactory::createTransform(TransformName name, Model *inputModel, |
565 const PluginTransform::ExecutionContext &context, | 592 const PluginTransform::ExecutionContext &context, |