Mercurial > hg > svgui
comparison widgets/PluginParameterBox.cpp @ 71:72fa239a4880
* Modify to use Vamp SDK for proper feature extraction plugins.
Requires that the vamp-plugin-sdk directory tree be present below
plugin/ (it's separate in Subversion).
| author | Chris Cannam |
|---|---|
| date | Fri, 31 Mar 2006 15:56:35 +0000 |
| parents | 10bcd53ddc71 |
| children | 195ad6178ef8 |
comparison
equal
deleted
inserted
replaced
| 70:bf306158803d | 71:72fa239a4880 |
|---|---|
| 15 | 15 |
| 16 #include "PluginParameterBox.h" | 16 #include "PluginParameterBox.h" |
| 17 | 17 |
| 18 #include "AudioDial.h" | 18 #include "AudioDial.h" |
| 19 | 19 |
| 20 #include "plugin/PluginXml.h" | |
| 21 | |
| 20 #include <QDoubleSpinBox> | 22 #include <QDoubleSpinBox> |
| 21 #include <QGridLayout> | 23 #include <QGridLayout> |
| 22 #include <QComboBox> | 24 #include <QComboBox> |
| 23 #include <QCheckBox> | 25 #include <QCheckBox> |
| 24 #include <QLayout> | 26 #include <QLayout> |
| 25 #include <QLabel> | 27 #include <QLabel> |
| 26 | 28 |
| 27 #include <iostream> | 29 #include <iostream> |
| 28 #include <string> | 30 #include <string> |
| 29 | 31 |
| 30 PluginParameterBox::PluginParameterBox(PluginInstance *plugin, QWidget *parent) : | 32 PluginParameterBox::PluginParameterBox(Vamp::PluginBase *plugin, QWidget *parent) : |
| 31 QFrame(parent), | 33 QFrame(parent), |
| 32 m_plugin(plugin) | 34 m_plugin(plugin) |
| 33 { | 35 { |
| 34 m_layout = new QGridLayout; | 36 m_layout = new QGridLayout; |
| 35 setLayout(m_layout); | 37 setLayout(m_layout); |
| 41 } | 43 } |
| 42 | 44 |
| 43 void | 45 void |
| 44 PluginParameterBox::populate() | 46 PluginParameterBox::populate() |
| 45 { | 47 { |
| 46 PluginInstance::ParameterList params = m_plugin->getParameterDescriptors(); | 48 Vamp::PluginBase::ParameterList params = m_plugin->getParameterDescriptors(); |
| 47 PluginInstance::ProgramList programs = m_plugin->getPrograms(); | 49 Vamp::PluginBase::ProgramList programs = m_plugin->getPrograms(); |
| 48 | 50 |
| 49 m_params.clear(); | 51 m_params.clear(); |
| 50 | 52 |
| 51 if (params.empty() && programs.empty()) { | 53 if (params.empty() && programs.empty()) { |
| 52 m_layout->addWidget | 54 m_layout->addWidget |
| 168 if (m_params.find(name) == m_params.end()) { | 170 if (m_params.find(name) == m_params.end()) { |
| 169 std::cerr << "WARNING: PluginParameterBox::dialChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl; | 171 std::cerr << "WARNING: PluginParameterBox::dialChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl; |
| 170 return; | 172 return; |
| 171 } | 173 } |
| 172 | 174 |
| 173 PluginInstance::ParameterDescriptor params = m_params[name].param; | 175 Vamp::PluginBase::ParameterDescriptor params = m_params[name].param; |
| 174 | 176 |
| 175 float min = params.minValue; | 177 float min = params.minValue; |
| 176 float max = params.maxValue; | 178 float max = params.maxValue; |
| 177 | 179 |
| 178 float qtz = 0.0; | 180 float qtz = 0.0; |
| 191 spin->blockSignals(false); | 193 spin->blockSignals(false); |
| 192 } | 194 } |
| 193 | 195 |
| 194 m_plugin->setParameter(name.toStdString(), newValue); | 196 m_plugin->setParameter(name.toStdString(), newValue); |
| 195 | 197 |
| 196 emit pluginConfigurationChanged(m_plugin->toXmlString()); | 198 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); |
| 197 } | 199 } |
| 198 | 200 |
| 199 void | 201 void |
| 200 PluginParameterBox::checkBoxChanged(int state) | 202 PluginParameterBox::checkBoxChanged(int state) |
| 201 { | 203 { |
| 205 if (m_params.find(name) == m_params.end()) { | 207 if (m_params.find(name) == m_params.end()) { |
| 206 std::cerr << "WARNING: PluginParameterBox::checkBoxChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl; | 208 std::cerr << "WARNING: PluginParameterBox::checkBoxChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl; |
| 207 return; | 209 return; |
| 208 } | 210 } |
| 209 | 211 |
| 210 PluginInstance::ParameterDescriptor params = m_params[name].param; | 212 Vamp::PluginBase::ParameterDescriptor params = m_params[name].param; |
| 211 | 213 |
| 212 if (state) m_plugin->setParameter(name.toStdString(), 1.0); | 214 if (state) m_plugin->setParameter(name.toStdString(), 1.0); |
| 213 else m_plugin->setParameter(name.toStdString(), 0.0); | 215 else m_plugin->setParameter(name.toStdString(), 0.0); |
| 214 | 216 |
| 215 emit pluginConfigurationChanged(m_plugin->toXmlString()); | 217 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); |
| 216 } | 218 } |
| 217 | 219 |
| 218 void | 220 void |
| 219 PluginParameterBox::spinBoxChanged(double value) | 221 PluginParameterBox::spinBoxChanged(double value) |
| 220 { | 222 { |
| 224 if (m_params.find(name) == m_params.end()) { | 226 if (m_params.find(name) == m_params.end()) { |
| 225 std::cerr << "WARNING: PluginParameterBox::spinBoxChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl; | 227 std::cerr << "WARNING: PluginParameterBox::spinBoxChanged: Unknown parameter \"" << name.toStdString() << "\"" << std::endl; |
| 226 return; | 228 return; |
| 227 } | 229 } |
| 228 | 230 |
| 229 PluginInstance::ParameterDescriptor params = m_params[name].param; | 231 Vamp::PluginBase::ParameterDescriptor params = m_params[name].param; |
| 230 | 232 |
| 231 float min = params.minValue; | 233 float min = params.minValue; |
| 232 float max = params.maxValue; | 234 float max = params.maxValue; |
| 233 | 235 |
| 234 float qtz = 0.0; | 236 float qtz = 0.0; |
| 256 dial->blockSignals(false); | 258 dial->blockSignals(false); |
| 257 } | 259 } |
| 258 | 260 |
| 259 m_plugin->setParameter(name.toStdString(), value); | 261 m_plugin->setParameter(name.toStdString(), value); |
| 260 | 262 |
| 261 emit pluginConfigurationChanged(m_plugin->toXmlString()); | 263 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); |
| 262 } | 264 } |
| 263 | 265 |
| 264 void | 266 void |
| 265 PluginParameterBox::programComboChanged(const QString &newProgram) | 267 PluginParameterBox::programComboChanged(const QString &newProgram) |
| 266 { | 268 { |
| 267 m_plugin->selectProgram(newProgram.toStdString()); | 269 m_plugin->selectProgram(newProgram.toStdString()); |
| 268 | 270 |
| 269 for (std::map<QString, ParamRec>::iterator i = m_params.begin(); | 271 for (std::map<QString, ParamRec>::iterator i = m_params.begin(); |
| 270 i != m_params.end(); ++i) { | 272 i != m_params.end(); ++i) { |
| 271 | 273 |
| 272 PluginInstance::ParameterDescriptor ¶m = i->second.param; | 274 Vamp::PluginBase::ParameterDescriptor ¶m = i->second.param; |
| 273 float value = m_plugin->getParameter(param.name); | 275 float value = m_plugin->getParameter(param.name); |
| 274 | 276 |
| 275 if (i->second.spin) { | 277 if (i->second.spin) { |
| 276 i->second.spin->blockSignals(true); | 278 i->second.spin->blockSignals(true); |
| 277 i->second.spin->setValue(value); | 279 i->second.spin->setValue(value); |
| 294 i->second.dial->setValue(int((value - min) / qtz)); | 296 i->second.dial->setValue(int((value - min) / qtz)); |
| 295 i->second.dial->blockSignals(false); | 297 i->second.dial->blockSignals(false); |
| 296 } | 298 } |
| 297 } | 299 } |
| 298 | 300 |
| 299 emit pluginConfigurationChanged(m_plugin->toXmlString()); | 301 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); |
| 300 } | 302 } |
| 301 | 303 |
