changeset 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
files main/MainWindow.cpp transform/TransformFactory.cpp transform/TransformFactory.h
diffstat 3 files changed, 73 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/main/MainWindow.cpp	Tue Oct 10 19:04:57 2006 +0000
+++ b/main/MainWindow.cpp	Wed Oct 11 16:18:51 2006 +0000
@@ -2967,8 +2967,34 @@
 
     PluginTransform::ExecutionContext context(channel);
 
+    std::vector<Model *> candidateInputModels;
+    candidateInputModels.push_back(m_document->getMainModel());
+
+    //!!! rationalise this (via document method for example)
+    for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
+        Pane *ip = m_paneStack->getPane(i);
+        if (!ip) continue;
+        for (int j = 0; j < ip->getLayerCount(); ++j) {
+            Layer *jl = ip->getLayer(j);
+            if (jl) {
+                Model *model = jl->getModel();
+                DenseTimeValueModel *dtvm = dynamic_cast<DenseTimeValueModel *>
+                    (model);
+                if (dtvm) {
+                    int k;
+                    for (k = 0; k < candidateInputModels.size(); ++k) {
+                        if (candidateInputModels[k] == dtvm) break;
+                    }
+                    if (k == candidateInputModels.size()) {
+                        candidateInputModels.push_back(dtvm);
+                    }
+                }
+            }
+        }
+    }
+
     bool ok = factory->getConfigurationForTransform(transform,
-                                                    m_document->getMainModel(),
+                                                    candidateInputModels,
                                                     context,
                                                     configurationXml,
                                                     m_playSource);
--- 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 *
--- a/transform/TransformFactory.h	Tue Oct 10 19:04:57 2006 +0000
+++ b/transform/TransformFactory.h	Wed Oct 11 16:18:51 2006 +0000
@@ -78,16 +78,16 @@
 
     /**
      * Get a configuration XML string for the given transform (by
-     * asking the user, most likely).  Returns true if the transform
-     * is acceptable, false if the operation should be cancelled.
-     * Audio callback play source may be used to audition effects
-     * plugins, if provided.
+     * asking the user, most likely).  Returns the selected input
+     * model if the transform is acceptable, 0 if the operation should
+     * be cancelled.  Audio callback play source may be used to
+     * audition effects plugins, if provided.
      */
-    bool getConfigurationForTransform(TransformName name,
-                                      Model *inputModel,
-                                      PluginTransform::ExecutionContext &context,
-                                      QString &configurationXml,
-                                      AudioCallbackPlaySource *source = 0);
+    Model *getConfigurationForTransform(TransformName name,
+                                        const std::vector<Model *> &candidateInputModels,
+                                        PluginTransform::ExecutionContext &context,
+                                        QString &configurationXml,
+                                        AudioCallbackPlaySource *source = 0);
 
     /**
      * Return the output model resulting from applying the named