# HG changeset patch # User Chris Cannam # Date 1143128981 0 # Node ID 7439f1696314d8796f479b5a0589466d02acdc71 # Parent 2157fa46c1e74f5cba1ddb4b2f5ca25e24b5e00f * Add editing for auralisation plugin parameters and programs * Rename and reorganise the sample plugin sample set diff -r 2157fa46c1e7 -r 7439f1696314 base/PlayParameterRepository.cpp --- 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(sender())); + PlayParameters *params = dynamic_cast(sender()); + emit playParametersChanged(params); +} + +void +PlayParameterRepository::playPluginIdChanged(QString id) +{ + PlayParameters *params = dynamic_cast(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(sender()); + for (ModelParameterMap::iterator i = m_playParameters.begin(); + i != m_playParameters.end(); ++i) { + if (i->second == params) { + emit playPluginConfigurationChanged(i->first, config); + return; + } + } } void diff -r 2157fa46c1e7 -r 7439f1696314 base/PlayParameterRepository.h --- 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 m_playParameters; + typedef std::map ModelParameterMap; + ModelParameterMap m_playParameters; static PlayParameterRepository *m_instance; }; diff -r 2157fa46c1e7 -r 7439f1696314 base/PlayParameters.cpp --- 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(); + } +} + + diff -r 2157fa46c1e7 -r 7439f1696314 base/PlayParameters.h --- 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 diff -r 2157fa46c1e7 -r 7439f1696314 plugin/DSSIPluginInstance.cpp --- 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(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) { diff -r 2157fa46c1e7 -r 7439f1696314 plugin/DSSIPluginInstance.h --- 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; diff -r 2157fa46c1e7 -r 7439f1696314 plugin/FeatureExtractionPlugin.h --- 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) { } diff -r 2157fa46c1e7 -r 7439f1696314 plugin/LADSPAPluginFactory.cpp --- 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) { diff -r 2157fa46c1e7 -r 7439f1696314 plugin/LADSPAPluginFactory.h --- 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: diff -r 2157fa46c1e7 -r 7439f1696314 plugin/LADSPAPluginInstance.cpp --- 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(m_factory); int inbuf = 0, outbuf = 0; for (std::vector::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) { diff -r 2157fa46c1e7 -r 7439f1696314 plugin/LADSPAPluginInstance.h --- 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; diff -r 2157fa46c1e7 -r 7439f1696314 plugin/PluginInstance.cpp --- 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; diff -r 2157fa46c1e7 -r 7439f1696314 plugin/PluginInstance.h --- 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 { diff -r 2157fa46c1e7 -r 7439f1696314 plugin/RealTimePluginInstance.h --- 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) { } diff -r 2157fa46c1e7 -r 7439f1696314 transform/TransformFactory.cpp --- 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; } } diff -r 2157fa46c1e7 -r 7439f1696314 transform/TransformFactory.h --- 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