Mercurial > hg > svcore
comparison plugin/PluginXml.cpp @ 75:163f3428bbe0
* Create temporary directory, cleaned up on exit, and use it to store
(inter alia) audio samples for the sample-player plugin.
* Ensure newly added layers always have unique names
* Make sure configure pairs for real-time plugins are stored in the
configuration Xml along with parameter & program settings
author | Chris Cannam |
---|---|
date | Mon, 10 Apr 2006 13:52:32 +0000 |
parents | 7afcfe666910 |
children | f277a171749d |
comparison
equal
deleted
inserted
replaced
74:47fd14e29813 | 75:163f3428bbe0 |
---|---|
22 #include <QDomElement> | 22 #include <QDomElement> |
23 #include <QDomNamedNodeMap> | 23 #include <QDomNamedNodeMap> |
24 #include <QDomAttr> | 24 #include <QDomAttr> |
25 | 25 |
26 #include "vamp-sdk/PluginBase.h" | 26 #include "vamp-sdk/PluginBase.h" |
27 #include "RealTimePluginInstance.h" | |
27 | 28 |
28 #include <iostream> | 29 #include <iostream> |
29 | 30 |
30 PluginXml::PluginXml(Vamp::PluginBase *plugin) : | 31 PluginXml::PluginXml(Vamp::PluginBase *plugin) : |
31 m_plugin(plugin) | 32 m_plugin(plugin) |
61 s += QString("param-%1=\"%2\" ") | 62 s += QString("param-%1=\"%2\" ") |
62 .arg(stripInvalidParameterNameCharacters(QString(i->name.c_str()))) | 63 .arg(stripInvalidParameterNameCharacters(QString(i->name.c_str()))) |
63 .arg(m_plugin->getParameter(i->name)); | 64 .arg(m_plugin->getParameter(i->name)); |
64 } | 65 } |
65 | 66 |
67 RealTimePluginInstance *rtpi = | |
68 dynamic_cast<RealTimePluginInstance *>(m_plugin); | |
69 if (rtpi) { | |
70 std::map<std::string, std::string> configurePairs = | |
71 rtpi->getConfigurePairs(); | |
72 QString config; | |
73 for (std::map<std::string, std::string>::iterator i = configurePairs.begin(); | |
74 i != configurePairs.end(); ++i) { | |
75 QString key = i->first.c_str(); | |
76 QString value = i->second.c_str(); | |
77 key.replace(";", "[[SEMICOLON]]"); | |
78 key.replace("=", "[[EQUALS]]"); | |
79 value.replace(";", "[[SEMICOLON]]"); | |
80 value.replace("=", "[[EQUALS]]"); | |
81 if (config != "") config += ";"; | |
82 config += QString("%1=%2").arg(key).arg(value); | |
83 } | |
84 if (config != "") { | |
85 s += QString("configuration=\"%1\" ") | |
86 .arg(encodeEntities(config)); | |
87 } | |
88 } | |
89 | |
66 s += "/>\n"; | 90 s += "/>\n"; |
67 return s; | 91 return s; |
68 } | 92 } |
69 | 93 |
70 #define CHECK_ATTRIBUTE(ATTRIBUTE, ACCESSOR) \ | 94 #define CHECK_ATTRIBUTE(ATTRIBUTE, ACCESSOR) \ |
88 int version = attrs.value("version").trimmed().toInt(&ok); | 112 int version = attrs.value("version").trimmed().toInt(&ok); |
89 if (ok && version != m_plugin->getPluginVersion()) { | 113 if (ok && version != m_plugin->getPluginVersion()) { |
90 std::cerr << "WARNING: PluginXml::setParameters: Plugin version does not match (attributes have " << version << ", my version is " << m_plugin->getPluginVersion() << ")" << std::endl; | 114 std::cerr << "WARNING: PluginXml::setParameters: Plugin version does not match (attributes have " << version << ", my version is " << m_plugin->getPluginVersion() << ")" << std::endl; |
91 } | 115 } |
92 | 116 |
117 RealTimePluginInstance *rtpi = | |
118 dynamic_cast<RealTimePluginInstance *>(m_plugin); | |
119 if (rtpi) { | |
120 QString config = attrs.value("configuration"); | |
121 if (config != "") { | |
122 QStringList configList = config.split(";"); | |
123 for (QStringList::iterator i = configList.begin(); | |
124 i != configList.end(); ++i) { | |
125 QStringList kv = i->split("="); | |
126 if (kv.count() < 2) { | |
127 std::cerr << "WARNING: PluginXml::setParameters: Malformed configure pair string: \"" << i->toStdString() << "\"" << std::endl; | |
128 continue; | |
129 } | |
130 QString key(kv[0]), value(kv[1]); | |
131 key.replace("[[SEMICOLON]]", ";"); | |
132 key.replace("[[EQUALS]]", ";"); | |
133 value.replace("[[SEMICOLON]]", ";"); | |
134 value.replace("[[SEMICOLON]]", ";"); | |
135 rtpi->configure(key.toStdString(), value.toStdString()); | |
136 } | |
137 } | |
138 } | |
139 | |
93 if (!m_plugin->getPrograms().empty()) { | 140 if (!m_plugin->getPrograms().empty()) { |
94 m_plugin->selectProgram(attrs.value("program").toStdString()); | 141 m_plugin->selectProgram(attrs.value("program").toStdString()); |
95 } | 142 } |
96 | 143 |
97 Vamp::PluginBase::ParameterList parameters = | 144 Vamp::PluginBase::ParameterList parameters = |