changeset 54:ec77936c268e

* Add system-specific LADSPA and DSSI plugin paths (for OS/X and Windows) * Add ability to open more than one audio file at once from the command line * Add plugin input source selection (with some caveats) * Show name of file being decoded in Ogg/mp3 decode progress dialog
author Chris Cannam
date Thu, 12 Oct 2006 14:56:28 +0000
parents 94f1c2747de4
children ca1e3f5657d5
files document/Document.cpp main/MainWindow.cpp main/MainWindow.h main/main.cpp transform/TransformFactory.cpp
diffstat 5 files changed, 88 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/document/Document.cpp	Wed Oct 11 16:18:51 2006 +0000
+++ b/document/Document.cpp	Thu Oct 12 14:56:28 2006 +0000
@@ -318,6 +318,8 @@
 	return;
     }
 
+    std::cerr << "Document::addDerivedModel: source is " << inputModel << " \"" << inputModel->objectName().toStdString() << std::endl;
+
     ModelRecord rec;
     rec.source = inputModel;
     rec.transform = transform;
--- a/main/MainWindow.cpp	Wed Oct 11 16:18:51 2006 +0000
+++ b/main/MainWindow.cpp	Thu Oct 12 14:56:28 2006 +0000
@@ -2282,9 +2282,9 @@
 }
 
 bool
-MainWindow::openSomeFile(QString path)
+MainWindow::openSomeFile(QString path, AudioFileOpenMode mode)
 {
-    if (openAudioFile(path)) {
+    if (openAudioFile(path, mode)) {
 	return true;
     } else if (openSessionFile(path)) {
 	return true;
@@ -2993,15 +2993,17 @@
         }
     }
 
-    bool ok = factory->getConfigurationForTransform(transform,
-                                                    candidateInputModels,
-                                                    context,
-                                                    configurationXml,
-                                                    m_playSource);
-    if (!ok) return;
+    Model *inputModel = factory->getConfigurationForTransform(transform,
+                                                              candidateInputModels,
+                                                              context,
+                                                              configurationXml,
+                                                              m_playSource);
+    if (!inputModel) return;
+
+    std::cerr << "Input model is " << inputModel << " \"" << inputModel->objectName().toStdString() << std::endl;
 
     Layer *newLayer = m_document->createDerivedLayer(transform,
-                                                     m_document->getMainModel(),
+                                                     inputModel,
                                                      context,
                                                      configurationXml);
 
--- a/main/MainWindow.h	Wed Oct 11 16:18:51 2006 +0000
+++ b/main/MainWindow.h	Thu Oct 12 14:56:28 2006 +0000
@@ -64,7 +64,7 @@
         AskUser
     };
 
-    bool openSomeFile(QString path);
+    bool openSomeFile(QString path, AudioFileOpenMode = AskUser);
     bool openAudioFile(QString path, AudioFileOpenMode = AskUser);
     bool openLayerFile(QString path);
     bool openSessionFile(QString path);
--- a/main/main.cpp	Wed Oct 11 16:18:51 2006 +0000
+++ b/main/main.cpp	Thu Oct 12 14:56:28 2006 +0000
@@ -138,17 +138,56 @@
     settings.endGroup();
     
     gui.show();
-
-    QString path;
+/*
+    QStringList pathList;
     for (QStringList::iterator i = args.begin(); i != args.end(); ++i) {
         if (i == args.begin()) continue;
         if (!i->startsWith('-')) {
-            path = *i;
-            break;
+            pathList.push_back(*i);
         }
     }
+*/
+    bool haveSession = false;
+    bool haveMainModel = false;
 
-    if (!path.isEmpty()) {
+    for (QStringList::iterator i = args.begin(); i != args.end(); ++i) {
+
+        bool success = false;
+
+        if (i == args.begin()) continue;
+        if (i->startsWith('-')) continue;
+
+        QString path = *i;
+
+        if (path.endsWith("sv")) {
+            if (!haveSession) {
+                success = gui.openSessionFile(path);
+                if (success) {
+                    haveSession = true;
+                    haveMainModel = true;
+                }
+            } else {
+                std::cerr << "WARNING: Ignoring additional session file argument \"" << path.toStdString() << "\"" << std::endl;
+                success = true;
+            }
+        }
+        if (!success) {
+            if (!haveMainModel) {
+                success = gui.openSomeFile(path, MainWindow::ReplaceMainModel);
+                if (success) haveMainModel = true;
+            } else {
+                success = gui.openSomeFile(path, MainWindow::CreateAdditionalModel);
+            }
+        }
+        if (!success) {
+	    QMessageBox::critical
+                (&gui, QMessageBox::tr("Failed to open file"),
+                 QMessageBox::tr("File \"%1\" could not be opened").arg(path));
+        }
+    }            
+    /*       
+
+    if (!pathList.isEmpty()) {
         bool success = false;
         if (path.endsWith(".sv")) {
             success = gui.openSessionFile(path);
@@ -161,6 +200,7 @@
 				  QMessageBox::tr("File \"%1\" could not be opened").arg(path));
 	}
     }
+    */
 
     int rv = application.exec();
     std::cerr << "application.exec() returned " << rv << std::endl;
--- a/transform/TransformFactory.cpp	Wed Oct 11 16:18:51 2006 +0000
+++ b/transform/TransformFactory.cpp	Thu Oct 12 14:56:28 2006 +0000
@@ -450,7 +450,22 @@
 {
     if (candidateInputModels.empty()) return 0;
 
+    //!!! This will need revision -- we'll have to have a callback
+    //from the dialog for when the candidate input model is changed,
+    //as we'll need to reinitialise the channel settings in the dialog
     Model *inputModel = candidateInputModels[0]; //!!! for now
+    QStringList candidateModelNames;
+    std::map<QString, Model *> modelMap;
+    for (size_t i = 0; i < candidateInputModels.size(); ++i) {
+        QString modelName = candidateInputModels[i]->objectName();
+        QString origModelName = modelName;
+        int dupcount = 1;
+        while (modelMap.find(modelName) != modelMap.end()) {
+            modelName = tr("%1 <%2>").arg(origModelName).arg(++dupcount);
+        }
+        modelMap[modelName] = candidateInputModels[i];
+        candidateModelNames.push_back(modelName);
+    }
 
     QString id = name.section(':', 0, 2);
     QString output = name.section(':', 3);
@@ -553,6 +568,10 @@
 
         PluginParameterDialog *dialog = new PluginParameterDialog(plugin);
 
+        if (candidateModelNames.size() > 1) {
+            dialog->setCandidateInputModels(candidateModelNames);
+        }
+
         dialog->setChannelArrangement(sourceChannels, targetChannels,
                                       defaultChannel);
         
@@ -564,6 +583,16 @@
             ok = true;
         }
 
+        QString selectedInput = dialog->getInputModel();
+        if (selectedInput != "") {
+            if (modelMap.find(selectedInput) != modelMap.end()) {
+                inputModel = modelMap[selectedInput];
+                std::cerr << "Found selected input \"" << selectedInput.toStdString() << "\" in model map, result is " << inputModel << std::endl;
+            } else {
+                std::cerr << "Failed to find selected input \"" << selectedInput.toStdString() << "\" in model map" << std::endl;
+            }
+        }
+
         configurationXml = PluginXml(plugin).toXmlString();
         context.channel = dialog->getChannel();