From 795c681a2c1e5fd0f4d98a59b8cb389c5198f15f Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 29 Dec 2024 13:41:52 +0100 Subject: [PATCH] Introduce constexpr for scaling exponent Introduce the `constexpr c_dBScalingExponent` which describes the scaling exponent that's used to scale the dB scale in both directions. This will simplify potential adjustments by keeping the values consistent everywhere. --- src/gui/widgets/Fader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/Fader.cpp b/src/gui/widgets/Fader.cpp index 111c4520c..b5a1f0709 100644 --- a/src/gui/widgets/Fader.cpp +++ b/src/gui/widgets/Fader.cpp @@ -60,6 +60,8 @@ namespace lmms::gui { +constexpr auto c_dBScalingExponent = 3.f; + SimpleTextFloat* Fader::s_textFloat = nullptr; Fader::Fader(FloatModel* model, const QString& name, QWidget* parent, bool modelIsLinear) : @@ -331,7 +333,7 @@ int Fader::calculateKnobPosYFromModel() const // This returns results between: // * m_knob.height() for a ratio of 1 // * height() for a ratio of 0 - return height() - (height() - m_knob.height()) * std::pow(ratio, 3.); + return height() - (height() - m_knob.height()) * std::pow(ratio, c_dBScalingExponent); } } else @@ -382,7 +384,7 @@ void Fader::setVolumeByLocalPixelValue(int y) LinearMap knobMap(float(m_knob.height()), 1., float(height()), 0.); // Apply the inverse of what is done in calculateKnobPosYFromModel - auto const knobPos = std::pow(knobMap.map(clampedLowerFaderKnob), 1./3.); + auto const knobPos = std::pow(knobMap.map(clampedLowerFaderKnob), 1./c_dBScalingExponent); float const maxDb = ampToDbfs(m->maxValue());