changeset 74:195ad6178ef8

* Support latest changes to Vamp API (value names for parameters, FFT alignment, value -> bin terminology change)
author Chris Cannam
date Wed, 05 Apr 2006 16:52:30 +0000
parents ad1fe715b480
children dfdbf336bb37
files widgets/PluginParameterBox.cpp widgets/PluginParameterBox.h
diffstat 2 files changed, 30 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/widgets/PluginParameterBox.cpp	Mon Apr 03 17:18:27 2006 +0000
+++ b/widgets/PluginParameterBox.cpp	Wed Apr 05 16:52:30 2006 +0000
@@ -95,6 +95,8 @@
         float qtz = 0.0;
         if (params[i].isQuantized) qtz = params[i].quantizeStep;
 
+        std::vector<std::string> valueNames = params[i].valueNames;
+
         // construct an integer range
 
         int imin = 0, imax = 100;
@@ -116,8 +118,24 @@
         rec.dial = 0;
         rec.spin = 0;
         rec.check = 0;
+        rec.combo = 0;
         
-        if (min == 0.0 && max == 1.0 && qtz == 1.0) {
+        if (params[i].isQuantized && !valueNames.empty()) {
+            
+            QComboBox *combobox = new QComboBox;
+            combobox->setObjectName(name);
+            for (unsigned int j = 0; j < valueNames.size(); ++j) {
+                combobox->addItem(valueNames[j].c_str());
+                if (lrintf((value - min) / qtz) == j) {
+                    combobox->setCurrentIndex(j);
+                }
+            }
+            connect(combobox, SIGNAL(activated(int)),
+                    this, SLOT(dialChanged(int)));
+            m_layout->addWidget(combobox, i + offset, 1, 1, 2);
+            rec.combo = combobox;
+
+        } else if (min == 0.0 && max == 1.0 && qtz == 1.0) {
             
             QCheckBox *checkbox = new QCheckBox;
             checkbox->setObjectName(name);
@@ -135,8 +153,8 @@
             dial->setMaximum(imax);
             dial->setPageStep(1);
             dial->setNotchesVisible((imax - imin) <= 12);
-            dial->setDefaultValue(int((deft - min) / qtz));
-            dial->setValue(int((value - min) / qtz));
+            dial->setDefaultValue(lrintf((deft - min) / qtz));
+            dial->setValue(lrintf((value - min) / qtz));
             dial->setFixedWidth(32);
             dial->setFixedHeight(32);
             connect(dial, SIGNAL(valueChanged(int)),
@@ -293,9 +311,15 @@
             }
 
             i->second.dial->blockSignals(true);
-            i->second.dial->setValue(int((value - min) / qtz));
+            i->second.dial->setValue(lrintf((value - min) / qtz));
             i->second.dial->blockSignals(false);
         }
+
+        if (i->second.combo) {
+            i->second.combo->blockSignals(true);
+            i->second.combo->setCurrentIndex(value);
+            i->second.combo->blockSignals(false);
+        }
     }
 
     emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString());
--- a/widgets/PluginParameterBox.h	Mon Apr 03 17:18:27 2006 +0000
+++ b/widgets/PluginParameterBox.h	Wed Apr 05 16:52:30 2006 +0000
@@ -25,6 +25,7 @@
 class QDoubleSpinBox;
 class QCheckBox;
 class QGridLayout;
+class QComboBox;
 
 class PluginParameterBox : public QFrame
 {
@@ -55,6 +56,7 @@
         AudioDial *dial;
         QDoubleSpinBox *spin;
         QCheckBox *check;
+        QComboBox *combo;
         Vamp::PluginBase::ParameterDescriptor param;
     };