diff 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
line wrap: on
line diff
--- a/transform/TransformFactory.cpp	Tue Oct 10 19:04:57 2006 +0000
+++ b/transform/TransformFactory.cpp	Wed Oct 11 16:18:51 2006 +0000
@@ -441,15 +441,20 @@
     }
 }
 
-bool
+Model *
 TransformFactory::getConfigurationForTransform(TransformName name,
-                                               Model *inputModel,
+                                               const std::vector<Model *> &candidateInputModels,
                                                PluginTransform::ExecutionContext &context,
                                                QString &configurationXml,
                                                AudioCallbackPlaySource *source)
 {
+    if (candidateInputModels.empty()) return 0;
+
+    Model *inputModel = candidateInputModels[0]; //!!! for now
+
     QString id = name.section(':', 0, 2);
     QString output = name.section(':', 3);
+    QString outputLabel = "";
     
     bool ok = false;
     configurationXml = m_lastConfigurations[name];
@@ -466,9 +471,22 @@
         Vamp::Plugin *vp =
             FeatureExtractionPluginFactory::instanceFor(id)->instantiatePlugin
             (id, inputModel->getSampleRate());
+
         if (vp) {
+
             plugin = vp;
             frequency = (vp->getInputDomain() == Vamp::Plugin::FrequencyDomain);
+
+            std::vector<Vamp::Plugin::OutputDescriptor> od =
+                vp->getOutputDescriptors();
+            if (od.size() > 1) {
+                for (size_t i = 0; i < od.size(); ++i) {
+                    if (od[i].name == output.toStdString()) {
+                        outputLabel = od[i].description.c_str();
+                        break;
+                    }
+                }
+            }
         }
 
     } else if (RealTimePluginFactory::instanceFor(id)) {
@@ -482,6 +500,13 @@
             effect = true;
         }
 
+        if (output != "A") {
+            int outputNo = output.toInt();
+            if (outputNo >= 0 && outputNo < desc->controlOutputPortCount) {
+                outputLabel = desc->controlOutputPortNames[outputNo].c_str();
+            }
+        }
+
         size_t sampleRate = inputModel->getSampleRate();
         size_t blockSize = 1024;
         size_t channels = 1;
@@ -526,13 +551,15 @@
 
         int defaultChannel = context.channel;
 
-        PluginParameterDialog *dialog = new PluginParameterDialog(plugin,
-                                                                  sourceChannels,
-                                                                  targetChannels,
-                                                                  defaultChannel,
-                                                                  output,
-                                                                  true,
-                                                                  frequency);
+        PluginParameterDialog *dialog = new PluginParameterDialog(plugin);
+
+        dialog->setChannelArrangement(sourceChannels, targetChannels,
+                                      defaultChannel);
+        
+        dialog->setOutputLabel(outputLabel);
+        
+        dialog->setShowProcessingOptions(true, frequency);
+
         if (dialog->exec() == QDialog::Accepted) {
             ok = true;
         }
@@ -557,7 +584,7 @@
 
     if (ok) m_lastConfigurations[name] = configurationXml;
 
-    return ok;
+    return ok ? inputModel : 0;
 }
 
 Transform *