Support for dB models

Add support for models that are in dB.

There's a new member `m_modelIsLinear` which can be set via the
constructor. The default value in the constructor is `true`.

Add the method `modelIsLinear` which can be used to query the parameter.
It is used in `calculateKnobPosYFromModel` and
`setVolumeByLocalPixelValue`. Both methods got extended to deal with
models in dB. They were also refactored to extract code that is common
for both cases.

Ensure that the constructor of `Fader` is called with `false` for
`CrossoverEQControlDialog` and `EqFader` because these use models that
are in dB.
This commit is contained in:
Michael Gregorius
2024-12-24 13:46:02 +01:00
parent f8e0bf5184
commit def44aee63
4 changed files with 91 additions and 57 deletions

View File

@@ -74,8 +74,8 @@ public:
Q_PROPERTY(bool renderUnityLine READ getRenderUnityLine WRITE setRenderUnityLine)
Q_PROPERTY(QColor unityMarker MEMBER m_unityMarker)
Fader(FloatModel* model, const QString& name, QWidget* parent);
Fader(FloatModel* model, const QString& name, QWidget* parent, const QPixmap& knob);
Fader(FloatModel* model, const QString& name, QWidget* parent, bool modelIsLinear = true);
Fader(FloatModel* model, const QString& name, QWidget* parent, const QPixmap& knob, bool modelIsLinear = true);
~Fader() override = default;
void setPeak_L(float fPeak);
@@ -126,6 +126,8 @@ private:
void updateTextFloat();
bool modelIsLinear() const { return m_modelIsLinear; }
// Private members
private:
float m_fPeakValue_L {0.};
@@ -141,6 +143,7 @@ private:
QPixmap m_knob {embed::getIconPixmap("fader_knob")};
bool m_levelsDisplayedInDBFS {true};
bool m_modelIsLinear {false};
// The dbFS amount after which we drop down to -inf dbFS
float const m_faderMinDb {-120.};