changeset 57:7439f1696314

* Add editing for auralisation plugin parameters and programs * Rename and reorganise the sample plugin sample set
author Chris Cannam
date Thu, 23 Mar 2006 15:49:41 +0000
parents 2157fa46c1e7
children 0a34d529f8e0
files base/PlayParameterRepository.cpp base/PlayParameterRepository.h base/PlayParameters.cpp base/PlayParameters.h plugin/DSSIPluginInstance.cpp plugin/DSSIPluginInstance.h plugin/FeatureExtractionPlugin.h plugin/LADSPAPluginFactory.cpp plugin/LADSPAPluginFactory.h plugin/LADSPAPluginInstance.cpp plugin/LADSPAPluginInstance.h plugin/PluginInstance.cpp plugin/PluginInstance.h plugin/RealTimePluginInstance.h transform/TransformFactory.cpp transform/TransformFactory.h
diffstat 16 files changed, 174 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/base/PlayParameterRepository.cpp	Wed Mar 22 17:38:29 2006 +0000
+++ b/base/PlayParameterRepository.cpp	Thu Mar 23 15:49:41 2006 +0000
@@ -48,9 +48,21 @@
 
 	    m_playParameters[model] = new PlayParameters;
 
+            m_playParameters[model]->setPlayPluginId
+                (AudioGenerator::getDefaultPlayPluginId(model));
+
+            m_playParameters[model]->setPlayPluginConfiguration
+                (AudioGenerator::getDefaultPlayPluginConfiguration(model));
+
 	    connect(m_playParameters[model], SIGNAL(playParametersChanged()),
 		    this, SLOT(playParametersChanged()));
 
+	    connect(m_playParameters[model], SIGNAL(playPluginIdChanged(QString)),
+		    this, SLOT(playPluginIdChanged(QString)));
+
+	    connect(m_playParameters[model], SIGNAL(playPluginConfigurationChanged(QString)),
+		    this, SLOT(playPluginConfigurationChanged(QString)));
+
 	} else {
 
 	    std::cerr << "PlayParameterRepository: Model " << model << " not playable" <<  std::endl;
@@ -75,7 +87,34 @@
 void
 PlayParameterRepository::playParametersChanged()
 {
-    emit playParametersChanged(dynamic_cast<PlayParameters *>(sender()));
+    PlayParameters *params = dynamic_cast<PlayParameters *>(sender());
+    emit playParametersChanged(params);
+}
+
+void
+PlayParameterRepository::playPluginIdChanged(QString id)
+{
+    PlayParameters *params = dynamic_cast<PlayParameters *>(sender());
+    for (ModelParameterMap::iterator i = m_playParameters.begin();
+         i != m_playParameters.end(); ++i) {
+        if (i->second == params) {
+            emit playPluginIdChanged(i->first, id);
+            return;
+        }
+    }
+}
+
+void
+PlayParameterRepository::playPluginConfigurationChanged(QString config)
+{
+    PlayParameters *params = dynamic_cast<PlayParameters *>(sender());
+    for (ModelParameterMap::iterator i = m_playParameters.begin();
+         i != m_playParameters.end(); ++i) {
+        if (i->second == params) {
+            emit playPluginConfigurationChanged(i->first, config);
+            return;
+        }
+    }
 }
 
 void
--- a/base/PlayParameterRepository.h	Wed Mar 22 17:38:29 2006 +0000
+++ b/base/PlayParameterRepository.h	Thu Mar 23 15:49:41 2006 +0000
@@ -41,12 +41,17 @@
 
 signals:
     void playParametersChanged(PlayParameters *);
+    void playPluginIdChanged(const Model *, QString);
+    void playPluginConfigurationChanged(const Model *, QString);
 
 protected slots:
     void playParametersChanged();
+    void playPluginIdChanged(QString);
+    void playPluginConfigurationChanged(QString);
 
 protected:
-    std::map<const Model *, PlayParameters *> m_playParameters;
+    typedef std::map<const Model *, PlayParameters *> ModelParameterMap;
+    ModelParameterMap m_playParameters;
 
     static PlayParameterRepository *m_instance;
 };
--- a/base/PlayParameters.cpp	Wed Mar 22 17:38:29 2006 +0000
+++ b/base/PlayParameters.cpp	Thu Mar 23 15:49:41 2006 +0000
@@ -37,17 +37,41 @@
 void
 PlayParameters::setPlayPan(float pan)
 {
-    m_playPan = pan;
-    emit playPanChanged(pan);
-    emit playParametersChanged();
+    if (m_playPan != pan) {
+        m_playPan = pan;
+        emit playPanChanged(pan);
+        emit playParametersChanged();
+    }
 }
 
 void
 PlayParameters::setPlayGain(float gain)
 {
-    m_playGain = gain;
-    emit playGainChanged(gain);
-    emit playParametersChanged();
+    if (m_playGain != gain) {
+        m_playGain = gain;
+        emit playGainChanged(gain);
+        emit playParametersChanged();
+    }
 }
 
+void
+PlayParameters::setPlayPluginId(QString id)
+{
+    if (m_playPluginId != id) {
+        m_playPluginId = id;
+        emit playPluginIdChanged(id);
+        emit playParametersChanged();
+    }
+}
 
+void
+PlayParameters::setPlayPluginConfiguration(QString configuration)
+{
+    if (m_playPluginConfiguration != configuration) {
+        m_playPluginConfiguration = configuration;
+        emit playPluginConfigurationChanged(configuration);
+        emit playParametersChanged();
+    }
+}
+
+
--- a/base/PlayParameters.h	Wed Mar 22 17:38:29 2006 +0000
+++ b/base/PlayParameters.h	Thu Mar 23 15:49:41 2006 +0000
@@ -29,11 +29,16 @@
     virtual float getPlayPan() const { return m_playPan; } // -1.0 -> 1.0
     virtual float getPlayGain() const { return m_playGain; }
 
+    virtual QString getPlayPluginId() const { return m_playPluginId; } 
+    virtual QString getPlayPluginConfiguration() const { return m_playPluginConfiguration; }
+
 public slots:
     virtual void setPlayMuted(bool muted);
     virtual void setPlayAudible(bool nonMuted);
     virtual void setPlayPan(float pan);
     virtual void setPlayGain(float gain);
+    virtual void setPlayPluginId(QString id);
+    virtual void setPlayPluginConfiguration(QString configuration);
 
 signals:
     void playParametersChanged();
@@ -41,11 +46,15 @@
     void playAudibleChanged(bool);
     void playPanChanged(float);
     void playGainChanged(float);
+    void playPluginIdChanged(QString);
+    void playPluginConfigurationChanged(QString);
 
 protected:
     bool m_playMuted;
     float m_playPan;
     float m_playGain;
+    QString m_playPluginId;
+    QString m_playPluginConfiguration;
 };
 
 #endif
--- a/plugin/DSSIPluginInstance.cpp	Wed Mar 22 17:38:29 2006 +0000
+++ b/plugin/DSSIPluginInstance.cpp	Thu Mar 23 15:49:41 2006 +0000
@@ -25,7 +25,7 @@
 #include "PluginIdentifier.h"
 #include "LADSPAPluginFactory.h"
 
-//#define DEBUG_DSSI 1
+#define DEBUG_DSSI 1
 //#define DEBUG_DSSI_PROCESS 1
 
 #define EVENT_BUFFER_SIZE 1023
@@ -143,7 +143,14 @@
         pd.minValue = f->getPortMinimum(m_descriptor->LADSPA_Plugin, pn);
         pd.maxValue = f->getPortMaximum(m_descriptor->LADSPA_Plugin, pn);
         pd.defaultValue = f->getPortDefault(m_descriptor->LADSPA_Plugin, pn);
-        pd.isQuantized = false;
+
+        float q = f->getPortQuantization(m_descriptor->LADSPA_Plugin, pn);
+        if (q == 0.0) {
+            pd.isQuantized = false;
+        } else {
+            pd.isQuantized = true;
+            pd.quantizeStep = q;
+        }
 
         list.push_back(pd);
     }
@@ -154,9 +161,13 @@
 float
 DSSIPluginInstance::getParameter(std::string name) const
 {
+    std::cerr << "DSSIPluginInstance::getParameter(" << name << ")" << std::endl;
     for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) {
         if (name == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) {
-            return getParameterValue(i);
+            std::cerr << "Matches port " << i << std::endl;
+            float v = getParameterValue(i);
+            std::cerr << "Returning " << v << std::endl;
+            return v;
         }
     }
 
@@ -166,6 +177,8 @@
 void
 DSSIPluginInstance::setParameter(std::string name, float value)
 {
+    std::cerr << "DSSIPluginInstance::setParameter(" << name << ", " << value << ")" << std::endl;
+
     for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) {
         if (name == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) {
             setParameterValue(i, value);
@@ -647,7 +660,8 @@
 
     assert(sizeof(LADSPA_Data) == sizeof(float));
     assert(sizeof(sample_t) == sizeof(float));
-
+    
+    LADSPAPluginFactory *f = dynamic_cast<LADSPAPluginFactory *>(m_factory);
     int inbuf = 0, outbuf = 0;
 
     for (unsigned int i = 0; i < m_audioPortsIn.size(); ++i) {
@@ -671,6 +685,14 @@
 	    (m_instanceHandle,
 	     m_controlPortsIn[i].first,
 	     m_controlPortsIn[i].second);
+
+        if (f) {
+            float defaultValue = f->getPortDefault
+                (m_descriptor->LADSPA_Plugin, m_controlPortsIn[i].first);
+            *m_controlPortsIn[i].second = defaultValue;
+            m_backupControlPortsIn[i] = defaultValue;
+            std::cerr << "DSSIPluginInstance::connectPorts: set control port " << i << " to default value " << defaultValue << std::endl;
+        }
     }
 
     for (unsigned int i = 0; i < m_controlPortsOut.size(); ++i) {
--- a/plugin/DSSIPluginInstance.h	Wed Mar 22 17:38:29 2006 +0000
+++ b/plugin/DSSIPluginInstance.h	Thu Mar 23 15:49:41 2006 +0000
@@ -93,6 +93,8 @@
     virtual bool isInGroup() const { return m_grouped; }
     virtual void detachFromGroup();
 
+    virtual std::string getType() const { return "DSSI Real-Time Plugin"; }
+
 protected:
     // To be constructed only by DSSIPluginFactory
     friend class DSSIPluginFactory;
--- a/plugin/FeatureExtractionPlugin.h	Wed Mar 22 17:38:29 2006 +0000
+++ b/plugin/FeatureExtractionPlugin.h	Thu Mar 23 15:49:41 2006 +0000
@@ -253,6 +253,8 @@
      */
     virtual FeatureSet getRemainingFeatures() = 0;
 
+    virtual std::string getType() const { return "Feature Extraction Plugin"; }
+
 protected:
     FeatureExtractionPlugin(float inputSampleRate) :
 	m_inputSampleRate(inputSampleRate) { }
--- a/plugin/LADSPAPluginFactory.cpp	Wed Mar 22 17:38:29 2006 +0000
+++ b/plugin/LADSPAPluginFactory.cpp	Thu Mar 23 15:49:41 2006 +0000
@@ -262,6 +262,20 @@
     return deft;
 }
 
+float
+LADSPAPluginFactory::getPortQuantization(const LADSPA_Descriptor *descriptor, int port)
+{
+    int displayHint = getPortDisplayHint(descriptor, port);
+    if (displayHint & PortHint::Toggled) {
+        return lrintf(getPortMaximum(descriptor, port)) - 
+            lrintf(getPortMinimum(descriptor, port));
+    }
+    if (displayHint & PortHint::Integer) {
+        return 1.0;
+    }
+    return 0.0;
+}
+
 int
 LADSPAPluginFactory::getPortDisplayHint(const LADSPA_Descriptor *descriptor, int port)
 {
--- a/plugin/LADSPAPluginFactory.h	Wed Mar 22 17:38:29 2006 +0000
+++ b/plugin/LADSPAPluginFactory.h	Thu Mar 23 15:49:41 2006 +0000
@@ -52,6 +52,7 @@
     float getPortMinimum(const LADSPA_Descriptor *, int port);
     float getPortMaximum(const LADSPA_Descriptor *, int port);
     float getPortDefault(const LADSPA_Descriptor *, int port);
+    float getPortQuantization(const LADSPA_Descriptor *, int port);
     int getPortDisplayHint(const LADSPA_Descriptor *, int port);
 
 protected:
--- a/plugin/LADSPAPluginInstance.cpp	Wed Mar 22 17:38:29 2006 +0000
+++ b/plugin/LADSPAPluginInstance.cpp	Thu Mar 23 15:49:41 2006 +0000
@@ -113,7 +113,14 @@
         pd.minValue = f->getPortMinimum(m_descriptor, pn);
         pd.maxValue = f->getPortMaximum(m_descriptor, pn);
         pd.defaultValue = f->getPortDefault(m_descriptor, pn);
-        pd.isQuantized = false;
+
+        float q = f->getPortQuantization(m_descriptor, pn);
+        if (q == 0.0) {
+            pd.isQuantized = false;
+        } else {
+            pd.isQuantized = true;
+            pd.quantizeStep = q;
+        }
 
         list.push_back(pd);
     }
@@ -335,6 +342,7 @@
     assert(sizeof(LADSPA_Data) == sizeof(float));
     assert(sizeof(sample_t) == sizeof(float));
 
+    LADSPAPluginFactory *f = dynamic_cast<LADSPAPluginFactory *>(m_factory);
     int inbuf = 0, outbuf = 0;
 
     for (std::vector<LADSPA_Handle>::iterator hi = m_instanceHandles.begin();
@@ -364,6 +372,11 @@
 	    m_descriptor->connect_port(*hi,
 				       m_controlPortsIn[i].first,
 				       m_controlPortsIn[i].second);
+            if (f) {
+                float defaultValue = f->getPortDefault
+                    (m_descriptor, m_controlPortsIn[i].first);
+                *m_controlPortsIn[i].second = defaultValue;
+            }
 	}
 
 	for (unsigned int i = 0; i < m_controlPortsOut.size(); ++i) {
--- a/plugin/LADSPAPluginInstance.h	Wed Mar 22 17:38:29 2006 +0000
+++ b/plugin/LADSPAPluginInstance.h	Thu Mar 23 15:49:41 2006 +0000
@@ -74,6 +74,8 @@
     virtual void silence();
     virtual void setIdealChannelCount(size_t channels); // may re-instantiate
 
+    virtual std::string getType() const { return "LADSPA Real-Time Plugin"; }
+
 protected:
     // To be constructed only by LADSPAPluginFactory
     friend class LADSPAPluginFactory;
--- a/plugin/PluginInstance.cpp	Wed Mar 22 17:38:29 2006 +0000
+++ b/plugin/PluginInstance.cpp	Thu Mar 23 15:49:41 2006 +0000
@@ -91,6 +91,10 @@
         QString name = QString("param-%1")
             .arg(stripInvalidParameterNameCharacters
                  (QString(i->name.c_str())));
+        if (attrs.value(name) == "") {
+            std::cerr << "PluginInstance::setParameters: no parameter \"" << i->name << "\" (attribute \"" << name.toStdString() << "\")" << std::endl;
+            continue;
+        }
         bool ok;
         float value = attrs.value(name).trimmed().toFloat(&ok);
         if (ok) {
@@ -119,15 +123,6 @@
     }
 
     QDomElement pluginElt = doc.firstChildElement("plugin");
-
-    if (pluginElt.isNull()) {
-        std::cerr << "pluginElt is null" << std::endl;
-        pluginElt = doc.documentElement();
-        if (pluginElt.isNull()) {
-            std::cerr << "pluginElt is still null" << std::endl;
-        }
-    }
-
     QDomNamedNodeMap attrNodes = pluginElt.attributes();
     QXmlAttributes attrs;
 
--- a/plugin/PluginInstance.h	Wed Mar 22 17:38:29 2006 +0000
+++ b/plugin/PluginInstance.h	Thu Mar 23 15:49:41 2006 +0000
@@ -69,6 +69,12 @@
      */
     virtual std::string getCopyright() const = 0;
 
+    /**
+     * Get the type of plugin (e.g. DSSI, etc).  This is likely to be
+     * implemented by the immediate subclass, not by actual plugins.
+     */
+    virtual std::string getType() const = 0;
+
 
     struct ParameterDescriptor
     {
--- a/plugin/RealTimePluginInstance.h	Wed Mar 22 17:38:29 2006 +0000
+++ b/plugin/RealTimePluginInstance.h	Thu Mar 23 15:49:41 2006 +0000
@@ -120,6 +120,8 @@
 
     void setFactory(RealTimePluginFactory *f) { m_factory = f; } // ew
 
+    virtual std::string getType() const { return "Real-Time Plugin"; }
+
 protected:
     RealTimePluginInstance(RealTimePluginFactory *factory, QString identifier) :
 	m_factory(factory), m_identifier(identifier) { }
--- a/transform/TransformFactory.cpp	Wed Mar 22 17:38:29 2006 +0000
+++ b/transform/TransformFactory.cpp	Thu Mar 23 15:49:41 2006 +0000
@@ -168,6 +168,14 @@
 }
 
 bool
+TransformFactory::isTransformConfigurable(TransformName name)
+{
+    if (m_transforms.find(name) != m_transforms.end()) {
+	return m_transforms[name].configurable;
+    } else return false;
+}
+
+bool
 TransformFactory::getConfigurationForTransform(TransformName name,
                                                Model *inputModel,
                                                QString &configurationXml)
@@ -193,6 +201,7 @@
                 ok = true;
             }
             configurationXml = plugin->toXmlString();
+            delete dialog;
             delete plugin;
         }
     }
--- a/transform/TransformFactory.h	Wed Mar 22 17:38:29 2006 +0000
+++ b/transform/TransformFactory.h	Thu Mar 23 15:49:41 2006 +0000
@@ -82,6 +82,13 @@
      */
     QString getTransformFriendlyName(TransformName name);
 
+    /**
+     * Return true if the transform has any configurable parameters,
+     * i.e. if getConfigurationForTransform can ever return a non-trivial
+     * (not equivalent to empty) configuration string.
+     */
+    bool isTransformConfigurable(TransformName name);
+
     //!!! Need some way to indicate that the input model has changed /
     //been deleted so as not to blow up backgrounded transform!  -- Or
     //indeed, if the output model has been deleted -- could equally