diff options
author | Daniel Schürmann <daschuer@mixxx.org> | 2014-11-05 20:53:47 +0100 |
---|---|---|
committer | Daniel Schürmann <daschuer@mixxx.org> | 2014-11-05 20:53:47 +0100 |
commit | b32b27a699c85770c59857f82a2450878fbc2649 (patch) | |
tree | 78e3e245de4952a5ff71cbb20bc9911b23c56d25 /src/control | |
parent | 6f0507ae8bb40aa856d73cdaa0b51424b3a42ba3 (diff) | |
parent | e477df5d316aaaa991e862240260dd44041829e5 (diff) |
Merge remote-tracking branch 'upstream/master' into flter_rack
Conflicts:
src/effects/effectmanifest.h
src/effects/native/bessel4lvmixeqeffect.cpp
src/effects/native/bessel8lvmixeqeffect.cpp
src/effects/native/bitcrushereffect.cpp
src/effects/native/filtereffect.cpp
src/engine/effects/engineeffectchain.cpp
Diffstat (limited to 'src/control')
-rw-r--r-- | src/control/controlbehavior.cpp | 44 | ||||
-rw-r--r-- | src/control/controlbehavior.h | 6 |
2 files changed, 19 insertions, 31 deletions
diff --git a/src/control/controlbehavior.cpp b/src/control/controlbehavior.cpp index fe56974a82..1ee9919d7d 100644 --- a/src/control/controlbehavior.cpp +++ b/src/control/controlbehavior.cpp @@ -98,50 +98,38 @@ double ControlPotmeterBehavior::valueToMidiParameter(double dValue) { #define middlePosition ((maxPosition - minPosition) / 2.0) #define positionrange (maxPosition - minPosition) -ControlLogPotmeterBehavior::ControlLogPotmeterBehavior(double dMinValue, double dMaxValue) - : ControlPotmeterBehavior(dMinValue, dMaxValue, false), - m_dB1(0.0), - m_dB2(0.0) { - if (dMaxValue == 1.0 || dMinValue != 0.0 ) { - m_bTwoState = false; - m_dB1 = log10((dMaxValue - dMinValue) + 1.0) / maxPosition; +ControlLogPotmeterBehavior::ControlLogPotmeterBehavior(double dMinValue, double dMaxValue, double minDB) + : ControlPotmeterBehavior(dMinValue, dMaxValue, false) { + if (minDB >= 0) { + qWarning() << "ControlLogPotmeterBehavior::ControlLogPotmeterBehavior() minDB must be negative"; + m_minDB = -1; } else { - m_bTwoState = true; - m_dB1 = log10(2.0) / middlePosition; - m_dB2 = log10(dMaxValue) / (maxPosition - middlePosition); + m_minDB = minDB; } + m_minOffset = db2ratio(m_minDB); } ControlLogPotmeterBehavior::~ControlLogPotmeterBehavior() { } double ControlLogPotmeterBehavior::valueToParameter(double dValue) { + if (m_dValueRange == 0.0) { + return 0; + } if (dValue > m_dMaxValue) { dValue = m_dMaxValue; } else if (dValue < m_dMinValue) { dValue = m_dMinValue; } - if (!m_bTwoState) { - return log10((dValue - m_dMinValue) + 1) / m_dB1; - } else { - if (dValue > 1.0) { - return log10(dValue) / m_dB2 + middlePosition; - } else { - return log10(dValue + 1.0) / m_dB1; - } - } + double linPrameter = (dValue - m_dMinValue) / m_dValueRange; + double dbParamter = ratio2db(linPrameter + m_minOffset * (1 - linPrameter)); + return 1 - (dbParamter / m_minDB); } double ControlLogPotmeterBehavior::parameterToValue(double dParam) { - if (!m_bTwoState) { - return pow(10.0, m_dB1 * dParam) - 1.0 + m_dMinValue; - } else { - if (dParam <= middlePosition) { - return pow(10.0, m_dB1 * dParam) - 1; - } else { - return pow(10.0, m_dB2 * (dParam - middlePosition)); - } - } + double dbParamter = (1 - dParam) * m_minDB; + double linPrameter = (db2ratio(dbParamter) - m_minOffset) / (1 - m_minOffset); + return m_dMinValue + (linPrameter * m_dValueRange); } ControlLinPotmeterBehavior::ControlLinPotmeterBehavior(double dMinValue, double dMaxValue, diff --git a/src/control/controlbehavior.h b/src/control/controlbehavior.h index e6f53938a9..d2e42e48a7 100644 --- a/src/control/controlbehavior.h +++ b/src/control/controlbehavior.h @@ -44,15 +44,15 @@ class ControlPotmeterBehavior : public ControlNumericBehavior { class ControlLogPotmeterBehavior : public ControlPotmeterBehavior { public: - ControlLogPotmeterBehavior(double dMinValue, double dMaxValue); + ControlLogPotmeterBehavior(double dMinValue, double dMaxValue, double minDB); virtual ~ControlLogPotmeterBehavior(); virtual double valueToParameter(double dValue); virtual double parameterToValue(double dParam); protected: - bool m_bTwoState; - double m_dB1, m_dB2; + double m_minDB; + double m_minOffset; }; class ControlLinPotmeterBehavior : public ControlPotmeterBehavior { |