From b9fc97171821e6faf488d1593d155f3e711051c8 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Wed, 23 Jul 2014 00:08:54 +0300 Subject: [PATCH 01/36] Move slotValueChanged from the base class to its children --- src/effects/effectbuttonparameterslot.cpp | 7 +++++++ src/effects/effectbuttonparameterslot.h | 1 + src/effects/effectparameterslot.cpp | 6 ++++++ src/effects/effectparameterslot.h | 1 + src/effects/effectparameterslotbase.cpp | 7 ------- src/effects/effectparameterslotbase.h | 1 - 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/effects/effectbuttonparameterslot.cpp b/src/effects/effectbuttonparameterslot.cpp index 56c5b44b907..32f7c38bb65 100644 --- a/src/effects/effectbuttonparameterslot.cpp +++ b/src/effects/effectbuttonparameterslot.cpp @@ -130,3 +130,10 @@ void EffectButtonParameterSlot::onChainParameterChanged(double parameter) { } } } + +void EffectButtonParameterSlot::slotValueChanged(double v) { + if (m_pEffectParameter) { + // Call setValue with type 11 (SET_PARAMETER_BUTTON_PARAMETERS) + m_pEffectParameter->setValue(v, 11); + } +} diff --git a/src/effects/effectbuttonparameterslot.h b/src/effects/effectbuttonparameterslot.h index 258a6017e4c..25f811fb674 100644 --- a/src/effects/effectbuttonparameterslot.h +++ b/src/effects/effectbuttonparameterslot.h @@ -37,6 +37,7 @@ class EffectButtonParameterSlot : public EffectParameterSlotBase { private slots: // Solely for handling control changes void slotParameterValueChanged(QVariant value); + void slotValueChanged(double v); private: QString debugString() const { diff --git a/src/effects/effectparameterslot.cpp b/src/effects/effectparameterslot.cpp index 9c50700b2b9..6cfce5bbb6a 100644 --- a/src/effects/effectparameterslot.cpp +++ b/src/effects/effectparameterslot.cpp @@ -131,3 +131,9 @@ void EffectParameterSlot::onChainParameterChanged(double parameter) { } } } + +void EffectParameterSlot::slotValueChanged(double v) { + if (m_pEffectParameter) { + m_pEffectParameter->setValue(v); + } +} diff --git a/src/effects/effectparameterslot.h b/src/effects/effectparameterslot.h index 033fbce4657..5db22721ee6 100644 --- a/src/effects/effectparameterslot.h +++ b/src/effects/effectparameterslot.h @@ -38,6 +38,7 @@ class EffectParameterSlot : public EffectParameterSlotBase { private slots: // Solely for handling control changes void slotParameterValueChanged(QVariant value); + void slotValueChanged(double v); private: QString debugString() const { diff --git a/src/effects/effectparameterslotbase.cpp b/src/effects/effectparameterslotbase.cpp index 68664b6ff79..c68123aa719 100644 --- a/src/effects/effectparameterslotbase.cpp +++ b/src/effects/effectparameterslotbase.cpp @@ -57,13 +57,6 @@ void EffectParameterSlotBase::slotLinkType(double v) { } } -void EffectParameterSlotBase::slotValueChanged(double v) { - //qDebug() << debugString() << "slotValueChanged" << v; - if (m_pEffectParameter) { - m_pEffectParameter->setValue(v); - } -} - void EffectParameterSlotBase::slotValueType(double v) { Q_UNUSED(v); //qDebug() << debugString() << "slotValueType" << v; diff --git a/src/effects/effectparameterslotbase.h b/src/effects/effectparameterslotbase.h index f729f36439e..5aacb63eb1e 100644 --- a/src/effects/effectparameterslotbase.h +++ b/src/effects/effectparameterslotbase.h @@ -44,7 +44,6 @@ class EffectParameterSlotBase : public QObject { // Solely for handling control changes void slotLoaded(double v); void slotLinkType(double v); - void slotValueChanged(double v); void slotValueType(double v); protected: From 302f536deedc37440ac5420d6440710070923444 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Wed, 23 Jul 2014 00:09:55 +0300 Subject: [PATCH 02/36] Add Kill buttons to ButterworthEQ --- src/effects/native/butterworth8eqeffect.cpp | 51 +++++++++++++++++++-- src/effects/native/butterworth8eqeffect.h | 4 ++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/effects/native/butterworth8eqeffect.cpp b/src/effects/native/butterworth8eqeffect.cpp index d6d62102753..753072f933c 100644 --- a/src/effects/native/butterworth8eqeffect.cpp +++ b/src/effects/native/butterworth8eqeffect.cpp @@ -29,6 +29,18 @@ EffectManifest Butterworth8EQEffect::getManifest() { low->setMinimum(0); low->setMaximum(4.0); + EffectManifestParameter* killLow = manifest.addButtonParameter(); + killLow->setId("killLow"); + killLow->setName(QObject::tr("Kill Low")); + killLow->setDescription(QObject::tr("Kill the Low Filter")); + killLow->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killLow->setValueHint(EffectManifestParameter::VALUE_INTEGRAL); + killLow->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); + killLow->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); + killLow->setDefault(0); + killLow->setMinimum(0); + killLow->setMaximum(1); + EffectManifestParameter* mid = manifest.addParameter(); mid->setId("mid"); mid->setName(QObject::tr("Mid")); @@ -41,6 +53,18 @@ EffectManifest Butterworth8EQEffect::getManifest() { mid->setMinimum(0); mid->setMaximum(4.0); + EffectManifestParameter* killMid = manifest.addButtonParameter(); + killMid->setId("killMid"); + killMid->setName(QObject::tr("Kill Mid")); + killMid->setDescription(QObject::tr("Kill the Mid Filter")); + killMid->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killMid->setValueHint(EffectManifestParameter::VALUE_INTEGRAL); + killMid->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); + killMid->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); + killMid->setDefault(0); + killMid->setMinimum(0); + killMid->setMaximum(1); + EffectManifestParameter* high = manifest.addParameter(); high->setId("high"); high->setName(QObject::tr("High")); @@ -53,6 +77,18 @@ EffectManifest Butterworth8EQEffect::getManifest() { high->setMinimum(0); high->setMaximum(4.0); + EffectManifestParameter* killHigh = manifest.addButtonParameter(); + killHigh->setId("killHigh"); + killHigh->setName(QObject::tr("Kill High")); + killHigh->setDescription(QObject::tr("Kill the High Filter")); + killHigh->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killHigh->setValueHint(EffectManifestParameter::VALUE_INTEGRAL); + killHigh->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); + killHigh->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); + killHigh->setDefault(0); + killHigh->setMinimum(0); + killHigh->setMaximum(1); + return manifest; } @@ -91,6 +127,9 @@ Butterworth8EQEffect::Butterworth8EQEffect(EngineEffect* pEffect, : m_pPotLow(pEffect->getParameterById("low")), m_pPotMid(pEffect->getParameterById("mid")), m_pPotHigh(pEffect->getParameterById("high")), + m_pKillLow(pEffect->getButtonParameterById("killLow")), + m_pKillMid(pEffect->getButtonParameterById("killMid")), + m_pKillHigh(pEffect->getButtonParameterById("killHigh")), m_oldSampleRate(0), m_loFreq(0), m_hiFreq(0) { Q_UNUSED(manifest); m_pLoFreqCorner = new ControlObjectSlave("[Mixer Profile]", "LoEQFrequency"); @@ -111,9 +150,15 @@ void Butterworth8EQEffect::processGroup(const QString& group, Q_UNUSED(groupFeatures); float fLow = 0.f, fMid = 0.f, fHigh = 0.f; - fLow = m_pPotLow->value().toDouble(); - fMid = m_pPotMid->value().toDouble(); - fHigh = m_pPotHigh->value().toDouble(); + if (m_pKillLow->value().toInt() == 0) { + fLow = m_pPotLow->value().toDouble(); + } + if (m_pKillMid->value().toInt() == 0) { + fMid = m_pPotMid->value().toDouble(); + } + if (m_pKillHigh->value().toInt() == 0) { + fHigh = m_pPotHigh->value().toDouble(); + } int sampleRate = getSampleRate(); if (m_oldSampleRate != sampleRate || diff --git a/src/effects/native/butterworth8eqeffect.h b/src/effects/native/butterworth8eqeffect.h index f4081778e55..4129729e44c 100644 --- a/src/effects/native/butterworth8eqeffect.h +++ b/src/effects/native/butterworth8eqeffect.h @@ -58,6 +58,10 @@ class Butterworth8EQEffect : public GroupEffectProcessor Date: Mon, 6 Oct 2014 21:29:31 +0200 Subject: [PATCH 03/36] Removed valueHint from effect parameter and turn all values form QVariant into double --- src/effects/effect.cpp | 6 +- src/effects/effectbuttonparameterslot.cpp | 16 +- src/effects/effectbuttonparameterslot.h | 2 +- src/effects/effectmanifestparameter.h | 48 +-- src/effects/effectparameter.cpp | 364 ++++---------------- src/effects/effectparameter.h | 31 +- src/effects/effectparameterslot.cpp | 16 +- src/effects/effectparameterslot.h | 2 +- src/effects/native/bessel4lvmixeqeffect.cpp | 9 +- src/effects/native/bessel8lvmixeqeffect.cpp | 9 +- src/effects/native/bitcrushereffect.cpp | 6 +- src/effects/native/butterworth8eqeffect.cpp | 9 +- src/effects/native/echoeffect.cpp | 16 +- src/effects/native/filtereffect.cpp | 12 +- src/effects/native/flangereffect.cpp | 9 +- src/effects/native/graphiceqeffect.cpp | 9 +- src/effects/native/reverbeffect.cpp | 8 +- src/engine/effects/engineeffectparameter.h | 36 +- src/engine/effects/message.h | 8 +- 19 files changed, 163 insertions(+), 453 deletions(-) diff --git a/src/effects/effect.cpp b/src/effects/effect.cpp index ba7c514efed..457c4cef821 100644 --- a/src/effects/effect.cpp +++ b/src/effects/effect.cpp @@ -183,8 +183,7 @@ QDomElement Effect::toXML(QDomDocument* doc) const { QDomElement parameter = doc->createElement("Parameter"); XmlParse::addElement(*doc, parameter, "Id", parameterManifest.id()); // TODO(rryan): Do smarter QVariant formatting? - XmlParse::addElement(*doc, parameter, "Value", - pParameter->getValue().toString()); + XmlParse::addElement(*doc, parameter, "Value", QString::number(pParameter->getValue())); // TODO(rryan): Output link state, etc. parameters.appendChild(parameter); } @@ -197,8 +196,7 @@ QDomElement Effect::toXML(QDomDocument* doc) const { QDomElement parameter = doc->createElement("ButtonParameter"); XmlParse::addElement(*doc, parameter, "Id", parameterManifest.id()); // TODO(rryan): Do smarter QVariant formatting? - XmlParse::addElement(*doc, parameter, "Value", - pParameter->getValue().toString()); + XmlParse::addElement(*doc, parameter, "Value", QString::number(pParameter->getValue())); // TODO(rryan): Output link state, etc. buttonParameters.appendChild(parameter); } diff --git a/src/effects/effectbuttonparameterslot.cpp b/src/effects/effectbuttonparameterslot.cpp index 56c5b44b907..d218e5d59af 100644 --- a/src/effects/effectbuttonparameterslot.cpp +++ b/src/effects/effectbuttonparameterslot.cpp @@ -53,12 +53,12 @@ void EffectButtonParameterSlot::loadEffect(EffectPointer pEffect) { if (m_pEffectParameter) { //qDebug() << debugString() << "Loading effect parameter" << m_pEffectParameter->name(); - double dValue = m_pEffectParameter->getValue().toDouble(); - double dMinimum = m_pEffectParameter->getMinimum().toDouble(); + double dValue = m_pEffectParameter->getValue(); + double dMinimum = m_pEffectParameter->getMinimum(); double dMinimumLimit = dMinimum; // TODO(rryan) expose limit from EffectParameter - double dMaximum = m_pEffectParameter->getMaximum().toDouble(); + double dMaximum = m_pEffectParameter->getMaximum(); double dMaximumLimit = dMaximum; // TODO(rryan) expose limit from EffectParameter - double dDefault = m_pEffectParameter->getDefault().toDouble(); + double dDefault = m_pEffectParameter->getDefault(); if (dValue > dMaximum || dValue < dMinimum || dMinimum < dMinimumLimit || dMaximum > dMaximumLimit || @@ -79,8 +79,8 @@ void EffectButtonParameterSlot::loadEffect(EffectPointer pEffect) { m_pControlLoaded->setAndConfirm(1.0); m_pControlLinkType->set(m_pEffectParameter->getLinkType()); - connect(m_pEffectParameter, SIGNAL(valueChanged(QVariant)), - this, SLOT(slotParameterValueChanged(QVariant))); + connect(m_pEffectParameter, SIGNAL(valueChanged(double)), + this, SLOT(slotParameterValueChanged(double))); } // Update the newly loaded parameter to match the current chain @@ -106,9 +106,9 @@ void EffectButtonParameterSlot::clear() { emit(updated()); } -void EffectButtonParameterSlot::slotParameterValueChanged(QVariant value) { +void EffectButtonParameterSlot::slotParameterValueChanged(double value) { //qDebug() << debugString() << "slotParameterValueChanged" << value.toDouble(); - m_pControlValue->set(value.toDouble()); + m_pControlValue->set(value); } void EffectButtonParameterSlot::onChainParameterChanged(double parameter) { diff --git a/src/effects/effectbuttonparameterslot.h b/src/effects/effectbuttonparameterslot.h index 258a6017e4c..f37a3834e02 100644 --- a/src/effects/effectbuttonparameterslot.h +++ b/src/effects/effectbuttonparameterslot.h @@ -36,7 +36,7 @@ class EffectButtonParameterSlot : public EffectParameterSlotBase { private slots: // Solely for handling control changes - void slotParameterValueChanged(QVariant value); + void slotParameterValueChanged(double value); private: QString debugString() const { diff --git a/src/effects/effectmanifestparameter.h b/src/effects/effectmanifestparameter.h index 5b6a560cfc8..5f460e14b4c 100644 --- a/src/effects/effectmanifestparameter.h +++ b/src/effects/effectmanifestparameter.h @@ -7,13 +7,6 @@ class EffectManifestParameter { public: - enum ValueHint { - VALUE_UNKNOWN = 0, - VALUE_BOOLEAN, - VALUE_INTEGRAL, - VALUE_FLOAT - }; - enum ControlHint { CONTROL_UNKNOWN = 0, CONTROL_KNOB_LINEAR, @@ -44,10 +37,12 @@ class EffectManifestParameter { EffectManifestParameter() : m_controlHint(CONTROL_UNKNOWN), - m_valueHint(VALUE_UNKNOWN), m_semanticHint(SEMANTIC_UNKNOWN), m_unitsHint(UNITS_UNKNOWN), - m_linkHint(LINK_NONE) { + m_linkHint(LINK_NONE), + m_default(0), + m_minimum(0), + m_maximum(1.0) { } virtual ~EffectManifestParameter() { @@ -90,13 +85,6 @@ class EffectManifestParameter { m_controlHint = controlHint; } - virtual ValueHint valueHint() const { - return m_valueHint; - } - virtual void setValueHint(ValueHint valueHint) { - m_valueHint = valueHint; - } - virtual SemanticHint semanticHint() const { return m_semanticHint; } @@ -122,33 +110,24 @@ class EffectManifestParameter { // Value Settings //////////////////////////////////////////////////////////////////////////////// - virtual bool hasDefault() const { - return m_default.isValid(); - } - virtual const QVariant& getDefault() const { + virtual const double& getDefault() const { return m_default; } - virtual void setDefault(const QVariant& defaultValue) { + virtual void setDefault(const double& defaultValue) { m_default = defaultValue; } - virtual bool hasMinimum() const { - return m_minimum.isValid(); - } - virtual const QVariant& getMinimum() const { + virtual const double& getMinimum() const { return m_minimum; } - virtual void setMinimum(const QVariant& minimum) { + virtual void setMinimum(const double& minimum) { m_minimum = minimum; } - virtual bool hasMaximum() const { - return m_maximum.isValid(); - } - virtual const QVariant& getMaximum() const { + virtual const double& getMaximum() const { return m_maximum; } - virtual void setMaximum(const QVariant& maximum) { + virtual void setMaximum(const double& maximum) { m_maximum = maximum; } @@ -162,14 +141,13 @@ class EffectManifestParameter { QString m_description; ControlHint m_controlHint; - ValueHint m_valueHint; SemanticHint m_semanticHint; UnitsHint m_unitsHint; LinkType m_linkHint; - QVariant m_default; - QVariant m_minimum; - QVariant m_maximum; + double m_default; + double m_minimum; + double m_maximum; }; QDebug operator<<(QDebug dbg, const EffectManifestParameter& parameter); diff --git a/src/effects/effectparameter.cpp b/src/effects/effectparameter.cpp index 4c0418b4117..83efaa681c0 100644 --- a/src/effects/effectparameter.cpp +++ b/src/effects/effectparameter.cpp @@ -15,76 +15,24 @@ EffectParameter::EffectParameter(Effect* pEffect, EffectsManager* pEffectsManage m_bAddedToEngine(false) { // qDebug() << debugString() << "Constructing new EffectParameter from EffectManifestParameter:" // << m_parameter.id(); - switch (m_parameter.valueHint()) { - case EffectManifestParameter::VALUE_BOOLEAN: - // Minimum and maximum are undefined for a boolean. - m_minimum = QVariant(); - m_maximum = QVariant(); - if (m_parameter.hasDefault() && m_parameter.getDefault().canConvert()) { - m_default = m_parameter.getDefault(); - } else { - // Default to false if no default is given. - m_default = QVariant(false); - } - m_value = m_default; - break; - case EffectManifestParameter::VALUE_INTEGRAL: - m_minimum = m_parameter.hasMinimum() && m_parameter.getMinimum().canConvert() ? - m_parameter.getMinimum() : QVariant(0); - m_maximum = m_parameter.hasMaximum() && m_parameter.getMinimum().canConvert() ? - m_parameter.getMaximum() : QVariant(1); - - // Sanity check the maximum and minimum - if (clampRanges()) { - qWarning() << debugString() << "WARNING: Parameter maximum is less than the minimum."; - } - - // If the parameter specifies a default, set that. Otherwise use the minimum - // value. - if (m_parameter.hasDefault() && m_parameter.getDefault().canConvert()) { - m_default = m_parameter.getDefault(); - if (m_default.toInt() < m_minimum.toInt() || m_default.toInt() > m_maximum.toInt()) { - qWarning() << debugString() << "WARNING: Parameter default is outside of minimum/maximum range."; - m_default = m_minimum; - } - } else { - m_default = m_minimum; - } - - // Finally, set the value to the default. - m_value = m_default; - break; - case EffectManifestParameter::VALUE_UNKNOWN: // Treat unknown like float - case EffectManifestParameter::VALUE_FLOAT: - m_minimum = m_parameter.hasMinimum() && m_parameter.getMinimum().canConvert() ? - m_parameter.getMinimum() : QVariant(0.0f); - m_maximum = m_parameter.hasMaximum() && m_parameter.getMinimum().canConvert() ? - m_parameter.getMaximum() : QVariant(1.0f); - // Sanity check the maximum and minimum - if (m_minimum.toDouble() > m_maximum.toDouble()) { - qWarning() << debugString() << "WARNING: Parameter maximum is less than the minimum."; - m_maximum = m_minimum; - } - - // If the parameter specifies a default, set that. Otherwise use the minimum - // value. - if (m_parameter.hasDefault() && m_parameter.getDefault().canConvert()) { - m_default = m_parameter.getDefault(); - if (m_default.toDouble() < m_minimum.toDouble() || m_default.toDouble() > m_maximum.toDouble()) { - qWarning() << debugString() << "WARNING: Parameter default is outside of minimum/maximum range."; - m_default = m_minimum; - } - } else { - m_default = m_minimum; - } - - // Finally, set the value to the default. - m_value = m_default; - break; - default: - qWarning() << debugString() << "ERROR: Unhandled valueHint"; - break; - } + m_minimum = m_parameter.getMinimum(); + m_maximum = m_parameter.getMaximum(); + // Sanity check the maximum and minimum + if (m_minimum > m_maximum) { + qWarning() << debugString() << "WARNING: Parameter maximum is less than the minimum."; + m_maximum = m_minimum; + } + + // If the parameter specifies a default, set that. Otherwise use the minimum + // value. + m_default = m_parameter.getDefault(); + if (m_default < m_minimum || m_default > m_maximum) { + qWarning() << debugString() << "WARNING: Parameter default is outside of minimum/maximum range."; + m_default = m_minimum; + } + + // Finally, set the value to the default. + m_value = m_default; } EffectParameter::~EffectParameter() { @@ -108,81 +56,30 @@ const QString EffectParameter::description() const { } // static -bool EffectParameter::clampValue(EffectManifestParameter::ValueHint valueHint, QVariant& value, - const QVariant& minimum, const QVariant& maximum) { - switch (valueHint) { - case EffectManifestParameter::VALUE_BOOLEAN: - break; - case EffectManifestParameter::VALUE_INTEGRAL: - if (value.toInt() < minimum.toInt()) { - value = minimum; - return true; - } else if (value.toInt() > maximum.toInt()) { - value = maximum; - return true; - } - break; - case EffectManifestParameter::VALUE_FLOAT: - case EffectManifestParameter::VALUE_UNKNOWN: - if (value.toDouble() < minimum.toDouble()) { - value = minimum; - return true; - } else if (value.toDouble() > maximum.toDouble()) { - value = maximum; - return true; - } - break; - default: - qWarning() << "ERROR: Unhandled valueHint"; - break; +bool EffectParameter::clampValue(double* pValue, + const double& minimum, const double& maximum) { + if (*pValue < minimum) { + *pValue = minimum; + return true; + } else if (*pValue > maximum) { + *pValue = maximum; + return true; } return false; } bool EffectParameter::clampValue() { - return clampValue(m_parameter.valueHint(), m_value, m_minimum, m_maximum); + return clampValue(&m_value, m_minimum, m_maximum); } bool EffectParameter::clampDefault() { - return clampValue(m_parameter.valueHint(), m_default, m_minimum, m_maximum); -} - -bool EffectParameter::checkType(const QVariant& value) const { - switch (m_parameter.valueHint()) { - case EffectManifestParameter::VALUE_BOOLEAN: - return value.canConvert(); - case EffectManifestParameter::VALUE_INTEGRAL: - return value.canConvert(); - case EffectManifestParameter::VALUE_FLOAT: - case EffectManifestParameter::VALUE_UNKNOWN: - return value.canConvert(); - default: - qWarning() << debugString() << "ERROR: Unhandled valueHint"; - break; - } - return false; + return clampValue(&m_default, m_minimum, m_maximum); } bool EffectParameter::clampRanges() { - switch (m_parameter.valueHint()) { - case EffectManifestParameter::VALUE_BOOLEAN: - break; - case EffectManifestParameter::VALUE_INTEGRAL: - if (m_minimum.toInt() > m_maximum.toInt()) { - m_maximum = m_minimum; - return true; - } - break; - case EffectManifestParameter::VALUE_FLOAT: - case EffectManifestParameter::VALUE_UNKNOWN: - if (m_minimum.toDouble() > m_maximum.toDouble()) { - m_maximum = m_minimum; - return true; - } - break; - default: - qWarning() << debugString() << "ERROR: Unhandled valueHint"; - break; + if (m_minimum > m_maximum) { + m_maximum = m_minimum; + return true; } return false; } @@ -196,32 +93,13 @@ void EffectParameter::setLinkType(EffectManifestParameter::LinkType linkType) { // TODO(rryan) update value based on link type. } -QVariant EffectParameter::getValue() const { +double EffectParameter::getValue() const { return m_value; } -void EffectParameter::setValue(QVariant value, int type) { - if (!checkType(value)) { - qWarning() << debugString() << "WARNING: Value cannot be converted to suitable value, ignoring."; - return; - } - - switch (m_parameter.valueHint()) { - case EffectManifestParameter::VALUE_BOOLEAN: - m_value = value.toBool(); - break; - case EffectManifestParameter::VALUE_INTEGRAL: - m_value = value.toInt(); - break; - case EffectManifestParameter::VALUE_UNKNOWN: // treat unknown as float - case EffectManifestParameter::VALUE_FLOAT: - // TODO(XXX) Handle inf, -inf, and nan - m_value = value.toDouble(); - break; - default: - qWarning() << debugString() << "ERROR: Unhandled valueHint"; - break; - } +void EffectParameter::setValue(double value, int type) { + // TODO(XXX) Handle inf, -inf, and nan + m_value = value; if (clampValue()) { qWarning() << debugString() << "WARNING: Value was outside of limits, clamped."; @@ -230,31 +108,12 @@ void EffectParameter::setValue(QVariant value, int type) { emit(valueChanged(m_value)); } -QVariant EffectParameter::getDefault() const { +double EffectParameter::getDefault() const { return m_default; } -void EffectParameter::setDefault(QVariant dflt) { - if (!checkType(dflt)) { - qWarning() << debugString() << "WARNING: Value for default cannot be converted to suitable value, ignoring."; - return; - } - - switch (m_parameter.valueHint()) { - case EffectManifestParameter::VALUE_BOOLEAN: - m_default = dflt.toBool(); - break; - case EffectManifestParameter::VALUE_INTEGRAL: - m_default = dflt.toInt(); - break; - case EffectManifestParameter::VALUE_UNKNOWN: - case EffectManifestParameter::VALUE_FLOAT: - m_default = dflt.toDouble(); - break; - default: - qWarning() << debugString() << "ERROR: Unhandled valueHint"; - break; - } +void EffectParameter::setDefault(double dflt) { + m_default = dflt; if (clampDefault()) { qWarning() << debugString() << "WARNING: Default parameter value was outside of range, clamped."; @@ -263,70 +122,30 @@ void EffectParameter::setDefault(QVariant dflt) { updateEngineState(); } -QVariant EffectParameter::getMinimum() const { +double EffectParameter::getMinimum() const { return m_minimum; } -void EffectParameter::setMinimum(QVariant minimum) { - if (!checkType(minimum)) { - qWarning() << debugString() << "WARNING: Value for minimum cannot be converted to suitable value, ignoring."; - return; +void EffectParameter::setMinimum(double minimum) { + m_minimum = minimum; + + if (m_minimum < m_parameter.getMinimum()) { + qWarning() << debugString() << "WARNING: Minimum value is less than plugin's absolute minimum, clamping."; + m_minimum = m_parameter.getMinimum(); } - switch (m_parameter.valueHint()) { - case EffectManifestParameter::VALUE_BOOLEAN: - // Minimum doesn't apply to booleans - break; - case EffectManifestParameter::VALUE_INTEGRAL: - m_minimum = minimum.toInt(); - - if (m_parameter.hasMinimum() && m_minimum.toInt() < m_parameter.getMinimum().toInt()) { - qWarning() << debugString() << "WARNING: Minimum value is less than plugin's absolute minimum, clamping."; - m_minimum = m_parameter.getMinimum(); - } - - if (m_minimum.toInt() > m_maximum.toInt()) { - qWarning() << debugString() << "WARNING: New minimum was above maximum, clamped."; - m_minimum = m_maximum; - } - - // There's a degenerate case here where the maximum could be lower - // than the manifest minimum. If that's the case, then the minimum - // value is currently below the manifest minimum. Since similar - // guards exist in the setMaximum call, this should not be able to - // happen. - if (m_parameter.hasMinimum()) { - Q_ASSERT(m_minimum.toInt() >= m_parameter.getMinimum().toInt()); - } - break; - case EffectManifestParameter::VALUE_UNKNOWN: - case EffectManifestParameter::VALUE_FLOAT: - m_minimum = minimum.toDouble(); - - if (m_parameter.hasMinimum() && m_minimum.toDouble() < m_parameter.getMinimum().toDouble()) { - qWarning() << debugString() << "WARNING: Minimum value is less than plugin's absolute minimum, clamping."; - m_minimum = m_parameter.getMinimum(); - } - - if (m_minimum.toDouble() > m_maximum.toDouble()) { - qWarning() << debugString() << "WARNING: New minimum was above maximum, clamped."; - m_minimum = m_maximum; - } - - // There's a degenerate case here where the maximum could be lower - // than the manifest minimum. If that's the case, then the minimum - // value is currently below the manifest minimum. Since similar - // guards exist in the setMaximum call, this should not be able to - // happen. - if (m_parameter.hasMinimum()) { - Q_ASSERT(m_minimum.toDouble() >= m_parameter.getMinimum().toDouble()); - } - break; - default: - qWarning() << debugString() << "ERROR: Unhandled valueHint"; - break; + if (m_minimum > m_maximum) { + qWarning() << debugString() << "WARNING: New minimum was above maximum, clamped."; + m_minimum = m_maximum; } + // There's a degenerate case here where the maximum could be lower + // than the manifest minimum. If that's the case, then the minimum + // value is currently below the manifest minimum. Since similar + // guards exist in the setMaximum call, this should not be able to + // happen. + Q_ASSERT(m_minimum >= m_parameter.getMinimum()); + if (clampValue()) { qWarning() << debugString() << "WARNING: Value was outside of new minimum, clamped."; } @@ -338,70 +157,29 @@ void EffectParameter::setMinimum(QVariant minimum) { updateEngineState(); } -QVariant EffectParameter::getMaximum() const { +double EffectParameter::getMaximum() const { return m_maximum; } -void EffectParameter::setMaximum(QVariant maximum) { - if (!checkType(maximum)) { - qWarning() << debugString() << "WARNING: Value for maximum cannot be converted to suitable value, ignoring."; - return; +void EffectParameter::setMaximum(double maximum) { + m_maximum = maximum; + if (m_maximum > m_parameter.getMaximum()) { + qWarning() << debugString() << "WARNING: Maximum value is less than plugin's absolute maximum, clamping."; + m_maximum = m_parameter.getMaximum(); } - switch (m_parameter.valueHint()) { - case EffectManifestParameter::VALUE_BOOLEAN: - // Maximum doesn't apply to booleans - break; - case EffectManifestParameter::VALUE_INTEGRAL: - m_maximum = maximum.toInt(); - - if (m_parameter.hasMaximum() && m_maximum.toInt() > m_parameter.getMaximum().toInt()) { - qWarning() << debugString() << "WARNING: Maximum value is less than plugin's absolute maximum, clamping."; - m_maximum = m_parameter.getMaximum(); - } - - if (m_maximum.toInt() < m_minimum.toInt()) { - qWarning() << debugString() << "WARNING: New maximum was below the minimum, clamped."; - m_maximum = m_minimum; - } - - // There's a degenerate case here where the minimum could be larger - // than the manifest maximum. If that's the case, then the maximum - // value is currently above the manifest maximum. Since similar - // guards exist in the setMinimum call, this should not be able to - // happen. - if (m_parameter.hasMaximum()) { - Q_ASSERT(m_maximum.toInt() <= m_parameter.getMaximum().toInt()); - } - break; - case EffectManifestParameter::VALUE_UNKNOWN: - case EffectManifestParameter::VALUE_FLOAT: - m_maximum = maximum.toDouble(); - - if (m_parameter.hasMaximum() && m_maximum.toDouble() > m_parameter.getMaximum().toDouble()) { - qWarning() << debugString() << "WARNING: Maximum value is less than plugin's absolute maximum, clamping."; - m_maximum = m_parameter.getMaximum(); - } - - if (m_maximum.toDouble() < m_minimum.toDouble()) { - qWarning() << debugString() << "WARNING: New maximum was below the minimum, clamped."; - m_maximum = m_minimum; - } - - // There's a degenerate case here where the minimum could be larger - // than the manifest maximum. If that's the case, then the maximum - // value is currently above the manifest maximum. Since similar - // guards exist in the setMinimum call, this should not be able to - // happen. - if (m_parameter.hasMaximum()) { - Q_ASSERT(m_maximum.toDouble() <= m_parameter.getMaximum().toDouble()); - } - break; - default: - qWarning() << debugString() << "ERROR: Unhandled valueHint"; - break; + if (m_maximum < m_minimum) { + qWarning() << debugString() << "WARNING: New maximum was below the minimum, clamped."; + m_maximum = m_minimum; } + // There's a degenerate case here where the minimum could be larger + // than the manifest maximum. If that's the case, then the maximum + // value is currently above the manifest maximum. Since similar + // guards exist in the setMinimum call, this should not be able to + // happen. + Q_ASSERT(m_maximum <= m_parameter.getMaximum()); + if (clampValue()) { qWarning() << debugString() << "WARNING: Value was outside of new maximum, clamped."; } diff --git a/src/effects/effectparameter.h b/src/effects/effectparameter.h index c35acf06d8f..655653db004 100644 --- a/src/effects/effectparameter.h +++ b/src/effects/effectparameter.h @@ -41,18 +41,18 @@ class EffectParameter : public QObject { EffectManifestParameter::LinkType getLinkType() const; void setLinkType(EffectManifestParameter::LinkType linkType); - QVariant getValue() const; + double getValue() const; // Default type is EffectsRequest::SET_PARAMETER_PARAMETERS - void setValue(QVariant value, int type = 10); + void setValue(double value, int type = 10); - QVariant getDefault() const; - void setDefault(QVariant defaultValue); + double getDefault() const; + void setDefault(double defaultValue); - QVariant getMinimum() const; - void setMinimum(QVariant minimum); + double getMinimum() const; + void setMinimum(double minimum); - QVariant getMaximum() const; - void setMaximum(QVariant maximum); + double getMaximum() const; + void setMaximum(double maximum); EffectManifestParameter::ControlHint getControlHint() const; @@ -60,29 +60,28 @@ class EffectParameter : public QObject { void updateEngineState(int type = 10); signals: - void valueChanged(QVariant value); + void valueChanged(double value); private: QString debugString() const { return QString("EffectParameter(%1)").arg(m_parameter.name()); } - static bool clampValue(EffectManifestParameter::ValueHint valueHint, QVariant& value, - const QVariant& minimum, const QVariant& maximum); + static bool clampValue(double* pValue, + const double& minimum, const double& maximum); bool clampValue(); bool clampDefault(); bool clampRanges(); - bool checkType(const QVariant& value) const; Effect* m_pEffect; EffectsManager* m_pEffectsManager; int m_iParameterNumber; EffectManifestParameter m_parameter; EffectManifestParameter::LinkType m_linkType; - QVariant m_minimum; - QVariant m_maximum; - QVariant m_default; - QVariant m_value; + double m_minimum; + double m_maximum; + double m_default; + double m_value; bool m_bAddedToEngine; DISALLOW_COPY_AND_ASSIGN(EffectParameter); diff --git a/src/effects/effectparameterslot.cpp b/src/effects/effectparameterslot.cpp index ce399fc8794..25b6169f82c 100644 --- a/src/effects/effectparameterslot.cpp +++ b/src/effects/effectparameterslot.cpp @@ -56,12 +56,12 @@ void EffectParameterSlot::loadEffect(EffectPointer pEffect) { if (m_pEffectParameter) { //qDebug() << debugString() << "Loading effect parameter" << m_pEffectParameter->name(); - double dValue = m_pEffectParameter->getValue().toDouble(); - double dMinimum = m_pEffectParameter->getMinimum().toDouble(); + double dValue = m_pEffectParameter->getValue(); + double dMinimum = m_pEffectParameter->getMinimum(); double dMinimumLimit = dMinimum; // TODO(rryan) expose limit from EffectParameter - double dMaximum = m_pEffectParameter->getMaximum().toDouble(); + double dMaximum = m_pEffectParameter->getMaximum(); double dMaximumLimit = dMaximum; // TODO(rryan) expose limit from EffectParameter - double dDefault = m_pEffectParameter->getDefault().toDouble(); + double dDefault = m_pEffectParameter->getDefault(); if (dValue > dMaximum || dValue < dMinimum || dMinimum < dMinimumLimit || dMaximum > dMaximumLimit || @@ -83,8 +83,8 @@ void EffectParameterSlot::loadEffect(EffectPointer pEffect) { m_pControlLoaded->setAndConfirm(1.0); m_pControlLinkType->set(m_pEffectParameter->getLinkType()); - connect(m_pEffectParameter, SIGNAL(valueChanged(QVariant)), - this, SLOT(slotParameterValueChanged(QVariant))); + connect(m_pEffectParameter, SIGNAL(valueChanged(double)), + this, SLOT(slotParameterValueChanged(double))); } } emit(updated()); @@ -113,9 +113,9 @@ EffectManifestParameter::LinkType EffectParameterSlot::getLinkType() const{ return EffectManifestParameter::LINK_NONE; } -void EffectParameterSlot::slotParameterValueChanged(QVariant value) { +void EffectParameterSlot::slotParameterValueChanged(double value) { //qDebug() << debugString() << "slotParameterValueChanged" << value.toDouble(); - m_pControlValue->set(value.toDouble()); + m_pControlValue->set(value); } void EffectParameterSlot::onChainParameterChanged(double parameter) { diff --git a/src/effects/effectparameterslot.h b/src/effects/effectparameterslot.h index 96a070501c2..e52f1071302 100644 --- a/src/effects/effectparameterslot.h +++ b/src/effects/effectparameterslot.h @@ -41,7 +41,7 @@ class EffectParameterSlot : public EffectParameterSlotBase { private slots: // Solely for handling control changes - void slotParameterValueChanged(QVariant value); + void slotParameterValueChanged(double value); private: QString debugString() const { diff --git a/src/effects/native/bessel4lvmixeqeffect.cpp b/src/effects/native/bessel4lvmixeqeffect.cpp index 5642c82b214..45aba22dd40 100644 --- a/src/effects/native/bessel4lvmixeqeffect.cpp +++ b/src/effects/native/bessel4lvmixeqeffect.cpp @@ -22,7 +22,6 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { low->setName(QObject::tr("Low")); low->setDescription(QObject::tr("Gain for Low Filter")); low->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - low->setValueHint(EffectManifestParameter::VALUE_FLOAT); low->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); low->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); low->setDefault(1.0); @@ -34,7 +33,6 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { mid->setName(QObject::tr("Mid")); mid->setDescription(QObject::tr("Gain for Band Filter")); mid->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - mid->setValueHint(EffectManifestParameter::VALUE_FLOAT); mid->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); mid->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); mid->setDefault(1.0); @@ -46,7 +44,6 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { high->setName(QObject::tr("High")); high->setDescription(QObject::tr("Gain for High Filter")); high->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - high->setValueHint(EffectManifestParameter::VALUE_FLOAT); high->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); high->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); high->setDefault(1.0); @@ -80,9 +77,9 @@ void Bessel4LVMixEQEffect::processGroup(const QString& group, Q_UNUSED(group); Q_UNUSED(groupFeatures); - double fLow = m_pPotLow->value().toDouble(); - double fMid = m_pPotMid->value().toDouble(); - double fHigh = m_pPotHigh->value().toDouble(); + double fLow = m_pPotLow->value(); + double fMid = m_pPotMid->value(); + double fHigh = m_pPotHigh->value(); if (pState->m_oldSampleRate != sampleRate || (pState->m_loFreq != m_pLoFreqCorner->get()) || diff --git a/src/effects/native/bessel8lvmixeqeffect.cpp b/src/effects/native/bessel8lvmixeqeffect.cpp index 2d34a193ce3..8c6241f7f87 100644 --- a/src/effects/native/bessel8lvmixeqeffect.cpp +++ b/src/effects/native/bessel8lvmixeqeffect.cpp @@ -29,7 +29,6 @@ EffectManifest Bessel8LVMixEQEffect::getManifest() { low->setName(QObject::tr("Low")); low->setDescription(QObject::tr("Gain for Low Filter")); low->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - low->setValueHint(EffectManifestParameter::VALUE_FLOAT); low->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); low->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); low->setDefault(1.0); @@ -41,7 +40,6 @@ EffectManifest Bessel8LVMixEQEffect::getManifest() { mid->setName(QObject::tr("Mid")); mid->setDescription(QObject::tr("Gain for Band Filter")); mid->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - mid->setValueHint(EffectManifestParameter::VALUE_FLOAT); mid->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); mid->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); mid->setDefault(1.0); @@ -53,7 +51,6 @@ EffectManifest Bessel8LVMixEQEffect::getManifest() { high->setName(QObject::tr("High")); high->setDescription(QObject::tr("Gain for High Filter")); high->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - high->setValueHint(EffectManifestParameter::VALUE_FLOAT); high->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); high->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); high->setDefault(1.0); @@ -87,9 +84,9 @@ void Bessel8LVMixEQEffect::processGroup(const QString& group, Q_UNUSED(group); Q_UNUSED(groupFeatures); - double fLow = m_pPotLow->value().toDouble(); - double fMid = m_pPotMid->value().toDouble(); - double fHigh = m_pPotHigh->value().toDouble(); + double fLow = m_pPotLow->value(); + double fMid = m_pPotMid->value(); + double fHigh = m_pPotHigh->value(); if (pState->m_oldSampleRate != sampleRate || (pState->m_loFreq != m_pLoFreqCorner->get()) || diff --git a/src/effects/native/bitcrushereffect.cpp b/src/effects/native/bitcrushereffect.cpp index 4c4c82ced33..1cf1d4fbe33 100644 --- a/src/effects/native/bitcrushereffect.cpp +++ b/src/effects/native/bitcrushereffect.cpp @@ -20,7 +20,6 @@ EffectManifest BitCrusherEffect::getManifest() { depth->setName(QObject::tr("Bit Depth")); depth->setDescription("TODO"); depth->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - depth->setValueHint(EffectManifestParameter::VALUE_FLOAT); depth->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); depth->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); depth->setLinkHint(EffectManifestParameter::LINK_INVERSE); @@ -35,7 +34,6 @@ EffectManifest BitCrusherEffect::getManifest() { frequency->setName(QObject::tr("Downsampling")); frequency->setDescription("TODO"); frequency->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - frequency->setValueHint(EffectManifestParameter::VALUE_FLOAT); frequency->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); frequency->setUnitsHint(EffectManifestParameter::UNITS_SAMPLERATE); frequency->setLinkHint(EffectManifestParameter::LINK_INVERSE); @@ -69,10 +67,10 @@ void BitCrusherEffect::processGroup(const QString& group, // TODO(rryan) this is broken. it needs to take into account the sample // rate. const CSAMPLE downsample = m_pDownsampleParameter ? - m_pDownsampleParameter->value().toDouble() : 0.0; + m_pDownsampleParameter->value() : 0.0; CSAMPLE bit_depth = m_pBitDepthParameter ? - m_pBitDepthParameter->value().toDouble() : 16; + m_pBitDepthParameter->value() : 16; // divided by two because we use float math which includes the sing bit anyway const CSAMPLE scale = pow(2.0f, bit_depth) / 2; diff --git a/src/effects/native/butterworth8eqeffect.cpp b/src/effects/native/butterworth8eqeffect.cpp index 7ff7dd5054f..9e803a5b9a5 100644 --- a/src/effects/native/butterworth8eqeffect.cpp +++ b/src/effects/native/butterworth8eqeffect.cpp @@ -22,7 +22,6 @@ EffectManifest Butterworth8EQEffect::getManifest() { low->setName(QObject::tr("Low")); low->setDescription(QObject::tr("Gain for Low Filter")); low->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - low->setValueHint(EffectManifestParameter::VALUE_FLOAT); low->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); low->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); low->setDefault(1.0); @@ -34,7 +33,6 @@ EffectManifest Butterworth8EQEffect::getManifest() { mid->setName(QObject::tr("Mid")); mid->setDescription(QObject::tr("Gain for Band Filter")); mid->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - mid->setValueHint(EffectManifestParameter::VALUE_FLOAT); mid->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); mid->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); mid->setDefault(1.0); @@ -46,7 +44,6 @@ EffectManifest Butterworth8EQEffect::getManifest() { high->setName(QObject::tr("High")); high->setDescription(QObject::tr("Gain for High Filter")); high->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - high->setValueHint(EffectManifestParameter::VALUE_FLOAT); high->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); high->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); high->setDefault(1.0); @@ -112,9 +109,9 @@ void Butterworth8EQEffect::processGroup(const QString& group, Q_UNUSED(groupFeatures); float fLow = 0.f, fMid = 0.f, fHigh = 0.f; - fLow = m_pPotLow->value().toDouble(); - fMid = m_pPotMid->value().toDouble(); - fHigh = m_pPotHigh->value().toDouble(); + fLow = m_pPotLow->value(); + fMid = m_pPotMid->value(); + fHigh = m_pPotHigh->value(); if (m_oldSampleRate != sampleRate || (m_loFreq != static_cast(m_pLoFreqCorner->get())) || diff --git a/src/effects/native/echoeffect.cpp b/src/effects/native/echoeffect.cpp index 30787486e91..50bc21e9877 100644 --- a/src/effects/native/echoeffect.cpp +++ b/src/effects/native/echoeffect.cpp @@ -27,7 +27,6 @@ EffectManifest EchoEffect::getManifest() { time->setDescription( QObject::tr("How much of the signal to send into the delay buffer")); time->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - time->setValueHint(EffectManifestParameter::VALUE_FLOAT); time->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); time->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); time->setMinimum(0.0); @@ -39,7 +38,6 @@ EffectManifest EchoEffect::getManifest() { time->setName(QObject::tr("Delay")); time->setDescription(QObject::tr("Delay time (seconds)")); time->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - time->setValueHint(EffectManifestParameter::VALUE_FLOAT); time->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); time->setUnitsHint(EffectManifestParameter::UNITS_TIME); time->setLinkHint(EffectManifestParameter::LINK_LINKED); @@ -53,7 +51,6 @@ EffectManifest EchoEffect::getManifest() { time->setDescription( QObject::tr("Amount the echo fades each time it loops")); time->setControlHint(EffectManifestParameter::CONTROL_KNOB_LOGARITHMIC); - time->setValueHint(EffectManifestParameter::VALUE_FLOAT); time->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); time->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); time->setMinimum(0.00); @@ -68,7 +65,6 @@ EffectManifest EchoEffect::getManifest() { "of the echoed signal is bounced between the left and " "right speakers.")); time->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - time->setValueHint(EffectManifestParameter::VALUE_FLOAT); time->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); time->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); time->setMinimum(0.0); @@ -110,14 +106,10 @@ void EchoEffect::processGroup(const QString& group, EchoGroupState* pGroupState, Q_UNUSED(group); Q_UNUSED(groupFeatures); EchoGroupState& gs = *pGroupState; - double delay_time = - m_pDelayParameter ? m_pDelayParameter->value().toDouble() : 1.0f; - double send_amount = - m_pSendParameter ? m_pSendParameter->value().toDouble() : 1.0f; - double feedback_amount = - m_pFeedbackParameter ? m_pFeedbackParameter->value().toDouble() : 0.25f; - double pingpong_frac = - m_pPingPongParameter ? m_pPingPongParameter->value().toDouble() : 0.25f; + double delay_time = m_pDelayParameter->value(); + double send_amount = m_pSendParameter->value(); + double feedback_amount = m_pFeedbackParameter->value(); + double pingpong_frac = m_pPingPongParameter->value(); // TODO(owilliams): get actual sample rate from somewhere. diff --git a/src/effects/native/filtereffect.cpp b/src/effects/native/filtereffect.cpp index b9b666ada21..d07b7ba432b 100644 --- a/src/effects/native/filtereffect.cpp +++ b/src/effects/native/filtereffect.cpp @@ -20,7 +20,6 @@ EffectManifest FilterEffect::getManifest() { depth->setName(QObject::tr("Depth")); depth->setDescription("TODO"); depth->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - depth->setValueHint(EffectManifestParameter::VALUE_FLOAT); depth->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); depth->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); depth->setLinkHint(EffectManifestParameter::LINK_LINKED); @@ -33,7 +32,6 @@ EffectManifest FilterEffect::getManifest() { bandpass_width->setName(QObject::tr("Bandpass Width")); bandpass_width->setDescription("TODO"); bandpass_width->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - bandpass_width->setValueHint(EffectManifestParameter::VALUE_FLOAT); bandpass_width->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); bandpass_width->setUnitsHint(EffectManifestParameter::UNITS_SAMPLERATE); bandpass_width->setDefault(0.01); @@ -45,7 +43,6 @@ EffectManifest FilterEffect::getManifest() { bandpass_gain->setName(QObject::tr("Bandpass Gain")); bandpass_gain->setDescription("TODO"); bandpass_gain->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - bandpass_gain->setValueHint(EffectManifestParameter::VALUE_FLOAT); bandpass_gain->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); bandpass_gain->setUnitsHint(EffectManifestParameter::UNITS_SAMPLERATE); bandpass_gain->setDefault(0.3); @@ -85,12 +82,9 @@ void FilterEffect::processGroup(const QString& group, const GroupFeatureState& groupFeatures) { Q_UNUSED(group); Q_UNUSED(groupFeatures); - double depth = m_pDepthParameter ? - m_pDepthParameter->value().toDouble() : 0.0; - double bandpass_width = m_pBandpassWidthParameter ? - m_pBandpassWidthParameter->value().toDouble() : 0.0; - CSAMPLE bandpass_gain = m_pBandpassGainParameter ? - m_pBandpassGainParameter->value().toFloat() : 0.0; + double depth = m_pDepthParameter->value(); + double bandpass_width = m_pBandpassWidthParameter->value(); + CSAMPLE bandpass_gain = m_pBandpassGainParameter->value(); // TODO(rryan) what if bandpass_gain changes? bool parametersChanged = depth != pState->oldDepth || diff --git a/src/effects/native/flangereffect.cpp b/src/effects/native/flangereffect.cpp index f4d126bec2d..88cfcf28570 100644 --- a/src/effects/native/flangereffect.cpp +++ b/src/effects/native/flangereffect.cpp @@ -28,7 +28,6 @@ EffectManifest FlangerEffect::getManifest() { depth->setName(QObject::tr("Depth")); depth->setDescription("TODO"); depth->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - depth->setValueHint(EffectManifestParameter::VALUE_FLOAT); depth->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); depth->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); depth->setDefault(0.0); @@ -40,7 +39,6 @@ EffectManifest FlangerEffect::getManifest() { delay->setName(QObject::tr("Delay")); delay->setDescription("TODO"); delay->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - delay->setValueHint(EffectManifestParameter::VALUE_FLOAT); delay->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); delay->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); delay->setDefault(50.0); @@ -52,7 +50,6 @@ EffectManifest FlangerEffect::getManifest() { period->setName(QObject::tr("Period")); period->setDescription("TODO"); period->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - period->setValueHint(EffectManifestParameter::VALUE_FLOAT); period->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); period->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); period->setDefault(50000.0); @@ -83,10 +80,8 @@ void FlangerEffect::processGroup(const QString& group, Q_UNUSED(group); Q_UNUSED(groupFeatures); Q_UNUSED(sampleRate); - CSAMPLE lfoPeriod = m_pPeriodParameter ? - m_pPeriodParameter->value().toDouble() : 0.0f; - CSAMPLE lfoDepth = m_pDepthParameter ? - m_pDepthParameter->value().toDouble() : 0.0f; + CSAMPLE lfoPeriod = m_pPeriodParameter->value(); + CSAMPLE lfoDepth = m_pDepthParameter->value(); // Unused in EngineFlanger // CSAMPLE lfoDelay = m_pDelayParameter ? // m_pDelayParameter->value().toDouble() : 0.0f; diff --git a/src/effects/native/graphiceqeffect.cpp b/src/effects/native/graphiceqeffect.cpp index 3b6dbb2f702..8fdc46f82ce 100644 --- a/src/effects/native/graphiceqeffect.cpp +++ b/src/effects/native/graphiceqeffect.cpp @@ -27,7 +27,6 @@ EffectManifest GraphicEQEffect::getManifest() { low->setName(QString("%1 Hz").arg(centerFrequencies[0])); low->setDescription(QString("Gain for Low Filter")); low->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - low->setValueHint(EffectManifestParameter::VALUE_FLOAT); low->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); low->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); low->setDefault(0); @@ -47,7 +46,6 @@ EffectManifest GraphicEQEffect::getManifest() { mid->setName(paramName); mid->setDescription(QString("Gain for Band Filter %1").arg(i)); mid->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - mid->setValueHint(EffectManifestParameter::VALUE_FLOAT); mid->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); mid->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); mid->setDefault(0); @@ -60,7 +58,6 @@ EffectManifest GraphicEQEffect::getManifest() { high->setName(QString("%1 kHz").arg(centerFrequencies[7] / 1000)); high->setDescription(QString("Gain for Hight Filter")); high->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - high->setValueHint(EffectManifestParameter::VALUE_FLOAT); high->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); high->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); high->setDefault(0); @@ -155,10 +152,10 @@ void GraphicEQEffect::processGroup(const QString& group, float fMid[6]; float fHigh; - fLow = m_pPotLow->value().toDouble(); - fHigh = m_pPotHigh->value().toDouble(); + fLow = m_pPotLow->value(); + fHigh = m_pPotHigh->value(); for (int i = 0; i < 6; i++) { - fMid[i] = m_pPotMid[i]->value().toDouble(); + fMid[i] = m_pPotMid[i]->value(); } diff --git a/src/effects/native/reverbeffect.cpp b/src/effects/native/reverbeffect.cpp index 23fec858649..b4d4ae0506d 100644 --- a/src/effects/native/reverbeffect.cpp +++ b/src/effects/native/reverbeffect.cpp @@ -29,7 +29,6 @@ EffectManifest ReverbEffect::getManifest() { time->setDescription(QObject::tr("Higher bandwidth values cause more " "bright (high-frequency) tones to be included")); time->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - time->setValueHint(EffectManifestParameter::VALUE_FLOAT); time->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); time->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); time->setMinimum(0.0005); @@ -42,7 +41,6 @@ EffectManifest ReverbEffect::getManifest() { damping->setDescription(QObject::tr("Higher damping values cause " "reverberations to die out more quickly.")); damping->setControlHint(EffectManifestParameter::CONTROL_KNOB_LINEAR); - damping->setValueHint(EffectManifestParameter::VALUE_FLOAT); damping->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); damping->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); damping->setMinimum(0.005); @@ -72,10 +70,8 @@ void ReverbEffect::processGroup(const QString& group, Q_UNUSED(group); Q_UNUSED(groupFeatures); Q_UNUSED(sampleRate); - CSAMPLE bandwidth = m_pBandWidthParameter ? - m_pBandWidthParameter->value().toDouble() : 1.0f; - CSAMPLE damping = m_pDampingParameter ? - m_pDampingParameter->value().toDouble() : 0.5f; + CSAMPLE bandwidth = m_pBandWidthParameter->value(); + CSAMPLE damping = m_pDampingParameter->value(); // Flip value around. Assumes max allowable is 1.0. damping = 1.0 - damping; diff --git a/src/engine/effects/engineeffectparameter.h b/src/engine/effects/engineeffectparameter.h index bc4abcaf89c..f3cee83b4cc 100644 --- a/src/engine/effects/engineeffectparameter.h +++ b/src/engine/effects/engineeffectparameter.h @@ -17,15 +17,9 @@ class EngineEffectParameter { // their parameters are not within the manifest's minimum/maximum bounds // so just to be safe we read the min/max/default from the manifest // here. - if (m_parameter.hasMinimum()) { - m_minimum = m_parameter.getMinimum(); - } - if (m_parameter.hasMaximum()) { - m_maximum = m_parameter.getMaximum(); - } - if (m_parameter.hasDefault()) { - m_default_value = m_parameter.getDefault(); - } + m_minimum = m_parameter.getMinimum(); + m_maximum = m_parameter.getMaximum(); + m_default_value = m_parameter.getDefault(); m_value = m_default_value; } virtual ~EngineEffectParameter() { } @@ -48,40 +42,40 @@ class EngineEffectParameter { // Value Settings /////////////////////////////////////////////////////////////////////////// - const QVariant& value() const { + const double& value() const { return m_value; } - void setValue(const QVariant& value) { + void setValue(const double& value) { m_value = value; } - const QVariant& defaultValue() const { + const double& defaultValue() const { return m_default_value; } - void setDefaultValue(const QVariant& default_value) { + void setDefaultValue(const double& default_value) { m_default_value = default_value; } - const QVariant& minimum() const { + const double& minimum() const { return m_minimum; } - void setMinimum(const QVariant& minimum) { + void setMinimum(const double& minimum) { m_minimum = minimum; } - const QVariant& maximum() const { + const double& maximum() const { return m_maximum; } - void setMaximum(const QVariant& maximum) { + void setMaximum(const double& maximum) { m_maximum = maximum; } private: EffectManifestParameter m_parameter; - QVariant m_value; - QVariant m_default_value; - QVariant m_minimum; - QVariant m_maximum; + double m_value; + double m_default_value; + double m_minimum; + double m_maximum; DISALLOW_COPY_AND_ASSIGN(EngineEffectParameter); }; diff --git a/src/engine/effects/message.h b/src/engine/effects/message.h index 7fac697404d..d21aab74417 100644 --- a/src/engine/effects/message.h +++ b/src/engine/effects/message.h @@ -125,10 +125,10 @@ struct EffectsRequest { QString group; // Used by SET_EFFECT_PARAMETER. - QVariant minimum; - QVariant maximum; - QVariant default_value; - QVariant value; + double minimum; + double maximum; + double default_value; + double value; }; struct EffectsResponse { From a6bd2d6e46cc608c88ff08a04c1311db47d795ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 7 Oct 2014 22:09:20 +0200 Subject: [PATCH 04/36] Added effect parameter buttons to Shade skin --- res/skins/Shade/effect_parameter_button.xml | 68 +++++++++++++++++++++ res/skins/Shade/effect_parameters.xml | 68 ++++++++++++++------- 2 files changed, 114 insertions(+), 22 deletions(-) create mode 100644 res/skins/Shade/effect_parameter_button.xml diff --git a/res/skins/Shade/effect_parameter_button.xml b/res/skins/Shade/effect_parameter_button.xml new file mode 100644 index 00000000000..a55d50c582c --- /dev/null +++ b/res/skins/Shade/effect_parameter_button.xml @@ -0,0 +1,68 @@ + + + diff --git a/res/skins/Shade/effect_parameters.xml b/res/skins/Shade/effect_parameters.xml index 686856ee312..23d12e534b7 100644 --- a/res/skins/Shade/effect_parameters.xml +++ b/res/skins/Shade/effect_parameters.xml @@ -20,29 +20,53 @@ - - - - - - - + + + + + + + + + + + + + + + From 86951e5bbbab433ac3dbd6cc09ed5c3b0a3fd09c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 7 Oct 2014 22:52:48 +0200 Subject: [PATCH 05/36] Added Kill buttons to LV-Mix EQs --- src/effects/native/bessel4lvmixeqeffect.cpp | 54 +++++++++++++++++++-- src/effects/native/bessel4lvmixeqeffect.h | 4 ++ src/effects/native/bessel8lvmixeqeffect.cpp | 54 +++++++++++++++++++-- src/effects/native/bessel8lvmixeqeffect.h | 4 ++ 4 files changed, 108 insertions(+), 8 deletions(-) diff --git a/src/effects/native/bessel4lvmixeqeffect.cpp b/src/effects/native/bessel4lvmixeqeffect.cpp index 5642c82b214..3159bf69b81 100644 --- a/src/effects/native/bessel4lvmixeqeffect.cpp +++ b/src/effects/native/bessel4lvmixeqeffect.cpp @@ -29,6 +29,18 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { low->setMinimum(0); low->setMaximum(4.0); + EffectManifestParameter* killLow = manifest.addButtonParameter(); + killLow->setId("killLow"); + killLow->setName(QObject::tr("Kill Low")); + killLow->setDescription(QObject::tr("Kill the Low Filter")); + killLow->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killLow->setValueHint(EffectManifestParameter::VALUE_INTEGRAL); + killLow->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); + killLow->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); + killLow->setDefault(0); + killLow->setMinimum(0); + killLow->setMaximum(1); + EffectManifestParameter* mid = manifest.addParameter(); mid->setId("mid"); mid->setName(QObject::tr("Mid")); @@ -41,6 +53,18 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { mid->setMinimum(0); mid->setMaximum(4.0); + EffectManifestParameter* killMid = manifest.addButtonParameter(); + killMid->setId("killMid"); + killMid->setName(QObject::tr("Kill Mid")); + killMid->setDescription(QObject::tr("Kill the Mid Filter")); + killMid->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killMid->setValueHint(EffectManifestParameter::VALUE_INTEGRAL); + killMid->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); + killMid->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); + killMid->setDefault(0); + killMid->setMinimum(0); + killMid->setMaximum(1); + EffectManifestParameter* high = manifest.addParameter(); high->setId("high"); high->setName(QObject::tr("High")); @@ -53,6 +77,18 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { high->setMinimum(0); high->setMaximum(4.0); + EffectManifestParameter* killHigh = manifest.addButtonParameter(); + killHigh->setId("killHigh"); + killHigh->setName(QObject::tr("Kill High")); + killHigh->setDescription(QObject::tr("Kill the High Filter")); + killHigh->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killHigh->setValueHint(EffectManifestParameter::VALUE_INTEGRAL); + killHigh->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); + killHigh->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); + killHigh->setDefault(0); + killHigh->setMinimum(0); + killHigh->setMaximum(1); + return manifest; } @@ -60,7 +96,10 @@ Bessel4LVMixEQEffect::Bessel4LVMixEQEffect(EngineEffect* pEffect, const EffectManifest& manifest) : m_pPotLow(pEffect->getParameterById("low")), m_pPotMid(pEffect->getParameterById("mid")), - m_pPotHigh(pEffect->getParameterById("high")) { + m_pPotHigh(pEffect->getParameterById("high")), + m_pKillLow(pEffect->getButtonParameterById("killLow")), + m_pKillMid(pEffect->getButtonParameterById("killMid")), + m_pKillHigh(pEffect->getButtonParameterById("killHigh")) { Q_UNUSED(manifest); m_pLoFreqCorner = new ControlObjectSlave("[Mixer Profile]", "LoEQFrequency"); m_pHiFreqCorner = new ControlObjectSlave("[Mixer Profile]", "HiEQFrequency"); @@ -80,9 +119,16 @@ void Bessel4LVMixEQEffect::processGroup(const QString& group, Q_UNUSED(group); Q_UNUSED(groupFeatures); - double fLow = m_pPotLow->value().toDouble(); - double fMid = m_pPotMid->value().toDouble(); - double fHigh = m_pPotHigh->value().toDouble(); + float fLow = 0.f, fMid = 0.f, fHigh = 0.f; + if (m_pKillLow->value().toInt() == 0) { + fLow = m_pPotLow->value().toDouble(); + } + if (m_pKillMid->value().toInt() == 0) { + fMid = m_pPotMid->value().toDouble(); + } + if (m_pKillHigh->value().toInt() == 0) { + fHigh = m_pPotHigh->value().toDouble(); + } if (pState->m_oldSampleRate != sampleRate || (pState->m_loFreq != m_pLoFreqCorner->get()) || diff --git a/src/effects/native/bessel4lvmixeqeffect.h b/src/effects/native/bessel4lvmixeqeffect.h index 8bf3835a54c..9a613d9aa8a 100644 --- a/src/effects/native/bessel4lvmixeqeffect.h +++ b/src/effects/native/bessel4lvmixeqeffect.h @@ -45,6 +45,10 @@ class Bessel4LVMixEQEffect : public GroupEffectProcessorsetMinimum(0); low->setMaximum(4.0); + EffectManifestParameter* killLow = manifest.addButtonParameter(); + killLow->setId("killLow"); + killLow->setName(QObject::tr("Kill Low")); + killLow->setDescription(QObject::tr("Kill the Low Filter")); + killLow->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killLow->setValueHint(EffectManifestParameter::VALUE_INTEGRAL); + killLow->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); + killLow->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); + killLow->setDefault(0); + killLow->setMinimum(0); + killLow->setMaximum(1); + EffectManifestParameter* mid = manifest.addParameter(); mid->setId("mid"); mid->setName(QObject::tr("Mid")); @@ -48,6 +60,18 @@ EffectManifest Bessel8LVMixEQEffect::getManifest() { mid->setMinimum(0); mid->setMaximum(4.0); + EffectManifestParameter* killMid = manifest.addButtonParameter(); + killMid->setId("killMid"); + killMid->setName(QObject::tr("Kill Mid")); + killMid->setDescription(QObject::tr("Kill the Mid Filter")); + killMid->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killMid->setValueHint(EffectManifestParameter::VALUE_INTEGRAL); + killMid->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); + killMid->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); + killMid->setDefault(0); + killMid->setMinimum(0); + killMid->setMaximum(1); + EffectManifestParameter* high = manifest.addParameter(); high->setId("high"); high->setName(QObject::tr("High")); @@ -60,6 +84,18 @@ EffectManifest Bessel8LVMixEQEffect::getManifest() { high->setMinimum(0); high->setMaximum(4.0); + EffectManifestParameter* killHigh = manifest.addButtonParameter(); + killHigh->setId("killHigh"); + killHigh->setName(QObject::tr("Kill High")); + killHigh->setDescription(QObject::tr("Kill the High Filter")); + killHigh->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killHigh->setValueHint(EffectManifestParameter::VALUE_INTEGRAL); + killHigh->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); + killHigh->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); + killHigh->setDefault(0); + killHigh->setMinimum(0); + killHigh->setMaximum(1); + return manifest; } @@ -67,7 +103,10 @@ Bessel8LVMixEQEffect::Bessel8LVMixEQEffect(EngineEffect* pEffect, const EffectManifest& manifest) : m_pPotLow(pEffect->getParameterById("low")), m_pPotMid(pEffect->getParameterById("mid")), - m_pPotHigh(pEffect->getParameterById("high")) { + m_pPotHigh(pEffect->getParameterById("high")), + m_pKillLow(pEffect->getButtonParameterById("killLow")), + m_pKillMid(pEffect->getButtonParameterById("killMid")), + m_pKillHigh(pEffect->getButtonParameterById("killHigh")) { Q_UNUSED(manifest); m_pLoFreqCorner = new ControlObjectSlave("[Mixer Profile]", "LoEQFrequency"); m_pHiFreqCorner = new ControlObjectSlave("[Mixer Profile]", "HiEQFrequency"); @@ -87,9 +126,16 @@ void Bessel8LVMixEQEffect::processGroup(const QString& group, Q_UNUSED(group); Q_UNUSED(groupFeatures); - double fLow = m_pPotLow->value().toDouble(); - double fMid = m_pPotMid->value().toDouble(); - double fHigh = m_pPotHigh->value().toDouble(); + float fLow = 0.f, fMid = 0.f, fHigh = 0.f; + if (m_pKillLow->value().toInt() == 0) { + fLow = m_pPotLow->value().toDouble(); + } + if (m_pKillMid->value().toInt() == 0) { + fMid = m_pPotMid->value().toDouble(); + } + if (m_pKillHigh->value().toInt() == 0) { + fHigh = m_pPotHigh->value().toDouble(); + } if (pState->m_oldSampleRate != sampleRate || (pState->m_loFreq != m_pLoFreqCorner->get()) || diff --git a/src/effects/native/bessel8lvmixeqeffect.h b/src/effects/native/bessel8lvmixeqeffect.h index adf6c00434a..182699ea7ea 100644 --- a/src/effects/native/bessel8lvmixeqeffect.h +++ b/src/effects/native/bessel8lvmixeqeffect.h @@ -47,6 +47,10 @@ class Bessel8LVMixEQEffect : public GroupEffectProcessor Date: Wed, 8 Oct 2014 22:50:35 +0200 Subject: [PATCH 06/36] renamed slotLinkTypeChanged to slotLinkTypeChanging --- src/effects/effectparameterslot.cpp | 4 ++-- src/effects/effectparameterslot.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/effects/effectparameterslot.cpp b/src/effects/effectparameterslot.cpp index 5a423addd3c..a5424f454fc 100644 --- a/src/effects/effectparameterslot.cpp +++ b/src/effects/effectparameterslot.cpp @@ -28,7 +28,7 @@ EffectParameterSlot::EffectParameterSlot(const unsigned int iRackNumber, ConfigKey(m_group, itemPrefix + QString("_type"))); m_pControlLinkType->connectValueChangeRequest( - this, SLOT(slotLinkTypeChanged(double))); + this, SLOT(slotLinkTypeChanging(double))); connect(m_pControlLinkInverse, SIGNAL(valueChanged(double)), this, SLOT(slotLinkInverseChanged(double))); connect(m_pControlValue, SIGNAL(valueChanged(double)), @@ -125,7 +125,7 @@ void EffectParameterSlot::slotParameterValueChanged(QVariant value) { m_pControlValue->set(value.toDouble()); } -void EffectParameterSlot::slotLinkTypeChanged(double v) { +void EffectParameterSlot::slotLinkTypeChanging(double v) { Q_UNUSED(v); m_pSoftTakeover->ignoreNext(); if (v > EffectManifestParameter::LINK_LINKED) { diff --git a/src/effects/effectparameterslot.h b/src/effects/effectparameterslot.h index 44cf66a987a..526a4f7d183 100644 --- a/src/effects/effectparameterslot.h +++ b/src/effects/effectparameterslot.h @@ -47,7 +47,7 @@ class EffectParameterSlot : public EffectParameterSlotBase { // Solely for handling control changes void slotParameterValueChanged(QVariant value); void slotValueChanged(double v); - void slotLinkTypeChanged(double v); + void slotLinkTypeChanging(double v); void slotLinkInverseChanged(double v); private: From 54054f16f26ca051d4e90eb8590fea07c17e5f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 9 Oct 2014 13:41:57 +0200 Subject: [PATCH 07/36] Added ahelper function for retreving bool and int. Inline these functions. --- src/engine/effects/engineeffectparameter.h | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/engine/effects/engineeffectparameter.h b/src/engine/effects/engineeffectparameter.h index f3cee83b4cc..26a1708dc87 100644 --- a/src/engine/effects/engineeffectparameter.h +++ b/src/engine/effects/engineeffectparameter.h @@ -19,8 +19,8 @@ class EngineEffectParameter { // here. m_minimum = m_parameter.getMinimum(); m_maximum = m_parameter.getMaximum(); - m_default_value = m_parameter.getDefault(); - m_value = m_default_value; + m_defaultValue = m_parameter.getDefault(); + m_value = m_defaultValue; } virtual ~EngineEffectParameter() { } @@ -42,38 +42,44 @@ class EngineEffectParameter { // Value Settings /////////////////////////////////////////////////////////////////////////// - const double& value() const { + inline double value() const { return m_value; } - void setValue(const double& value) { + inline void setValue(const double value) { m_value = value; } + inline int intValue() const { + return (int)m_value; + } + inline int boolValue() const { + return m_value > 0; + } - const double& defaultValue() const { - return m_default_value; + inline double defaultValue() const { + return m_defaultValue; } - void setDefaultValue(const double& default_value) { - m_default_value = default_value; + inline void setDefaultValue(const double default_value) { + m_defaultValue = default_value; } - const double& minimum() const { + inline double minimum() const { return m_minimum; } - void setMinimum(const double& minimum) { + inline void setMinimum(const double minimum) { m_minimum = minimum; } - const double& maximum() const { + inline double maximum() const { return m_maximum; } - void setMaximum(const double& maximum) { + inline void setMaximum(const double maximum) { m_maximum = maximum; } private: EffectManifestParameter m_parameter; double m_value; - double m_default_value; + double m_defaultValue; double m_minimum; double m_maximum; From cb21ff5b602b5f4e5711d12d6089463d4b311249 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Sat, 26 Jul 2014 00:03:42 +0300 Subject: [PATCH 08/36] Add another ValueHint for enumerations --- src/effects/effectmanifestparameter.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/effects/effectmanifestparameter.h b/src/effects/effectmanifestparameter.h index bc7b55d2098..7e552da78c0 100644 --- a/src/effects/effectmanifestparameter.h +++ b/src/effects/effectmanifestparameter.h @@ -11,7 +11,8 @@ class EffectManifestParameter { VALUE_UNKNOWN = 0, VALUE_BOOLEAN, VALUE_INTEGRAL, - VALUE_FLOAT + VALUE_FLOAT, + VALUE_ENUMERATION }; enum ControlHint { From 46c85143c12d1b30a2f15ca81855168ecbeda617 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Sat, 26 Jul 2014 13:56:38 +0300 Subject: [PATCH 09/36] Add a list of options for enumeration parameters to EffectManifestParameter --- src/effects/effectmanifestparameter.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/effects/effectmanifestparameter.h b/src/effects/effectmanifestparameter.h index 7e552da78c0..17ef1962c2f 100644 --- a/src/effects/effectmanifestparameter.h +++ b/src/effects/effectmanifestparameter.h @@ -171,6 +171,13 @@ class EffectManifestParameter { m_maximum = maximum; } + virtual void insertOption(QPair option) { + m_enumerationOptions.append(option); + } + virtual QList > getOptions() { + return m_enumerationOptions; + } + private: QString debugString() const { return QString("EffectManifestParameter(%1)").arg(m_id); @@ -190,6 +197,11 @@ class EffectManifestParameter { QVariant m_default; QVariant m_minimum; QVariant m_maximum; + + // Useful data for enumeration parameters; each pair has the following form: + // description - value + QList > m_enumerationOptions; + }; QDebug operator<<(QDebug dbg, const EffectManifestParameter& parameter); From 0cab23894abdee1c71c0255d00f976e44f0c9eae Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Fri, 1 Aug 2014 22:43:44 +0300 Subject: [PATCH 10/36] Add a special case for EffectManifestParameter::VALUE_ENUMERATION --- src/effects/effectparameter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/effects/effectparameter.cpp b/src/effects/effectparameter.cpp index 639bab727d3..07818471a35 100644 --- a/src/effects/effectparameter.cpp +++ b/src/effects/effectparameter.cpp @@ -55,6 +55,7 @@ EffectParameter::EffectParameter(Effect* pEffect, EffectsManager* pEffectsManage break; case EffectManifestParameter::VALUE_UNKNOWN: // Treat unknown like float case EffectManifestParameter::VALUE_FLOAT: + case EffectManifestParameter::VALUE_ENUMERATION: m_minimum = m_parameter.hasMinimum() && m_parameter.getMinimum().canConvert() ? m_parameter.getMinimum() : QVariant(0.0f); m_maximum = m_parameter.hasMaximum() && m_parameter.getMinimum().canConvert() ? @@ -153,6 +154,7 @@ bool EffectParameter::checkType(const QVariant& value) const { return value.canConvert(); case EffectManifestParameter::VALUE_FLOAT: case EffectManifestParameter::VALUE_UNKNOWN: + case EffectManifestParameter::VALUE_ENUMERATION: return value.canConvert(); default: qWarning() << debugString() << "ERROR: Unhandled valueHint"; @@ -270,6 +272,7 @@ void EffectParameter::setMinimum(QVariant minimum) { break; case EffectManifestParameter::VALUE_UNKNOWN: case EffectManifestParameter::VALUE_FLOAT: + case EffectManifestParameter::VALUE_ENUMERATION: m_minimum = minimum.toDouble(); if (m_parameter.hasMinimum() && m_minimum.toDouble() < m_parameter.getMinimum().toDouble()) { @@ -345,6 +348,8 @@ void EffectParameter::setMaximum(QVariant maximum) { break; case EffectManifestParameter::VALUE_UNKNOWN: case EffectManifestParameter::VALUE_FLOAT: + case EffectManifestParameter::VALUE_ENUMERATION: + m_maximum = maximum.toDouble(); if (m_parameter.hasMaximum() && m_maximum.toDouble() > m_parameter.getMaximum().toDouble()) { From 55c4ae2e69c116e134c6719d8f2ebc48b92549f9 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Fri, 1 Aug 2014 22:44:46 +0300 Subject: [PATCH 11/36] Make getOptions() method const because it is being called on a const object --- src/effects/effectmanifestparameter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/effects/effectmanifestparameter.h b/src/effects/effectmanifestparameter.h index 17ef1962c2f..e314c24c3d6 100644 --- a/src/effects/effectmanifestparameter.h +++ b/src/effects/effectmanifestparameter.h @@ -174,7 +174,7 @@ class EffectManifestParameter { virtual void insertOption(QPair option) { m_enumerationOptions.append(option); } - virtual QList > getOptions() { + virtual QList > getOptions() const { return m_enumerationOptions; } From d9fc071d4cf1f17324fafa87e96331709e58b360 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Fri, 1 Aug 2014 22:45:23 +0300 Subject: [PATCH 12/36] Set the number of states for each EffectButtonParameterSlot --- src/effects/effectbuttonparameterslot.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/effects/effectbuttonparameterslot.cpp b/src/effects/effectbuttonparameterslot.cpp index cc0245aa57e..eeec7719ac3 100644 --- a/src/effects/effectbuttonparameterslot.cpp +++ b/src/effects/effectbuttonparameterslot.cpp @@ -46,6 +46,9 @@ void EffectButtonParameterSlot::loadEffect(EffectPointer pEffect) { m_pEffectParameter = pEffect->getButtonParameter(m_iParameterNumber); if (m_pEffectParameter) { + // Set the number of states + int numStates = m_pEffectParameter->manifest().getOptions().size(); + m_pControlValue->setStates(numStates); //qDebug() << debugString() << "Loading effect parameter" << m_pEffectParameter->name(); double dValue = m_pEffectParameter->getValue().toDouble(); double dMinimum = m_pEffectParameter->getMinimum().toDouble(); From e76ecda97b2f7ac366ef7c1321abffa27327e062 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Fri, 1 Aug 2014 22:46:32 +0300 Subject: [PATCH 13/36] Add special treatment for EffectManifestParameter::VALUE_ENUMERATION (wrap around the values) --- src/effects/effectparameter.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/effects/effectparameter.cpp b/src/effects/effectparameter.cpp index 07818471a35..3bb87de5257 100644 --- a/src/effects/effectparameter.cpp +++ b/src/effects/effectparameter.cpp @@ -135,6 +135,16 @@ bool EffectParameter::clampValue(EffectManifestParameter::ValueHint valueHint, Q return true; } break; + case EffectManifestParameter::VALUE_ENUMERATION: + if (pValue->toDouble() < minimum.toDouble()) { + *pValue = maximum; + return true; + } else if (pValue->toDouble() > maximum.toDouble()) { + *pValue = minimum; + return true; + } + break; + default: qWarning() << "ERROR: Unhandled valueHint"; break; From 69059d7c3b0d645755ca5c0b55cb9c1927997ac6 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Tue, 5 Aug 2014 01:48:23 +0300 Subject: [PATCH 14/36] Add getManifest() method to EffectParameterSlotBase --- src/effects/effectparameterslotbase.cpp | 7 +++++++ src/effects/effectparameterslotbase.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/effects/effectparameterslotbase.cpp b/src/effects/effectparameterslotbase.cpp index d4ef6164784..0416832ed2e 100644 --- a/src/effects/effectparameterslotbase.cpp +++ b/src/effects/effectparameterslotbase.cpp @@ -52,3 +52,10 @@ void EffectParameterSlotBase::slotValueType(double v) { //qDebug() << debugString() << "slotValueType" << v; qWarning() << "WARNING: value_type is a read-only control."; } + +const EffectManifestParameter EffectParameterSlotBase::getManifest() { + if (m_pEffectParameter) { + return m_pEffectParameter->manifest(); + } + return EffectManifestParameter(); +} diff --git a/src/effects/effectparameterslotbase.h b/src/effects/effectparameterslotbase.h index 492dd702f80..1e62dd6547b 100644 --- a/src/effects/effectparameterslotbase.h +++ b/src/effects/effectparameterslotbase.h @@ -35,6 +35,7 @@ class EffectParameterSlotBase : public QObject { QString name() const; QString description() const; + const EffectManifestParameter getManifest(); signals: // Signal that indicates that the EffectParameterSlotBase has been updated. From 4f711fba114054b63dbf9d8d906d3af47bf4b5dc Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Tue, 5 Aug 2014 01:53:56 +0300 Subject: [PATCH 15/36] Add a new widget derived from WPushButton which displays a QMenu with available options when right clicking the button --- src/widget/weffectpushbutton.cpp | 498 +++++++++++++++++++++++++++++++ src/widget/weffectpushbutton.h | 99 ++++++ 2 files changed, 597 insertions(+) create mode 100644 src/widget/weffectpushbutton.cpp create mode 100644 src/widget/weffectpushbutton.h diff --git a/src/widget/weffectpushbutton.cpp b/src/widget/weffectpushbutton.cpp new file mode 100644 index 00000000000..c49cdd7ae56 --- /dev/null +++ b/src/widget/weffectpushbutton.cpp @@ -0,0 +1,498 @@ +#include "widget/weffectpushbutton.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "widget/wpixmapstore.h" +#include "controlobject.h" +#include "controlpushbutton.h" +#include "control/controlbehavior.h" +#include "util/debug.h" + +WEffectPushButton::WEffectPushButton(QWidget* pParent, EffectsManager* pEffectsManager) + : WWidget(pParent), + m_leftButtonMode(ControlPushButton::PUSH), + m_rightButtonMode(ControlPushButton::PUSH), + m_pEffectsManager(pEffectsManager) { + setStates(0); +} + +WEffectPushButton::WEffectPushButton(QWidget* pParent, ControlPushButton::ButtonMode leftButtonMode, + ControlPushButton::ButtonMode rightButtonMode) + : WWidget(pParent), + m_leftButtonMode(leftButtonMode), + m_rightButtonMode(rightButtonMode) { + setStates(0); +} + +WEffectPushButton::~WEffectPushButton() { +} + +void WEffectPushButton::setup(QDomNode node, const SkinContext& context) { + // Number of states + int iNumStates = context.selectInt(node, "NumberStates"); + setStates(iNumStates); + + // Set background pixmap if available + if (context.hasNode(node, "BackPath")) { + QString mode_str = context.selectAttributeString( + context.selectElement(node, "BackPath"), "scalemode", "TILE"); + QString backPath = context.getPixmapPath(context.selectNode(node, "BackPath")); + if (!backPath.isEmpty()) { + setPixmapBackground(backPath, Paintable::DrawModeFromString(mode_str)); + } + } + + // Load pixmaps for associated states + QDomNode state = context.selectNode(node, "State"); + while (!state.isNull()) { + if (state.isElement() && state.nodeName() == "State") { + int iState = context.selectInt(state, "Number"); + if (iState < m_iNoStates) { + QString pixmapPath; + + pixmapPath = context.getPixmapPath(context.selectNode(state, "Unpressed")); + if (!pixmapPath.isEmpty()) { + setPixmap(iState, false, pixmapPath); + } + + pixmapPath = context.getPixmapPath(context.selectNode(state, "Pressed")); + if (!pixmapPath.isEmpty()) { + setPixmap(iState, true, pixmapPath); + } + + m_text.replace(iState, context.selectString(state, "Text")); + QString alignment = context.selectString(state, "Alignment"); + if (alignment == "left") { + m_align.replace(iState, Qt::AlignLeft); + } else if (alignment == "right") { + m_align.replace(iState, Qt::AlignRight); + } else { + // Default is center. + m_align.replace(iState, Qt::AlignCenter); + } + } + } + state = state.nextSibling(); + } + + ControlParameterWidgetConnection* leftConnection = NULL; + if (m_leftConnections.isEmpty()) { + if (!m_connections.isEmpty()) { + // If no left connection is set, the this is the left connection + leftConnection = m_connections.at(0); + } + } else { + leftConnection = m_leftConnections.at(0); + } + + if (leftConnection) { + bool leftClickForcePush = context.selectBool(node, "LeftClickIsPushButton", false); + m_leftButtonMode = ControlPushButton::PUSH; + if (!leftClickForcePush) { + const ConfigKey& configKey = leftConnection->getKey(); + ControlPushButton* p = dynamic_cast( + ControlObject::getControl(configKey)); + if (p) { + m_leftButtonMode = p->getButtonMode(); + } + } + if (leftConnection->getEmitOption() & + ControlParameterWidgetConnection::EMIT_DEFAULT) { + switch (m_leftButtonMode) { + case ControlPushButton::PUSH: + case ControlPushButton::LONGPRESSLATCHING: + case ControlPushButton::POWERWINDOW: + leftConnection->setEmitOption( + ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE); + break; + default: + leftConnection->setEmitOption( + ControlParameterWidgetConnection::EMIT_ON_PRESS); + break; + } + } + if (leftConnection->getDirectionOption() & + ControlParameterWidgetConnection::DIR_DEFAULT) { + if (m_pDisplayConnection == leftConnection) { + leftConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_FROM_AND_TO_WIDGET); + } else { + leftConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_FROM_WIDGET); + if (m_pDisplayConnection->getDirectionOption() & + ControlParameterWidgetConnection::DIR_DEFAULT) { + m_pDisplayConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_TO_WIDGET); + } + } + } + } + + if (!m_rightConnections.isEmpty()) { + ControlParameterWidgetConnection* rightConnection = m_rightConnections.at(0); + bool rightClickForcePush = context.selectBool(node, "RightClickIsPushButton", false); + m_rightButtonMode = ControlPushButton::PUSH; + if (!rightClickForcePush) { + const ConfigKey configKey = rightConnection->getKey(); + ControlPushButton* p = dynamic_cast( + ControlObject::getControl(configKey)); + if (p) { + m_rightButtonMode = p->getButtonMode(); + if (m_rightButtonMode != ControlPushButton::PUSH) { + qWarning() + << "WEffectPushButton::setup: Connecting a Pushbutton not in PUSH mode is not implemented\n" + << "Please set true"; + } + } + } + if (rightConnection->getEmitOption() & + ControlParameterWidgetConnection::EMIT_DEFAULT) { + switch (m_rightButtonMode) { + case ControlPushButton::PUSH: + case ControlPushButton::LONGPRESSLATCHING: + case ControlPushButton::POWERWINDOW: + leftConnection->setEmitOption( + ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE); + break; + default: + leftConnection->setEmitOption( + ControlParameterWidgetConnection::EMIT_ON_PRESS); + break; + } + } + if (rightConnection->getDirectionOption() & + ControlParameterWidgetConnection::DIR_DEFAULT) { + rightConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_FROM_WIDGET); + } + } + + m_pButtonMenu = new QMenu(this); + connect(m_pButtonMenu, SIGNAL(triggered(QAction*)), + this, SLOT(slotActionChosen(QAction*))); + bool rackOk = false; + int rackNumber = context.selectInt(node, "EffectRack", &rackOk) - 1; + bool chainOk = false; + int chainNumber = context.selectInt(node, "EffectUnit", &chainOk) - 1; + bool effectOk = false; + int effectNumber = context.selectInt(node, "Effect", &effectOk) - 1; + bool parameterOk = false; + int parameterNumber = context.selectInt(node, "EffectButtonParameter", ¶meterOk) - 1; + + // Tolerate no . Use the default one. + if (!rackOk) { + rackNumber = 0; + } + + if (!chainOk) { + qDebug() << "EffectPushButton node had invalid EffectUnit number:" << chainNumber; + } + + if (!effectOk) { + qDebug() << "EffectPushButton node had invalid Effect number:" << effectNumber; + } + + if (!parameterOk) { + qDebug() << "EffectPushButton node had invalid ButtonParameter number:" << parameterNumber; + } + + EffectRackPointer pRack = m_pEffectsManager->getEffectRack(rackNumber); + if (pRack) { + EffectChainSlotPointer pChainSlot = pRack->getEffectChainSlot(chainNumber); + if (pChainSlot) { + EffectSlotPointer pEffectSlot = pChainSlot->getEffectSlot(effectNumber); + if (pEffectSlot) { + EffectParameterSlotBasePointer pParameterSlot = + pEffectSlot->getEffectButtonParameterSlot(parameterNumber); + if (pParameterSlot) { + m_pEffectParameterSlot = pParameterSlot; + connect(pParameterSlot.data(), SIGNAL(updated()), + this, SLOT(parameterUpdated())); + parameterUpdated(); + } else { + qDebug() << "EffectPushButton node had invalid ButtonParameter number:" << parameterNumber; + } + } else { + qDebug() << "EffectPushButton node had invalid Effect number:" << effectNumber; + } + } else { + qDebug() << "EffectPushButton node had invalid EffectUnit number:" << chainNumber; + } + } else { + qDebug() << "EffectPushButton node had invalid EffectRack number:" << rackNumber; + } +} + +void WEffectPushButton::setStates(int iStates) { + m_bPressed = false; + m_iNoStates = iStates; + m_activeTouchButton = Qt::NoButton; + + m_pressedPixmaps.resize(iStates); + m_unpressedPixmaps.resize(iStates); + m_text.resize(iStates); + m_align.resize(iStates); +} + +void WEffectPushButton::setPixmap(int iState, bool bPressed, const QString& filename) { + QVector& pixmaps = bPressed ? + m_pressedPixmaps : m_unpressedPixmaps; + + if (iState < 0 || iState >= pixmaps.size()) { + return; + } + + PaintablePointer pPixmap = WPixmapStore::getPaintable(filename, + Paintable::STRETCH); + + if (pPixmap.isNull() || pPixmap->isNull()) { + // Only log if it looks like the user tried to specify a pixmap. + if (!filename.isEmpty()) { + qDebug() << "WEffectPushButton: Error loading pixmap:" << filename; + } + } else { + // Set size of widget equal to pixmap size + setFixedSize(pPixmap->size()); + } + pixmaps.replace(iState, pPixmap); +} + +void WEffectPushButton::setPixmapBackground(const QString &filename, + Paintable::DrawMode mode) { + // Load background pixmap + m_pPixmapBack = WPixmapStore::getPaintable(filename, mode); + if (!filename.isEmpty() && + (m_pPixmapBack.isNull() || m_pPixmapBack->isNull())) { + // Only log if it looks like the user tried to specify a pixmap. + qDebug() << "WEffectPushButton: Error loading background pixmap:" << filename; + } +} + +void WEffectPushButton::onConnectedControlChanged(double dParameter, double dValue) { + Q_UNUSED(dParameter); + // Enums are not currently represented using parameter space so it doesn't + // make sense to use the parameter here yet. + if (m_iNoStates == 1) { + m_bPressed = (dValue == 1.0); + } + + double value = getControlParameterDisplay(); + int idx = static_cast(value) % m_iNoStates; + setProperty("displayValue", idx); + // According to http://stackoverflow.com/a/3822243 this is the least + // expensive way to restyle just this widget. + // Since we expect button connections to not change at high frequency we + // don't try to detect whether things have changed for WEffectPushButton, we just + // re-render. + style()->unpolish(this); + style()->polish(this); + // These calls don't always trigger the repaint, so call it explicitly. + repaint(); +} + +void WEffectPushButton::paintEvent(QPaintEvent* e) { + Q_UNUSED(e); + QStyleOption option; + option.initFrom(this); + QStylePainter p(this); + p.drawPrimitive(QStyle::PE_Widget, option); + + if (m_iNoStates == 0) { + return; + } + + if (m_pPixmapBack) { + m_pPixmapBack->draw(0, 0, &p); + } + + const QVector& pixmaps = m_bPressed ? + m_pressedPixmaps : m_unpressedPixmaps; + + + // m_text, m_pressedPixmaps and m_unpressedPixmaps are all the same size (as + // per setup()) so if one is empty, all are empty. + if (pixmaps.isEmpty()) { + return; + } + + int idx = readDisplayValue(); + // Just in case m_iNoStates is somehow different from pixmaps.size(). + if (idx < 0) { + idx = 0; + } else if (idx >= pixmaps.size()) { + idx = pixmaps.size() - 1; + } + + PaintablePointer pPixmap = pixmaps.at(idx); + if (!pPixmap.isNull() && !pPixmap->isNull()) { + pPixmap->draw(0, 0, &p); + } + + QString text = m_text.at(idx); + if (!text.isEmpty()) { + p.drawText(rect(), m_align.at(idx), text); + } +} + +void WEffectPushButton::mousePressEvent(QMouseEvent * e) { + const bool leftClick = e->button() == Qt::LeftButton; + const bool rightClick = e->button() == Qt::RightButton; + + if (m_leftButtonMode == ControlPushButton::POWERWINDOW + && m_iNoStates == 2) { + if (leftClick) { + if (getControlParameterLeft() == 0.0) { + m_clickTimer.setSingleShot(true); + m_clickTimer.start(ControlPushButtonBehavior::kPowerWindowTimeMillis); + } + m_bPressed = true; + setControlParameterLeftDown(1.0); + update(); + } + // discharge right clicks here, because is used for latching in POWERWINDOW mode + return; + } + + if (rightClick) { + m_pButtonMenu->exec(e->globalPos()); + // This is the secondary button function allways a Pushbutton + // due the leak of visual feedback we do not allow a toggle function + if (m_rightButtonMode == ControlPushButton::PUSH + || m_iNoStates == 1) { + m_bPressed = true; + setControlParameterRightDown(1.0); + update(); + } + return; + } + + if (leftClick) { + double emitValue; + if (m_leftButtonMode == ControlPushButton::PUSH + || m_iNoStates == 1) { + // This is either forced to behave like a push button on left-click + // or this is a push button. + emitValue = 1.0; + } else { + // Toggle thru the states + emitValue = static_cast(getControlParameterLeft() + 1.0) % m_iNoStates; + if (m_leftButtonMode == ControlPushButton::LONGPRESSLATCHING) { + m_clickTimer.setSingleShot(true); + m_clickTimer.start(ControlPushButtonBehavior::kLongPressLatchingTimeMillis); + } + + // Check the corresponding QAction + foreach (QAction* action, m_pButtonMenu->actions()) { + if (action->data().toDouble() == emitValue) { + action->setChecked(true); + break; + } + } + } + m_bPressed = true; + setControlParameterLeftDown(emitValue); + update(); + } +} + +void WEffectPushButton::focusOutEvent(QFocusEvent* e) { + Q_UNUSED(e); + if (e->reason() != Qt::MouseFocusReason) { + // Since we support multi touch there is no reason to reset + // the pressed flag if the Primary touch point is moved to an + // other widget + m_bPressed = false; + update(); + } +} + +void WEffectPushButton::mouseReleaseEvent(QMouseEvent * e) { + const bool leftClick = e->button() == Qt::LeftButton; + const bool rightClick = e->button() == Qt::RightButton; + + if (m_leftButtonMode == ControlPushButton::POWERWINDOW + && m_iNoStates == 2) { + if (leftClick) { + const bool rightButtonDown = QApplication::mouseButtons() & Qt::RightButton; + if (m_bPressed && !m_clickTimer.isActive() && !rightButtonDown) { + // Release button after timer, but not if right button is clicked + setControlParameterLeftUp(0.0); + } + m_bPressed = false; + } else if (rightClick) { + m_bPressed = false; + } + update(); + return; + } + + if (rightClick) { + // This is the secondary clickButton function, + // due the leak of visual feedback we do not allow a toggle + // function + if (m_rightButtonMode == ControlPushButton::PUSH + || m_iNoStates == 1) { + m_bPressed = false; + setControlParameterRightUp(0.0); + update(); + } + return; + } + + if (leftClick) { + double emitValue = getControlParameterLeft(); + if (m_leftButtonMode == ControlPushButton::PUSH + || m_iNoStates == 1) { + // This is a Pushbutton + emitValue = 0.0; + } else { + if (m_leftButtonMode == ControlPushButton::LONGPRESSLATCHING + && m_clickTimer.isActive() && emitValue >= 1.0) { + // revert toggle if button is released too early + emitValue = static_cast(emitValue - 1.0) % m_iNoStates; + } else { + // Nothing special happens when releasing a normal toggle button + } + } + m_bPressed = false; + setControlParameterLeftUp(emitValue); + update(); + } +} + +void WEffectPushButton::fillDebugTooltip(QStringList* debug) { + WWidget::fillDebugTooltip(debug); + *debug << QString("NumberStates: %1").arg(m_iNoStates) + << QString("LeftCurrentState: %1").arg( + static_cast(getControlParameterLeft()) % + (m_iNoStates > 0 ? m_iNoStates : 1)) + << QString("Pressed: %1").arg(toDebugString(m_bPressed)) + << QString("LeftButtonMode: %1") + .arg(ControlPushButton::buttonModeToString(m_leftButtonMode)) + << QString("RightButtonMode: %1") + .arg(ControlPushButton::buttonModeToString(m_rightButtonMode)); +} + +void WEffectPushButton::parameterUpdated() { + m_pButtonMenu->clear(); + QList > options = m_pEffectParameterSlot->getManifest().getOptions(); + qDebug() << " HERE IS THE OPTIONS SIZE: " << options.size(); + QActionGroup* actionGroup = new QActionGroup(m_pButtonMenu); + actionGroup->setExclusive(true); + for (int i = 0; i < options.size(); i++) { + // action is added automatically to actionGroup + QAction* action = new QAction(actionGroup); + action->setText(options[i].first); + action->setData(options[i].second); + action->setCheckable(true); + m_pButtonMenu->addAction(action); + } +} + +void WEffectPushButton::slotActionChosen(QAction* action) { + action->setChecked(true); + setControlParameter(action->data().toDouble()); +} diff --git a/src/widget/weffectpushbutton.h b/src/widget/weffectpushbutton.h new file mode 100644 index 00000000000..1a51d6839e3 --- /dev/null +++ b/src/widget/weffectpushbutton.h @@ -0,0 +1,99 @@ +#ifndef WEFFECTPUSHBUTTON_H +#define WEFFECTPUSHBUTTON_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "widget/wwidget.h" +#include "widget/wpixmapstore.h" +#include "controlpushbutton.h" +#include "skin/skincontext.h" +#include "controlwidgetconnection.h" +#include "effects/effectsmanager.h" + +class WEffectPushButton : public WWidget { + Q_OBJECT + public: + WEffectPushButton(QWidget* pParent, EffectsManager* pEffectsManager); + // Used by WEffectPushButtonTest. + WEffectPushButton(QWidget* pParent, ControlPushButton::ButtonMode leftButtonMode, + ControlPushButton::ButtonMode rightButtonMode); + virtual ~WEffectPushButton(); + + Q_PROPERTY(bool pressed READ isPressed); + + bool isPressed() const { + return m_bPressed; + } + + // The displayValue property is used to restyle the pushbutton with CSS. + // The declaration #MyButton[displayValue="0"] { } will define the style + // when the widget is in state 0. This allows for effects like reversing + // background and foreground colors to indicate enabled/disabled state. + Q_PROPERTY(int displayValue READ readDisplayValue) + + int readDisplayValue() const { + double value = getControlParameterDisplay(); + int idx = static_cast(value) % m_iNoStates; + return idx; + } + + void setup(QDomNode node, const SkinContext& context); + + // Sets the number of states associated with this button, and removes + // associated pixmaps. + void setStates(int iStatesW); + + public slots: + void onConnectedControlChanged(double dParameter, double dValue); + + protected: + virtual void paintEvent(QPaintEvent*); + virtual void mousePressEvent(QMouseEvent* e); + virtual void mouseReleaseEvent(QMouseEvent* e); + virtual void focusOutEvent(QFocusEvent* e); + void fillDebugTooltip(QStringList* debug); + + private slots: + void parameterUpdated(); + void slotActionChosen(QAction* action); + + private: + // Associates a pixmap of a given state of the button with the widget + void setPixmap(int iState, bool bPressed, const QString &filename); + + // Associates a background pixmap with the widget. This is only needed if + // the button pixmaps contains alpha channel values. + void setPixmapBackground(const QString &filename, Paintable::DrawMode mode); + + // True, if the button is currently pressed + bool m_bPressed; + + // Array of associated pixmaps + int m_iNoStates; + QVector m_text; + QVector m_pressedPixmaps; + QVector m_unpressedPixmaps; + + // Associated background pixmap + PaintablePointer m_pPixmapBack; + + // short click toggle button long click push button + ControlPushButton::ButtonMode m_leftButtonMode; + ControlPushButton::ButtonMode m_rightButtonMode; + QTimer m_clickTimer; + QVector m_align; + + EffectsManager* m_pEffectsManager; + EffectParameterSlotBasePointer m_pEffectParameterSlot; + QMenu* m_pButtonMenu; +}; + +#endif // WEFFECTPUSHBUTTON_H From 204a6c53f4cf46277dc9dfc6946a7eb3f20ad2af Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Tue, 5 Aug 2014 01:55:34 +0300 Subject: [PATCH 16/36] Add WEffectPushButton to depends.py --- build/depends.py | 1 + 1 file changed, 1 insertion(+) diff --git a/build/depends.py b/build/depends.py index 7496aeb0a95..6ab221593f4 100644 --- a/build/depends.py +++ b/build/depends.py @@ -674,6 +674,7 @@ def sources(self, build): "widget/wdisplay.cpp", "widget/wvumeter.cpp", "widget/wpushbutton.cpp", + "widget/weffectpushbutton.cpp", "widget/wslidercomposed.cpp", "widget/wstatuslight.cpp", "widget/woverview.cpp", From 6f325aca235f81585941e45b6e7a7c7394f1d58c Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Tue, 5 Aug 2014 01:55:56 +0300 Subject: [PATCH 17/36] Write a new method for parsing an EffectPushButton skin node --- src/skin/legacyskinparser.cpp | 16 ++++++++++++++++ src/skin/legacyskinparser.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 35966d2f5d5..f1bca6fab94 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -36,6 +36,7 @@ #include "widget/wknobcomposed.h" #include "widget/wslidercomposed.h" #include "widget/wpushbutton.h" +#include "widget/weffectpushbutton.h" #include "widget/wdisplay.h" #include "widget/wvumeter.h" #include "widget/wstatuslight.h" @@ -404,6 +405,8 @@ QList LegacySkinParser::parseNode(QDomElement node) { result = wrapWidget(parseStandardWidget(node)); } else if (nodeName == "PushButton") { result = wrapWidget(parseStandardWidget(node)); + } else if (nodeName == "EffectPushButton") { + result = wrapWidget(parseEffectPushButton(node)); } else if (nodeName == "ComboBox") { result = wrapWidget(parseStandardWidget(node)); } else if (nodeName == "Overview") { @@ -1275,6 +1278,19 @@ QWidget* LegacySkinParser::parseEffectName(QDomElement node) { return pEffect; } +QWidget* LegacySkinParser::parseEffectPushButton(QDomElement element) { + WEffectPushButton* pWidget = new WEffectPushButton(m_pParent, m_pEffectsManager); + setupConnections(element, pWidget); + setupBaseWidget(element, pWidget); + setupWidget(element, pWidget); + pWidget->setup(element, *m_pContext); + pWidget->installEventFilter(m_pKeyboard); + pWidget->installEventFilter( + m_pControllerManager->getControllerLearningEventFilter()); + pWidget->Init(); + return pWidget; +} + QWidget* LegacySkinParser::parseEffectParameterName(QDomElement node) { WEffectParameterBase* pEffectParameter = new WEffectParameter(m_pParent, m_pEffectsManager); setupLabelWidget(node, pEffectParameter); diff --git a/src/skin/legacyskinparser.h b/src/skin/legacyskinparser.h index 94cbc935e3e..5c34c12761b 100644 --- a/src/skin/legacyskinparser.h +++ b/src/skin/legacyskinparser.h @@ -76,6 +76,7 @@ class LegacySkinParser : public QObject, public SkinParser { QWidget* parseEffectName(QDomElement node); QWidget* parseEffectParameterName(QDomElement node); QWidget* parseEffectButtonParameterName(QDomElement node); + QWidget* parseEffectPushButton(QDomElement node); // Legacy pre-1.12.0 skin support. QWidget* parseBackground(QDomElement node, QWidget* pOuterWidget, QWidget* pInnerWidget); From bcb35cba5f9a87b9dee0b152b461ff854104b926 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Wed, 6 Aug 2014 01:37:43 +0300 Subject: [PATCH 18/36] Introduce a list which is responsible for remapping indices of active parameters --- src/effects/effectmanifest.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index dace34d0192..8dab6aba2dd 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -21,7 +21,12 @@ // example, a database-backed manifest) class EffectManifest { public: - EffectManifest() { } + EffectManifest() { + for (unsigned int i = 0; i < 188; i++) { + m_activeParameters.append(i); + } + } + virtual ~EffectManifest() { //qDebug() << debugString() << "deleted"; } @@ -65,7 +70,6 @@ class EffectManifest { return m_parameters; } - virtual EffectManifestParameter* addParameter() { m_parameters.append(EffectManifestParameter()); return &m_parameters.last(); @@ -80,6 +84,14 @@ class EffectManifest { return &m_buttonParameters.last(); } + virtual void setActiveParameter(int index, unsigned int value) { + m_activeParameters[index] = value; + } + + virtual unsigned int getActiveParameter(int index) const { + return m_activeParameters[index]; + } + private: QString debugString() const { return QString("EffectManifest(%1)").arg(m_id); @@ -92,6 +104,7 @@ class EffectManifest { QString m_description; QList m_parameters; QList m_buttonParameters; + QList m_activeParameters; }; #endif /* EFFECTMANIFEST_H */ From ccca041e6d7987f86f4973461097262e9d9c754e Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Wed, 6 Aug 2014 01:39:10 +0300 Subject: [PATCH 19/36] Use the remapping provided by the EffectManifest --- src/effects/effectparameterslot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/effects/effectparameterslot.cpp b/src/effects/effectparameterslot.cpp index a5424f454fc..70277358c91 100644 --- a/src/effects/effectparameterslot.cpp +++ b/src/effects/effectparameterslot.cpp @@ -59,7 +59,7 @@ void EffectParameterSlot::loadEffect(EffectPointer pEffect) { clear(); if (pEffect) { // Returns null if it doesn't have a parameter for that number - m_pEffectParameter = pEffect->getParameter(m_iParameterNumber); + m_pEffectParameter = pEffect->getParameter(pEffect->getManifest().getActiveParameter(m_iParameterNumber)); if (m_pEffectParameter) { //qDebug() << debugString() << "Loading effect parameter" << m_pEffectParameter->name(); From ffa9a8259a8242c4bf10433d940f707ce8aadc7f Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Fri, 8 Aug 2014 15:20:50 +0300 Subject: [PATCH 20/36] Add information about active button parameters inside EffectManifest --- src/effects/effectmanifest.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index 8dab6aba2dd..67fbc385b3a 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -24,6 +24,7 @@ class EffectManifest { EffectManifest() { for (unsigned int i = 0; i < 188; i++) { m_activeParameters.append(i); + m_activeButtonParameters.append(i); } } @@ -92,6 +93,14 @@ class EffectManifest { return m_activeParameters[index]; } + virtual void setActiveButtonParameter(int index, unsigned int value) { + m_activeButtonParameters[index] = value; + } + + virtual unsigned int getActiveButtonParameter(int index) const { + return m_activeButtonParameters[index]; + } + private: QString debugString() const { return QString("EffectManifest(%1)").arg(m_id); @@ -105,6 +114,7 @@ class EffectManifest { QList m_parameters; QList m_buttonParameters; QList m_activeParameters; + QList m_activeButtonParameters; }; #endif /* EFFECTMANIFEST_H */ From 2632b17b8d4631bdd6be093e8e1a9d81dcc93879 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Fri, 8 Aug 2014 15:23:28 +0300 Subject: [PATCH 21/36] Use the mapping provided by the EffectManifest when asking for a button parameter --- src/effects/effectbuttonparameterslot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/effects/effectbuttonparameterslot.cpp b/src/effects/effectbuttonparameterslot.cpp index eeec7719ac3..76206348436 100644 --- a/src/effects/effectbuttonparameterslot.cpp +++ b/src/effects/effectbuttonparameterslot.cpp @@ -43,7 +43,7 @@ void EffectButtonParameterSlot::loadEffect(EffectPointer pEffect) { if (pEffect) { m_pEffect = pEffect; // Returns null if it doesn't have a parameter for that number - m_pEffectParameter = pEffect->getButtonParameter(m_iParameterNumber); + m_pEffectParameter = pEffect->getButtonParameter(pEffect->getManifest().getActiveButtonParameter(m_iParameterNumber)); if (m_pEffectParameter) { // Set the number of states From 3d23f1b715e1cbd8e280b06a4b7e38b257092b18 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Sun, 10 Aug 2014 12:12:39 +0300 Subject: [PATCH 22/36] Remove the hard coded mapping function from EffectManifest's constructor --- src/effects/effectmanifest.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index 67fbc385b3a..93d90ad28fd 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -22,10 +22,6 @@ class EffectManifest { public: EffectManifest() { - for (unsigned int i = 0; i < 188; i++) { - m_activeParameters.append(i); - m_activeButtonParameters.append(i); - } } virtual ~EffectManifest() { @@ -72,6 +68,7 @@ class EffectManifest { } virtual EffectManifestParameter* addParameter() { + m_activeParameters.append(m_parameters.size()); m_parameters.append(EffectManifestParameter()); return &m_parameters.last(); } @@ -81,6 +78,7 @@ class EffectManifest { } virtual EffectManifestParameter* addButtonParameter() { + m_activeButtonParameters.append(m_buttonParameters.size()); m_buttonParameters.append(EffectManifestParameter()); return &m_buttonParameters.last(); } @@ -113,6 +111,11 @@ class EffectManifest { QString m_description; QList m_parameters; QList m_buttonParameters; + + // These two lists store the mapping between the parameter slot and + // the effective parameter which is loaded onto the slot. + // When a manifest is created, this mapping is the identity + // function (list[i] = i) QList m_activeParameters; QList m_activeButtonParameters; }; From 727c5bf8911c20abad70a5991925e8d1a1bb8653 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Sun, 10 Aug 2014 12:13:44 +0300 Subject: [PATCH 23/36] Replace getParameter and getButtonParameter methods with getParameterForSlot and getButtonParameterForSlot --- src/effects/effect.cpp | 14 ++++++++++---- src/effects/effect.h | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/effects/effect.cpp b/src/effects/effect.cpp index ba7c514efed..7fb50ac6662 100644 --- a/src/effects/effect.cpp +++ b/src/effects/effect.cpp @@ -159,16 +159,22 @@ EffectParameter* Effect::getButtonParameterById(const QString& id) const { return pParameter; } -EffectParameter* Effect::getParameter(unsigned int parameterNumber) { +EffectParameter* Effect::getParameterForSlot(unsigned int slotNumber) { // It's normal to ask for a parameter that doesn't exist. Callers must check // for NULL. - return m_parameters.value(parameterNumber, NULL); + if (static_cast(m_parameters.size()) <= slotNumber) { + return NULL; + } + return m_parameters.value(m_manifest.getActiveParameter(slotNumber)); } -EffectParameter* Effect::getButtonParameter(unsigned int parameterNumber) { +EffectParameter* Effect::getButtonParameterForSlot(unsigned int slotNumber) { // It's normal to ask for a parameter that doesn't exist. Callers must check // for NULL. - return m_buttonParameters.value(parameterNumber, NULL); + if (static_cast(m_buttonParameters.size()) <= slotNumber) { + return NULL; + } + return m_buttonParameters.value(m_manifest.getActiveButtonParameter(slotNumber)); } QDomElement Effect::toXML(QDomDocument* doc) const { diff --git a/src/effects/effect.h b/src/effects/effect.h index 3184cfcba62..6400e2c1578 100644 --- a/src/effects/effect.h +++ b/src/effects/effect.h @@ -33,8 +33,8 @@ class Effect : public QObject { unsigned int numParameters() const; unsigned int numButtonParameters() const; - EffectParameter* getParameter(unsigned int parameterNumber); - EffectParameter* getButtonParameter(unsigned int parameterNumber); + EffectParameter* getParameterForSlot(unsigned int slotNumber); + EffectParameter* getButtonParameterForSlot(unsigned int slotNumber); EffectParameter* getParameterById(const QString& id) const; EffectParameter* getButtonParameterById(const QString& id) const; From a902f983334adc51ea98e81191feeabe33729ded Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Sun, 10 Aug 2014 12:14:31 +0300 Subject: [PATCH 24/36] Use the newly added methods for retrieving the appropriate EffectParameter inside loadEffect method --- src/effects/effectbuttonparameterslot.cpp | 2 +- src/effects/effectparameterslot.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/effects/effectbuttonparameterslot.cpp b/src/effects/effectbuttonparameterslot.cpp index 76206348436..d01f512b1d6 100644 --- a/src/effects/effectbuttonparameterslot.cpp +++ b/src/effects/effectbuttonparameterslot.cpp @@ -43,7 +43,7 @@ void EffectButtonParameterSlot::loadEffect(EffectPointer pEffect) { if (pEffect) { m_pEffect = pEffect; // Returns null if it doesn't have a parameter for that number - m_pEffectParameter = pEffect->getButtonParameter(pEffect->getManifest().getActiveButtonParameter(m_iParameterNumber)); + m_pEffectParameter = pEffect->getButtonParameterForSlot(m_iParameterNumber); if (m_pEffectParameter) { // Set the number of states diff --git a/src/effects/effectparameterslot.cpp b/src/effects/effectparameterslot.cpp index 70277358c91..c914796f7e7 100644 --- a/src/effects/effectparameterslot.cpp +++ b/src/effects/effectparameterslot.cpp @@ -59,7 +59,7 @@ void EffectParameterSlot::loadEffect(EffectPointer pEffect) { clear(); if (pEffect) { // Returns null if it doesn't have a parameter for that number - m_pEffectParameter = pEffect->getParameter(pEffect->getManifest().getActiveParameter(m_iParameterNumber)); + m_pEffectParameter = pEffect->getParameterForSlot(m_iParameterNumber); if (m_pEffectParameter) { //qDebug() << debugString() << "Loading effect parameter" << m_pEffectParameter->name(); From b836da6638216523bd8a6909dabd207dd32fc7e9 Mon Sep 17 00:00:00 2001 From: Nicu Badescu Date: Sun, 10 Aug 2014 13:08:37 +0300 Subject: [PATCH 25/36] Replace all occurrences of parameterNumber with parameterSlotNumber --- src/effects/effectbuttonparameterslot.cpp | 8 ++++---- src/effects/effectbuttonparameterslot.h | 8 ++++---- src/effects/effectparameterslot.cpp | 8 ++++---- src/effects/effectparameterslot.h | 8 ++++---- src/effects/effectparameterslotbase.cpp | 4 ++-- src/effects/effectparameterslotbase.h | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/effects/effectbuttonparameterslot.cpp b/src/effects/effectbuttonparameterslot.cpp index d01f512b1d6..b9db636a580 100644 --- a/src/effects/effectbuttonparameterslot.cpp +++ b/src/effects/effectbuttonparameterslot.cpp @@ -8,10 +8,10 @@ EffectButtonParameterSlot::EffectButtonParameterSlot(const unsigned int iRackNumber, const unsigned int iChainNumber, const unsigned int iSlotNumber, - const unsigned int iParameterNumber) + const unsigned int iParameterSlotNumber) : EffectParameterSlotBase(iRackNumber, iChainNumber, iSlotNumber, - iParameterNumber) { - QString itemPrefix = formatItemPrefix(iParameterNumber); + iParameterSlotNumber) { + QString itemPrefix = formatItemPrefix(iParameterSlotNumber); m_pControlLoaded = new ControlObject( ConfigKey(m_group, itemPrefix + QString("_loaded"))); m_pControlValue = new ControlPushButton( @@ -43,7 +43,7 @@ void EffectButtonParameterSlot::loadEffect(EffectPointer pEffect) { if (pEffect) { m_pEffect = pEffect; // Returns null if it doesn't have a parameter for that number - m_pEffectParameter = pEffect->getButtonParameterForSlot(m_iParameterNumber); + m_pEffectParameter = pEffect->getButtonParameterForSlot(m_iParameterSlotNumber); if (m_pEffectParameter) { // Set the number of states diff --git a/src/effects/effectbuttonparameterslot.h b/src/effects/effectbuttonparameterslot.h index d3f091e0468..b82231c2974 100644 --- a/src/effects/effectbuttonparameterslot.h +++ b/src/effects/effectbuttonparameterslot.h @@ -22,11 +22,11 @@ class EffectButtonParameterSlot : public EffectParameterSlotBase { EffectButtonParameterSlot(const unsigned int iRackNumber, const unsigned int iChainNumber, const unsigned int iSlotNumber, - const unsigned int iParameterNumber); + const unsigned int iParameterSlotNumber); virtual ~EffectButtonParameterSlot(); - static QString formatItemPrefix(const unsigned int iParameterNumber) { - return QString("button_parameter%1").arg(iParameterNumber + 1); + static QString formatItemPrefix(const unsigned int iParameterSlotNumber) { + return QString("button_parameter%1").arg(iParameterSlotNumber + 1); } // Load the parameter of the given effect into this EffectButtonParameterSlot @@ -39,7 +39,7 @@ class EffectButtonParameterSlot : public EffectParameterSlotBase { private: QString debugString() const { - return QString("EffectButtonParameterSlot(%1,%2)").arg(m_group).arg(m_iParameterNumber); + return QString("EffectButtonParameterSlot(%1,%2)").arg(m_group).arg(m_iParameterSlotNumber); } // Clear the currently loaded effect diff --git a/src/effects/effectparameterslot.cpp b/src/effects/effectparameterslot.cpp index c914796f7e7..308239ffd94 100644 --- a/src/effects/effectparameterslot.cpp +++ b/src/effects/effectparameterslot.cpp @@ -9,10 +9,10 @@ EffectParameterSlot::EffectParameterSlot(const unsigned int iRackNumber, const unsigned int iChainNumber, const unsigned int iSlotNumber, - const unsigned int iParameterNumber) + const unsigned int iParameterSlotNumber) : EffectParameterSlotBase(iRackNumber, iChainNumber, iSlotNumber, - iParameterNumber) { - QString itemPrefix = formatItemPrefix(iParameterNumber); + iParameterSlotNumber) { + QString itemPrefix = formatItemPrefix(iParameterSlotNumber); m_pControlLoaded = new ControlObject( ConfigKey(m_group, itemPrefix + QString("_loaded"))); m_pControlLinkType = new ControlPushButton( @@ -59,7 +59,7 @@ void EffectParameterSlot::loadEffect(EffectPointer pEffect) { clear(); if (pEffect) { // Returns null if it doesn't have a parameter for that number - m_pEffectParameter = pEffect->getParameterForSlot(m_iParameterNumber); + m_pEffectParameter = pEffect->getParameterForSlot(m_iParameterSlotNumber); if (m_pEffectParameter) { //qDebug() << debugString() << "Loading effect parameter" << m_pEffectParameter->name(); diff --git a/src/effects/effectparameterslot.h b/src/effects/effectparameterslot.h index 526a4f7d183..78bf36b4e8e 100644 --- a/src/effects/effectparameterslot.h +++ b/src/effects/effectparameterslot.h @@ -24,11 +24,11 @@ class EffectParameterSlot : public EffectParameterSlotBase { EffectParameterSlot(const unsigned int iRackNumber, const unsigned int iChainNumber, const unsigned int iSlotNumber, - const unsigned int iParameterNumber); + const unsigned int iParameterSlotNumber); virtual ~EffectParameterSlot(); - static QString formatItemPrefix(const unsigned int iParameterNumber) { - return QString("parameter%1").arg(iParameterNumber + 1); + static QString formatItemPrefix(const unsigned int iParameterSlotNumber) { + return QString("parameter%1").arg(iParameterSlotNumber + 1); } // Load the parameter of the given effect into this EffectParameterSlot @@ -52,7 +52,7 @@ class EffectParameterSlot : public EffectParameterSlotBase { private: QString debugString() const { - return QString("EffectParameterSlot(%1,%2)").arg(m_group).arg(m_iParameterNumber); + return QString("EffectParameterSlot(%1,%2)").arg(m_group).arg(m_iParameterSlotNumber); } // Clear the currently loaded effect diff --git a/src/effects/effectparameterslotbase.cpp b/src/effects/effectparameterslotbase.cpp index 0416832ed2e..4a660bff03b 100644 --- a/src/effects/effectparameterslotbase.cpp +++ b/src/effects/effectparameterslotbase.cpp @@ -8,11 +8,11 @@ EffectParameterSlotBase::EffectParameterSlotBase(const unsigned int iRackNumber, const unsigned int iChainNumber, const unsigned int iSlotNumber, - const unsigned int iParameterNumber) + const unsigned int iParameterSlotNumber) : m_iRackNumber(iRackNumber), m_iChainNumber(iChainNumber), m_iSlotNumber(iSlotNumber), - m_iParameterNumber(iParameterNumber), + m_iParameterSlotNumber(iParameterSlotNumber), m_group(formatGroupString(m_iRackNumber, m_iChainNumber, m_iSlotNumber)), m_pEffectParameter(NULL), diff --git a/src/effects/effectparameterslotbase.h b/src/effects/effectparameterslotbase.h index 1e62dd6547b..06454e784ee 100644 --- a/src/effects/effectparameterslotbase.h +++ b/src/effects/effectparameterslotbase.h @@ -21,7 +21,7 @@ class EffectParameterSlotBase : public QObject { EffectParameterSlotBase(const unsigned int iRackNumber, const unsigned int iChainNumber, const unsigned int iSlotNumber, - const unsigned int iParameterNumber); + const unsigned int iParameterSlotNumber); virtual ~EffectParameterSlotBase(); static QString formatGroupString(const unsigned int iRackNumber, @@ -50,7 +50,7 @@ class EffectParameterSlotBase : public QObject { const unsigned int m_iRackNumber; const unsigned int m_iChainNumber; const unsigned int m_iSlotNumber; - const unsigned int m_iParameterNumber; + const unsigned int m_iParameterSlotNumber; QString m_group; EffectPointer m_pEffect; EffectParameter* m_pEffectParameter; From a4121f161d6ce2b40b670b7009ddd99f5965767a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 12 Oct 2014 00:31:41 +0200 Subject: [PATCH 26/36] renamed helper to toXXX to match function names elsewhere --- src/engine/effects/engineeffectparameter.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/effects/engineeffectparameter.h b/src/engine/effects/engineeffectparameter.h index 26a1708dc87..08b79ff7090 100644 --- a/src/engine/effects/engineeffectparameter.h +++ b/src/engine/effects/engineeffectparameter.h @@ -48,11 +48,11 @@ class EngineEffectParameter { inline void setValue(const double value) { m_value = value; } - inline int intValue() const { + inline int toInt() const { return (int)m_value; } - inline int boolValue() const { - return m_value > 0; + inline int toBool() const { + return m_value > 0.0; } inline double defaultValue() const { From 957a283fc8ce84565b246218999f0a0f3b8fd10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 12 Oct 2014 01:51:50 +0200 Subject: [PATCH 27/36] Renamed m_enumerationOptions to m_steps, Introduced two new ControlHint using these steps --- src/effects/effectbuttonparameterslot.cpp | 3 ++- src/effects/effectmanifestparameter.h | 22 ++++++++++++------- src/effects/native/bessel4lvmixeqeffect.cpp | 6 ++--- src/effects/native/bessel8lvmixeqeffect.cpp | 6 ++--- src/effects/native/linkwitzriley8eqeffect.cpp | 6 ++--- src/widget/weffectpushbutton.cpp | 2 +- 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/effects/effectbuttonparameterslot.cpp b/src/effects/effectbuttonparameterslot.cpp index b5f76fbc53d..1af83765a78 100644 --- a/src/effects/effectbuttonparameterslot.cpp +++ b/src/effects/effectbuttonparameterslot.cpp @@ -4,6 +4,7 @@ #include "effects/effectbuttonparameterslot.h" #include "controlobject.h" #include "controlpushbutton.h" +#include "util/math.h" EffectButtonParameterSlot::EffectButtonParameterSlot(const unsigned int iRackNumber, const unsigned int iChainNumber, @@ -47,7 +48,7 @@ void EffectButtonParameterSlot::loadEffect(EffectPointer pEffect) { if (m_pEffectParameter) { // Set the number of states - int numStates = m_pEffectParameter->manifest().getOptions().size(); + int numStates = math_max(m_pEffectParameter->manifest().getSteps().size(), 2); m_pControlValue->setStates(numStates); //qDebug() << debugString() << "Loading effect parameter" << m_pEffectParameter->name(); double dValue = m_pEffectParameter->getValue(); diff --git a/src/effects/effectmanifestparameter.h b/src/effects/effectmanifestparameter.h index 0562b9ff7a8..554a9a57b71 100644 --- a/src/effects/effectmanifestparameter.h +++ b/src/effects/effectmanifestparameter.h @@ -11,7 +11,10 @@ class EffectManifestParameter { CONTROL_UNKNOWN = 0, CONTROL_KNOB_LINEAR, CONTROL_KNOB_LOGARITHMIC, - CONTROL_TOGGLE + CONTROL_KNOB_STEPPING, // A step rotary, steps given by m_steps + // are arranged with equal distance on scale + CONTROL_TOGGLE_STEPPING // For button and enum controls, not accessible + // form many controllers, no linking to super knob }; enum SemanticHint { @@ -149,11 +152,11 @@ class EffectManifestParameter { m_maximum = maximum; } - virtual void insertOption(QPair option) { - m_enumerationOptions.append(option); + virtual void appendStep(const QPair& step) { + m_steps.append(step); } - virtual QList > getOptions() const { - return m_enumerationOptions; + virtual const QList >& getSteps() const { + return m_steps; } private: @@ -175,9 +178,12 @@ class EffectManifestParameter { double m_minimum; double m_maximum; - // Useful data for enumeration parameters; each pair has the following form: - // description - value - QList > m_enumerationOptions; + // Used to describe steps of + // CONTROL_KNOB_STEPPING and CONTROL_TOGGLE_STEPPING + // effect parameters + // Each pair has the following form: + // name - value + QList > m_steps; }; diff --git a/src/effects/native/bessel4lvmixeqeffect.cpp b/src/effects/native/bessel4lvmixeqeffect.cpp index decd271b886..483ad128056 100644 --- a/src/effects/native/bessel4lvmixeqeffect.cpp +++ b/src/effects/native/bessel4lvmixeqeffect.cpp @@ -33,7 +33,7 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { killLow->setId("killLow"); killLow->setName(QObject::tr("Kill Low")); killLow->setDescription(QObject::tr("Kill the Low Filter")); - killLow->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killLow->setControlHint(EffectManifestParameter::CONTROL_TOGGLE_STEPPING); killLow->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); killLow->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); killLow->setDefault(0); @@ -56,7 +56,7 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { killMid->setId("killMid"); killMid->setName(QObject::tr("Kill Mid")); killMid->setDescription(QObject::tr("Kill the Mid Filter")); - killMid->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killMid->setControlHint(EffectManifestParameter::CONTROL_TOGGLE_STEPPING); killMid->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); killMid->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); killMid->setDefault(0); @@ -79,7 +79,7 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { killHigh->setId("killHigh"); killHigh->setName(QObject::tr("Kill High")); killHigh->setDescription(QObject::tr("Kill the High Filter")); - killHigh->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killHigh->setControlHint(EffectManifestParameter::CONTROL_TOGGLE_STEPPING); killHigh->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); killHigh->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); killHigh->setDefault(0); diff --git a/src/effects/native/bessel8lvmixeqeffect.cpp b/src/effects/native/bessel8lvmixeqeffect.cpp index f080178d1bb..b4ed642ae81 100644 --- a/src/effects/native/bessel8lvmixeqeffect.cpp +++ b/src/effects/native/bessel8lvmixeqeffect.cpp @@ -40,7 +40,7 @@ EffectManifest Bessel8LVMixEQEffect::getManifest() { killLow->setId("killLow"); killLow->setName(QObject::tr("Kill Low")); killLow->setDescription(QObject::tr("Kill the Low Filter")); - killLow->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killLow->setControlHint(EffectManifestParameter::CONTROL_TOGGLE_STEPPING); killLow->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); killLow->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); killLow->setDefault(0); @@ -63,7 +63,7 @@ EffectManifest Bessel8LVMixEQEffect::getManifest() { killMid->setId("killMid"); killMid->setName(QObject::tr("Kill Mid")); killMid->setDescription(QObject::tr("Kill the Mid Filter")); - killMid->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killMid->setControlHint(EffectManifestParameter::CONTROL_TOGGLE_STEPPING); killMid->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); killMid->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); killMid->setDefault(0); @@ -86,7 +86,7 @@ EffectManifest Bessel8LVMixEQEffect::getManifest() { killHigh->setId("killHigh"); killHigh->setName(QObject::tr("Kill High")); killHigh->setDescription(QObject::tr("Kill the High Filter")); - killHigh->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killHigh->setControlHint(EffectManifestParameter::CONTROL_TOGGLE_STEPPING); killHigh->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); killHigh->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); killHigh->setDefault(0); diff --git a/src/effects/native/linkwitzriley8eqeffect.cpp b/src/effects/native/linkwitzriley8eqeffect.cpp index cc0d896924d..8b40e97c2d5 100644 --- a/src/effects/native/linkwitzriley8eqeffect.cpp +++ b/src/effects/native/linkwitzriley8eqeffect.cpp @@ -37,7 +37,7 @@ EffectManifest LinkwitzRiley8EQEffect::getManifest() { killLow->setId("killLow"); killLow->setName(QObject::tr("Kill Low")); killLow->setDescription(QObject::tr("Kill the Low Filter")); - killLow->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killLow->setControlHint(EffectManifestParameter::CONTROL_TOGGLE_STEPPING); killLow->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); killLow->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); killLow->setDefault(0); @@ -60,7 +60,7 @@ EffectManifest LinkwitzRiley8EQEffect::getManifest() { killMid->setId("killMid"); killMid->setName(QObject::tr("Kill Mid")); killMid->setDescription(QObject::tr("Kill the Mid Filter")); - killMid->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killMid->setControlHint(EffectManifestParameter::CONTROL_TOGGLE_STEPPING); killMid->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); killMid->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); killMid->setDefault(0); @@ -83,7 +83,7 @@ EffectManifest LinkwitzRiley8EQEffect::getManifest() { killHigh->setId("killHigh"); killHigh->setName(QObject::tr("Kill High")); killHigh->setDescription(QObject::tr("Kill the High Filter")); - killHigh->setControlHint(EffectManifestParameter::CONTROL_TOGGLE); + killHigh->setControlHint(EffectManifestParameter::CONTROL_TOGGLE_STEPPING); killHigh->setSemanticHint(EffectManifestParameter::SEMANTIC_UNKNOWN); killHigh->setUnitsHint(EffectManifestParameter::UNITS_UNKNOWN); killHigh->setDefault(0); diff --git a/src/widget/weffectpushbutton.cpp b/src/widget/weffectpushbutton.cpp index 975041c9160..b1a4bdc649c 100644 --- a/src/widget/weffectpushbutton.cpp +++ b/src/widget/weffectpushbutton.cpp @@ -478,7 +478,7 @@ void WEffectPushButton::fillDebugTooltip(QStringList* debug) { void WEffectPushButton::parameterUpdated() { m_pButtonMenu->clear(); - QList > options = m_pEffectParameterSlot->getManifest().getOptions(); + const QList >& options = m_pEffectParameterSlot->getManifest().getSteps(); qDebug() << " HERE IS THE OPTIONS SIZE: " << options.size(); QActionGroup* actionGroup = new QActionGroup(m_pButtonMenu); actionGroup->setExclusive(true); From 18208e7f134284a4f26dd2246c687c9006a833f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 12 Oct 2014 02:57:51 +0200 Subject: [PATCH 28/36] Merge list of EffectButtonParameters to EffectParameters, assigne controlls on the fly --- src/effects/effect.cpp | 93 +++++++------------ src/effects/effect.h | 6 +- src/effects/effectbuttonparameterslot.cpp | 3 +- src/effects/effectmanifest.h | 20 ---- src/effects/effectparameter.cpp | 8 +- src/effects/effectparameter.h | 7 +- src/effects/effectparameterslot.cpp | 2 +- src/effects/effectslot.cpp | 4 +- src/effects/native/bessel4lvmixeqeffect.cpp | 12 +-- src/effects/native/bessel8lvmixeqeffect.cpp | 12 +-- src/effects/native/linkwitzriley8eqeffect.cpp | 12 +-- src/engine/effects/engineeffect.cpp | 42 +-------- src/engine/effects/engineeffect.h | 6 -- src/engine/effects/engineeffectsmanager.cpp | 1 - src/engine/effects/message.h | 1 - 15 files changed, 66 insertions(+), 163 deletions(-) diff --git a/src/effects/effect.cpp b/src/effects/effect.cpp index 2a97ed70215..ee3e07702d7 100644 --- a/src/effects/effect.cpp +++ b/src/effects/effect.cpp @@ -27,16 +27,6 @@ Effect::Effect(QObject* pParent, EffectsManager* pEffectsManager, } m_parametersById[parameter.id()] = pParameter; } - - foreach (const EffectManifestParameter& parameter, m_manifest.buttonParameters()) { - EffectParameter* pParameter = new EffectParameter( - this, pEffectsManager, m_buttonParameters.size(), parameter); - m_buttonParameters.append(pParameter); - if (m_buttonParametersById.contains(parameter.id())) { - qWarning() << debugString() << "WARNING: Loaded EffectManifest that had parameters with duplicate IDs. Dropping one of them."; - } - m_buttonParametersById[parameter.id()] = pParameter; - } } Effect::~Effect() { @@ -47,11 +37,6 @@ Effect::~Effect() { m_parameters[i] = NULL; delete pParameter; } - for (int i = 0; i < m_buttonParameters.size(); ++i) { - EffectParameter* pParameter = m_buttonParameters.at(i); - m_buttonParameters[i] = NULL; - delete pParameter; - } } void Effect::addToEngine(EngineEffectChain* pChain, int iIndex) { @@ -65,10 +50,6 @@ void Effect::addToEngine(EngineEffectChain* pChain, int iIndex) { foreach (EffectParameter* pParameter, m_parameters) { pParameter->addToEngine(); } - - foreach (EffectParameter* pParameter, m_buttonParameters) { - pParameter->addToEngine(); - } } void Effect::removeFromEngine(EngineEffectChain* pChain, int iIndex) { @@ -82,10 +63,6 @@ void Effect::removeFromEngine(EngineEffectChain* pChain, int iIndex) { foreach (EffectParameter* pParameter, m_parameters) { pParameter->removeFromEngine(); } - - foreach (EffectParameter* pParameter, m_buttonParameters) { - pParameter->removeFromEngine(); - } } void Effect::updateEngineState() { @@ -96,10 +73,6 @@ void Effect::updateEngineState() { foreach (EffectParameter* pParameter, m_parameters) { pParameter->updateEngineState(); } - - foreach (EffectParameter* pParameter, m_buttonParameters) { - pParameter->updateEngineState(); - } } EngineEffect* Effect::getEngineEffect() { @@ -133,12 +106,24 @@ void Effect::sendParameterUpdate() { m_pEffectsManager->writeRequest(pRequest); } -unsigned int Effect::numParameters() const { - return m_parameters.size(); +unsigned int Effect::numKnobParameters() const { + unsigned int num = 0; + foreach(const EffectParameter* parameter, m_parameters) { + if (parameter->manifest().controlHint() != EffectManifestParameter::CONTROL_TOGGLE_STEPPING) { + ++num; + } + } + return num; } unsigned int Effect::numButtonParameters() const { - return m_buttonParameters.size(); + unsigned int num = 0; + foreach(const EffectParameter* parameter, m_parameters) { + if (parameter->manifest().controlHint() == EffectManifestParameter::CONTROL_TOGGLE_STEPPING) { + ++num; + } + } + return num; } EffectParameter* Effect::getParameterById(const QString& id) const { @@ -150,31 +135,34 @@ EffectParameter* Effect::getParameterById(const QString& id) const { return pParameter; } -EffectParameter* Effect::getButtonParameterById(const QString& id) const { - EffectParameter* pParameter = m_buttonParametersById.value(id, NULL); - if (pParameter == NULL) { - qWarning() << debugString() << "getParameterById" - << "WARNING: parameter for id does not exist:" << id; - } - return pParameter; -} - -EffectParameter* Effect::getParameterForSlot(unsigned int slotNumber) { +EffectParameter* Effect::getKnobParameterForSlot(unsigned int slotNumber) { // It's normal to ask for a parameter that doesn't exist. Callers must check // for NULL. - if (static_cast(m_parameters.size()) <= slotNumber) { - return NULL; + unsigned int num = 0; + foreach(EffectParameter* parameter, m_parameters) { + if (parameter->manifest().controlHint() != EffectManifestParameter::CONTROL_TOGGLE_STEPPING) { + if(num == slotNumber) { + return parameter; + } + ++num; + } } - return m_parameters.value(m_manifest.getActiveParameter(slotNumber)); + return NULL; } EffectParameter* Effect::getButtonParameterForSlot(unsigned int slotNumber) { // It's normal to ask for a parameter that doesn't exist. Callers must check // for NULL. - if (static_cast(m_buttonParameters.size()) <= slotNumber) { - return NULL; + unsigned int num = 0; + foreach(EffectParameter* parameter, m_parameters) { + if (parameter->manifest().controlHint() == EffectManifestParameter::CONTROL_TOGGLE_STEPPING) { + if(num == slotNumber) { + return parameter; + } + ++num; + } } - return m_buttonParameters.value(m_manifest.getActiveButtonParameter(slotNumber)); + return NULL; } QDomElement Effect::toXML(QDomDocument* doc) const { @@ -195,19 +183,6 @@ QDomElement Effect::toXML(QDomDocument* doc) const { } element.appendChild(parameters); - QDomElement buttonParameters = doc->createElement("ButtonParameters"); - foreach (EffectParameter* pParameter, m_buttonParameters) { - const EffectManifestParameter& parameterManifest = - pParameter->manifest(); - QDomElement parameter = doc->createElement("ButtonParameter"); - XmlParse::addElement(*doc, parameter, "Id", parameterManifest.id()); - // TODO(rryan): Do smarter QVariant formatting? - XmlParse::addElement(*doc, parameter, "Value", QString::number(pParameter->getValue())); - // TODO(rryan): Output link state, etc. - buttonParameters.appendChild(parameter); - } - element.appendChild(buttonParameters); - return element; } diff --git a/src/effects/effect.h b/src/effects/effect.h index 6400e2c1578..ba257765f8d 100644 --- a/src/effects/effect.h +++ b/src/effects/effect.h @@ -31,9 +31,9 @@ class Effect : public QObject { const EffectManifest& getManifest() const; - unsigned int numParameters() const; + unsigned int numKnobParameters() const; unsigned int numButtonParameters() const; - EffectParameter* getParameterForSlot(unsigned int slotNumber); + EffectParameter* getKnobParameterForSlot(unsigned int slotNumber); EffectParameter* getButtonParameterForSlot(unsigned int slotNumber); EffectParameter* getParameterById(const QString& id) const; EffectParameter* getButtonParameterById(const QString& id) const; @@ -68,8 +68,6 @@ class Effect : public QObject { bool m_bEnabled; QList m_parameters; QMap m_parametersById; - QList m_buttonParameters; - QMap m_buttonParametersById; DISALLOW_COPY_AND_ASSIGN(Effect); }; diff --git a/src/effects/effectbuttonparameterslot.cpp b/src/effects/effectbuttonparameterslot.cpp index 1af83765a78..4b07e215a3d 100644 --- a/src/effects/effectbuttonparameterslot.cpp +++ b/src/effects/effectbuttonparameterslot.cpp @@ -105,7 +105,6 @@ void EffectButtonParameterSlot::slotParameterValueChanged(double value) { void EffectButtonParameterSlot::slotValueChanged(double v) { if (m_pEffectParameter) { - // Call setValue with type 11 (SET_PARAMETER_BUTTON_PARAMETERS) - m_pEffectParameter->setValue(v, 11); + m_pEffectParameter->setValue(v); } } diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index 93d90ad28fd..b01b0264b25 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -73,16 +73,6 @@ class EffectManifest { return &m_parameters.last(); } - virtual const QList& buttonParameters() const { - return m_buttonParameters; - } - - virtual EffectManifestParameter* addButtonParameter() { - m_activeButtonParameters.append(m_buttonParameters.size()); - m_buttonParameters.append(EffectManifestParameter()); - return &m_buttonParameters.last(); - } - virtual void setActiveParameter(int index, unsigned int value) { m_activeParameters[index] = value; } @@ -91,14 +81,6 @@ class EffectManifest { return m_activeParameters[index]; } - virtual void setActiveButtonParameter(int index, unsigned int value) { - m_activeButtonParameters[index] = value; - } - - virtual unsigned int getActiveButtonParameter(int index) const { - return m_activeButtonParameters[index]; - } - private: QString debugString() const { return QString("EffectManifest(%1)").arg(m_id); @@ -110,14 +92,12 @@ class EffectManifest { QString m_version; QString m_description; QList m_parameters; - QList m_buttonParameters; // These two lists store the mapping between the parameter slot and // the effective parameter which is loaded onto the slot. // When a manifest is created, this mapping is the identity // function (list[i] = i) QList m_activeParameters; - QList m_activeButtonParameters; }; #endif /* EFFECTMANIFEST_H */ diff --git a/src/effects/effectparameter.cpp b/src/effects/effectparameter.cpp index 5adf67a006d..f3de06a72b0 100644 --- a/src/effects/effectparameter.cpp +++ b/src/effects/effectparameter.cpp @@ -95,7 +95,7 @@ double EffectParameter::getValue() const { return m_value; } -void EffectParameter::setValue(double value, int type) { +void EffectParameter::setValue(double value) { // TODO(XXX) Handle inf, -inf, and nan m_value = value; @@ -105,7 +105,7 @@ void EffectParameter::setValue(double value, int type) { m_value = value; - updateEngineState(type); + updateEngineState(); emit(valueChanged(m_value)); } @@ -202,12 +202,12 @@ void EffectParameter::removeFromEngine() { m_bAddedToEngine = false; } -void EffectParameter::updateEngineState(int type) { +void EffectParameter::updateEngineState() { if (!m_bAddedToEngine) { return; } EffectsRequest* pRequest = new EffectsRequest(); - pRequest->type = static_cast(type); + pRequest->type = EffectsRequest::SET_PARAMETER_PARAMETERS; pRequest->pTargetEffect = m_pEffect->getEngineEffect(); pRequest->SetParameterParameters.iParameter = m_iParameterNumber; pRequest->value = m_value; diff --git a/src/effects/effectparameter.h b/src/effects/effectparameter.h index ab33eb3dc88..563cf0f0354 100644 --- a/src/effects/effectparameter.h +++ b/src/effects/effectparameter.h @@ -42,8 +42,8 @@ class EffectParameter : public QObject { double getNeutralPointOnScale() const; double getValue() const; - // Default type is EffectsRequest::SET_PARAMETER_PARAMETERS - void setValue(double value, int type = 10); + + void setValue(double value); double getDefault() const; void setDefault(double defaultValue); @@ -56,8 +56,7 @@ class EffectParameter : public QObject { EffectManifestParameter::ControlHint getControlHint() const; - // Default type is EffectsRequest::SET_PARAMETER_PARAMETERS - void updateEngineState(int type = 10); + void updateEngineState(); signals: void valueChanged(double value); diff --git a/src/effects/effectparameterslot.cpp b/src/effects/effectparameterslot.cpp index 26aca2c1014..e59f7216308 100644 --- a/src/effects/effectparameterslot.cpp +++ b/src/effects/effectparameterslot.cpp @@ -59,7 +59,7 @@ void EffectParameterSlot::loadEffect(EffectPointer pEffect) { clear(); if (pEffect) { // Returns null if it doesn't have a parameter for that number - m_pEffectParameter = pEffect->getParameterForSlot(m_iParameterSlotNumber); + m_pEffectParameter = pEffect->getKnobParameterForSlot(m_iParameterSlotNumber); if (m_pEffectParameter) { //qDebug() << debugString() << "Loading effect parameter" << m_pEffectParameter->name(); diff --git a/src/effects/effectslot.cpp b/src/effects/effectslot.cpp index 962aa061dd6..344845a0135 100644 --- a/src/effects/effectslot.cpp +++ b/src/effects/effectslot.cpp @@ -176,7 +176,7 @@ void EffectSlot::loadEffect(EffectPointer pEffect) { if (pEffect) { m_pEffect = pEffect; m_pControlLoaded->setAndConfirm(1.0); - m_pControlNumParameters->setAndConfirm(m_pEffect->numParameters()); + m_pControlNumParameters->setAndConfirm(m_pEffect->numKnobParameters()); m_pControlNumButtonParameters->setAndConfirm(m_pEffect->numButtonParameters()); // Enabled is a persistent property of the effect slot, not of the @@ -186,7 +186,7 @@ void EffectSlot::loadEffect(EffectPointer pEffect) { connect(m_pEffect.data(), SIGNAL(enabledChanged(bool)), this, SLOT(slotEffectEnabledChanged(bool))); - while (static_cast(m_parameters.size()) < m_pEffect->numParameters()) { + while (static_cast(m_parameters.size()) < m_pEffect->numKnobParameters()) { addEffectParameterSlot(); } diff --git a/src/effects/native/bessel4lvmixeqeffect.cpp b/src/effects/native/bessel4lvmixeqeffect.cpp index 483ad128056..6b8c45cd8ef 100644 --- a/src/effects/native/bessel4lvmixeqeffect.cpp +++ b/src/effects/native/bessel4lvmixeqeffect.cpp @@ -29,7 +29,7 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { low->setMinimum(0); low->setMaximum(4.0); - EffectManifestParameter* killLow = manifest.addButtonParameter(); + EffectManifestParameter* killLow = manifest.addParameter(); killLow->setId("killLow"); killLow->setName(QObject::tr("Kill Low")); killLow->setDescription(QObject::tr("Kill the Low Filter")); @@ -52,7 +52,7 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { mid->setMinimum(0); mid->setMaximum(4.0); - EffectManifestParameter* killMid = manifest.addButtonParameter(); + EffectManifestParameter* killMid = manifest.addParameter(); killMid->setId("killMid"); killMid->setName(QObject::tr("Kill Mid")); killMid->setDescription(QObject::tr("Kill the Mid Filter")); @@ -75,7 +75,7 @@ EffectManifest Bessel4LVMixEQEffect::getManifest() { high->setMinimum(0); high->setMaximum(4.0); - EffectManifestParameter* killHigh = manifest.addButtonParameter(); + EffectManifestParameter* killHigh = manifest.addParameter(); killHigh->setId("killHigh"); killHigh->setName(QObject::tr("Kill High")); killHigh->setDescription(QObject::tr("Kill the High Filter")); @@ -94,9 +94,9 @@ Bessel4LVMixEQEffect::Bessel4LVMixEQEffect(EngineEffect* pEffect, : m_pPotLow(pEffect->getParameterById("low")), m_pPotMid(pEffect->getParameterById("mid")), m_pPotHigh(pEffect->getParameterById("high")), - m_pKillLow(pEffect->getButtonParameterById("killLow")), - m_pKillMid(pEffect->getButtonParameterById("killMid")), - m_pKillHigh(pEffect->getButtonParameterById("killHigh")) { + m_pKillLow(pEffect->getParameterById("killLow")), + m_pKillMid(pEffect->getParameterById("killMid")), + m_pKillHigh(pEffect->getParameterById("killHigh")) { Q_UNUSED(manifest); m_pLoFreqCorner = new ControlObjectSlave("[Mixer Profile]", "LoEQFrequency"); m_pHiFreqCorner = new ControlObjectSlave("[Mixer Profile]", "HiEQFrequency"); diff --git a/src/effects/native/bessel8lvmixeqeffect.cpp b/src/effects/native/bessel8lvmixeqeffect.cpp index b4ed642ae81..1f4258c4afd 100644 --- a/src/effects/native/bessel8lvmixeqeffect.cpp +++ b/src/effects/native/bessel8lvmixeqeffect.cpp @@ -36,7 +36,7 @@ EffectManifest Bessel8LVMixEQEffect::getManifest() { low->setMinimum(0); low->setMaximum(4.0); - EffectManifestParameter* killLow = manifest.addButtonParameter(); + EffectManifestParameter* killLow = manifest.addParameter(); killLow->setId("killLow"); killLow->setName(QObject::tr("Kill Low")); killLow->setDescription(QObject::tr("Kill the Low Filter")); @@ -59,7 +59,7 @@ EffectManifest Bessel8LVMixEQEffect::getManifest() { mid->setMinimum(0); mid->setMaximum(4.0); - EffectManifestParameter* killMid = manifest.addButtonParameter(); + EffectManifestParameter* killMid = manifest.addParameter(); killMid->setId("killMid"); killMid->setName(QObject::tr("Kill Mid")); killMid->setDescription(QObject::tr("Kill the Mid Filter")); @@ -82,7 +82,7 @@ EffectManifest Bessel8LVMixEQEffect::getManifest() { high->setMinimum(0); high->setMaximum(4.0); - EffectManifestParameter* killHigh = manifest.addButtonParameter(); + EffectManifestParameter* killHigh = manifest.addParameter(); killHigh->setId("killHigh"); killHigh->setName(QObject::tr("Kill High")); killHigh->setDescription(QObject::tr("Kill the High Filter")); @@ -101,9 +101,9 @@ Bessel8LVMixEQEffect::Bessel8LVMixEQEffect(EngineEffect* pEffect, : m_pPotLow(pEffect->getParameterById("low")), m_pPotMid(pEffect->getParameterById("mid")), m_pPotHigh(pEffect->getParameterById("high")), - m_pKillLow(pEffect->getButtonParameterById("killLow")), - m_pKillMid(pEffect->getButtonParameterById("killMid")), - m_pKillHigh(pEffect->getButtonParameterById("killHigh")) { + m_pKillLow(pEffect->getParameterById("killLow")), + m_pKillMid(pEffect->getParameterById("killMid")), + m_pKillHigh(pEffect->getParameterById("killHigh")) { Q_UNUSED(manifest); m_pLoFreqCorner = new ControlObjectSlave("[Mixer Profile]", "LoEQFrequency"); m_pHiFreqCorner = new ControlObjectSlave("[Mixer Profile]", "HiEQFrequency"); diff --git a/src/effects/native/linkwitzriley8eqeffect.cpp b/src/effects/native/linkwitzriley8eqeffect.cpp index 8b40e97c2d5..284b1b59b48 100644 --- a/src/effects/native/linkwitzriley8eqeffect.cpp +++ b/src/effects/native/linkwitzriley8eqeffect.cpp @@ -33,7 +33,7 @@ EffectManifest LinkwitzRiley8EQEffect::getManifest() { low->setMinimum(0); low->setMaximum(4.0); - EffectManifestParameter* killLow = manifest.addButtonParameter(); + EffectManifestParameter* killLow = manifest.addParameter(); killLow->setId("killLow"); killLow->setName(QObject::tr("Kill Low")); killLow->setDescription(QObject::tr("Kill the Low Filter")); @@ -56,7 +56,7 @@ EffectManifest LinkwitzRiley8EQEffect::getManifest() { mid->setMinimum(0); mid->setMaximum(4.0); - EffectManifestParameter* killMid = manifest.addButtonParameter(); + EffectManifestParameter* killMid = manifest.addParameter(); killMid->setId("killMid"); killMid->setName(QObject::tr("Kill Mid")); killMid->setDescription(QObject::tr("Kill the Mid Filter")); @@ -79,7 +79,7 @@ EffectManifest LinkwitzRiley8EQEffect::getManifest() { high->setMinimum(0); high->setMaximum(4.0); - EffectManifestParameter* killHigh = manifest.addButtonParameter(); + EffectManifestParameter* killHigh = manifest.addParameter(); killHigh->setId("killHigh"); killHigh->setName(QObject::tr("Kill High")); killHigh->setDescription(QObject::tr("Kill the High Filter")); @@ -134,9 +134,9 @@ LinkwitzRiley8EQEffect::LinkwitzRiley8EQEffect(EngineEffect* pEffect, : m_pPotLow(pEffect->getParameterById("low")), m_pPotMid(pEffect->getParameterById("mid")), m_pPotHigh(pEffect->getParameterById("high")), - m_pKillLow(pEffect->getButtonParameterById("killLow")), - m_pKillMid(pEffect->getButtonParameterById("killMid")), - m_pKillHigh(pEffect->getButtonParameterById("killHigh")) { + m_pKillLow(pEffect->getParameterById("killLow")), + m_pKillMid(pEffect->getParameterById("killMid")), + m_pKillHigh(pEffect->getParameterById("killHigh")) { Q_UNUSED(manifest); m_pLoFreqCorner = new ControlObjectSlave("[Mixer Profile]", "LoEQFrequency"); m_pHiFreqCorner = new ControlObjectSlave("[Mixer Profile]", "HiEQFrequency"); diff --git a/src/engine/effects/engineeffect.cpp b/src/engine/effects/engineeffect.cpp index 34713f84dc8..84396a0ab61 100644 --- a/src/engine/effects/engineeffect.cpp +++ b/src/engine/effects/engineeffect.cpp @@ -5,8 +5,7 @@ EngineEffect::EngineEffect(const EffectManifest& manifest, EffectInstantiatorPointer pInstantiator) : m_manifest(manifest), m_bEnabled(true), - m_parameters(manifest.parameters().size()), - m_buttonParameters(manifest.buttonParameters().size()) { + m_parameters(manifest.parameters().size()) { const QList& parameters = m_manifest.parameters(); for (int i = 0; i < parameters.size(); ++i) { const EffectManifestParameter& parameter = parameters.at(i); @@ -16,16 +15,6 @@ EngineEffect::EngineEffect(const EffectManifest& manifest, m_parametersById[parameter.id()] = pParameter; } - const QList& buttonParameters = - m_manifest.buttonParameters(); - for (int i = 0; i < buttonParameters.size(); ++i) { - const EffectManifestParameter& parameter = buttonParameters.at(i); - EngineEffectParameter* pParameter = - new EngineEffectParameter(parameter); - m_buttonParameters[i] = pParameter; - m_buttonParametersById[parameter.id()] = pParameter; - } - // Creating the processor must come last. m_pProcessor = pInstantiator->instantiate(this, manifest); m_pProcessor->initialize(registeredGroups); @@ -42,12 +31,6 @@ EngineEffect::~EngineEffect() { m_parameters[i] = NULL; delete pParameter; } - m_buttonParametersById.clear(); - for (int i = 0; i < m_buttonParameters.size(); ++i) { - EngineEffectParameter* pParameter = m_buttonParameters.at(i); - m_buttonParameters[i] = NULL; - delete pParameter; - } } bool EngineEffect::processEffectsRequest(const EffectsRequest& message, @@ -89,29 +72,6 @@ bool EngineEffect::processEffectsRequest(const EffectsRequest& message, } pResponsePipe->writeMessages(&response, 1); return true; - case EffectsRequest::SET_PARAMETER_BUTTON_PARAMETERS: - if (kEffectDebugOutput) { - qDebug() << debugString() << "SET_BUTTON_PARAMETER_PARAMETERS" - << "parameter" << message.SetParameterParameters.iParameter - << "minimum" << message.minimum - << "maximum" << message.maximum - << "default_value" << message.default_value - << "value" << message.value; - } - pParameter = m_buttonParameters.value( - message.SetParameterParameters.iParameter, NULL); - if (pParameter) { - pParameter->setMinimum(message.minimum); - pParameter->setMaximum(message.maximum); - pParameter->setDefaultValue(message.default_value); - pParameter->setValue(message.value); - response.success = true; - } else { - response.success = false; - response.status = EffectsResponse::NO_SUCH_PARAMETER; - } - pResponsePipe->writeMessages(&response, 1); - return true; default: break; } diff --git a/src/engine/effects/engineeffect.h b/src/engine/effects/engineeffect.h index a41c5836d0e..f17b0e615ec 100644 --- a/src/engine/effects/engineeffect.h +++ b/src/engine/effects/engineeffect.h @@ -30,10 +30,6 @@ class EngineEffect : public EffectsRequestHandler { return m_parametersById.value(id, NULL); } - EngineEffectParameter* getButtonParameterById(const QString& id) { - return m_buttonParametersById.value(id, NULL); - } - bool processEffectsRequest( const EffectsRequest& message, EffectsResponsePipe* pResponsePipe); @@ -58,9 +54,7 @@ class EngineEffect : public EffectsRequestHandler { bool m_bEnabled; // Must not be modified after construction. QVector m_parameters; - QVector m_buttonParameters; QMap m_parametersById; - QMap m_buttonParametersById; }; #endif /* ENGINEEFFECT_H */ diff --git a/src/engine/effects/engineeffectsmanager.cpp b/src/engine/effects/engineeffectsmanager.cpp index 6d8869f33e4..3b591def709 100644 --- a/src/engine/effects/engineeffectsmanager.cpp +++ b/src/engine/effects/engineeffectsmanager.cpp @@ -98,7 +98,6 @@ void EngineEffectsManager::onCallbackStart() { break; case EffectsRequest::SET_EFFECT_PARAMETERS: case EffectsRequest::SET_PARAMETER_PARAMETERS: - case EffectsRequest::SET_PARAMETER_BUTTON_PARAMETERS: if (!m_effects.contains(request->pTargetEffect)) { if (kEffectDebugOutput) { qDebug() << debugString() diff --git a/src/engine/effects/message.h b/src/engine/effects/message.h index d21aab74417..181792f019a 100644 --- a/src/engine/effects/message.h +++ b/src/engine/effects/message.h @@ -34,7 +34,6 @@ struct EffectsRequest { // Messages for EngineEffect SET_EFFECT_PARAMETERS, SET_PARAMETER_PARAMETERS, - SET_PARAMETER_BUTTON_PARAMETERS, // Must come last. NUM_REQUEST_TYPES From 2586bdedc310b62cd77fc7cbe43598d8dd37f8a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 12 Oct 2014 21:33:47 +0200 Subject: [PATCH 29/36] move "active" List to parameter manifest as showInParameterSlot --- src/effects/effect.cpp | 10 +++++++--- src/effects/effectmanifest.h | 15 --------------- src/effects/effectmanifestparameter.h | 16 +++++++++++++++- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/effects/effect.cpp b/src/effects/effect.cpp index ee3e07702d7..e9e7c88badb 100644 --- a/src/effects/effect.cpp +++ b/src/effects/effect.cpp @@ -20,7 +20,7 @@ Effect::Effect(QObject* pParent, EffectsManager* pEffectsManager, m_bEnabled(true) { foreach (const EffectManifestParameter& parameter, m_manifest.parameters()) { EffectParameter* pParameter = new EffectParameter( - this, pEffectsManager, m_parameters.size(), parameter); + this, pEffectsManager, m_parameters.size(), parameter); m_parameters.append(pParameter); if (m_parametersById.contains(parameter.id())) { qWarning() << debugString() << "WARNING: Loaded EffectManifest that had parameters with duplicate IDs. Dropping one of them."; @@ -140,7 +140,9 @@ EffectParameter* Effect::getKnobParameterForSlot(unsigned int slotNumber) { // for NULL. unsigned int num = 0; foreach(EffectParameter* parameter, m_parameters) { - if (parameter->manifest().controlHint() != EffectManifestParameter::CONTROL_TOGGLE_STEPPING) { + if (parameter->manifest().showInParameterSlot() && + parameter->manifest().controlHint() == + EffectManifestParameter::CONTROL_TOGGLE_STEPPING) { if(num == slotNumber) { return parameter; } @@ -155,7 +157,9 @@ EffectParameter* Effect::getButtonParameterForSlot(unsigned int slotNumber) { // for NULL. unsigned int num = 0; foreach(EffectParameter* parameter, m_parameters) { - if (parameter->manifest().controlHint() == EffectManifestParameter::CONTROL_TOGGLE_STEPPING) { + if (parameter->manifest().showInParameterSlot() && + parameter->manifest().controlHint() == + EffectManifestParameter::CONTROL_TOGGLE_STEPPING) { if(num == slotNumber) { return parameter; } diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index b01b0264b25..ca17a7b2c6b 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -68,19 +68,10 @@ class EffectManifest { } virtual EffectManifestParameter* addParameter() { - m_activeParameters.append(m_parameters.size()); m_parameters.append(EffectManifestParameter()); return &m_parameters.last(); } - virtual void setActiveParameter(int index, unsigned int value) { - m_activeParameters[index] = value; - } - - virtual unsigned int getActiveParameter(int index) const { - return m_activeParameters[index]; - } - private: QString debugString() const { return QString("EffectManifest(%1)").arg(m_id); @@ -92,12 +83,6 @@ class EffectManifest { QString m_version; QString m_description; QList m_parameters; - - // These two lists store the mapping between the parameter slot and - // the effective parameter which is loaded onto the slot. - // When a manifest is created, this mapping is the identity - // function (list[i] = i) - QList m_activeParameters; }; #endif /* EFFECTMANIFEST_H */ diff --git a/src/effects/effectmanifestparameter.h b/src/effects/effectmanifestparameter.h index 554a9a57b71..3d064dca415 100644 --- a/src/effects/effectmanifestparameter.h +++ b/src/effects/effectmanifestparameter.h @@ -48,7 +48,8 @@ class EffectManifestParameter { m_neutralPointOnScale(0.0), m_default(0), m_minimum(0), - m_maximum(1.0) { + m_maximum(1.0), + m_showInParametertSlot(true) { } virtual ~EffectManifestParameter() { @@ -127,6 +128,18 @@ class EffectManifestParameter { m_neutralPointOnScale = neutralPoint; } + + // These store the mapping between the parameter slot and + // the effective parameter which is loaded onto the slot. + // This is required because we have only 8 parameter slots, but + // LV2 or VST effects can have more then 8. + virtual bool showInParameterSlot() const { + return m_showInParametertSlot; + } + virtual void setShowInParameterSlot(double show) { + m_showInParametertSlot = show; + } + //////////////////////////////////////////////////////////////////////////////// // Value Settings //////////////////////////////////////////////////////////////////////////////// @@ -185,6 +198,7 @@ class EffectManifestParameter { // name - value QList > m_steps; + bool m_showInParametertSlot; }; QDebug operator<<(QDebug dbg, const EffectManifestParameter& parameter); From d5b0e6b4ff9e738115bf839204bbf2879ae518e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 13 Oct 2014 20:55:15 +0200 Subject: [PATCH 30/36] cleaned up parameter templates --- res/skins/Shade/effect_parameter_button.xml | 100 +++++++++--------- res/skins/Shade/effect_parameter_knob.xml | 108 ++++++++++---------- 2 files changed, 104 insertions(+), 104 deletions(-) diff --git a/res/skins/Shade/effect_parameter_button.xml b/res/skins/Shade/effect_parameter_button.xml index a55d50c582c..bce7a7603e4 100644 --- a/res/skins/Shade/effect_parameter_button.xml +++ b/res/skins/Shade/effect_parameter_button.xml @@ -9,56 +9,56 @@ EffectParameter: the parameter -->