Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalable consistent faders with themeable gradients, marker at unity, dbFS by default #7045

Merged
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5aa542d
Render fader levels in code with a gradient
michaelgregorius Dec 30, 2023
dac9208
Remove unused pixmaps from `Fader`
michaelgregorius Dec 30, 2023
9a4082a
Rename peak properties and use them to render levels
michaelgregorius Dec 30, 2023
c9e83a3
Always render the knob in the middle of the fader
michaelgregorius Dec 30, 2023
ec4830f
Set size policy of fader to minimum expanding
michaelgregorius Dec 30, 2023
8051134
Default dbFS levels and better peak values
michaelgregorius Jan 1, 2024
3b7cc15
Fix faders of Crossover EQ
michaelgregorius Jan 1, 2024
796661a
Remove EqFader constructor with pixmaps
michaelgregorius Jan 1, 2024
cc6a7d9
Remove background and LEDs pixmap from Fader constructor
michaelgregorius Jan 1, 2024
50781de
Remove the init method from Fader
michaelgregorius Jan 1, 2024
0126c02
Merge remote-tracking branch 'upstream/master' into FaderInCodeWithGr…
michaelgregorius Jan 2, 2024
045a2cd
Draw unity lines last
michaelgregorius Jan 3, 2024
a644bdc
Introduce range with solid warn color
michaelgregorius Jan 6, 2024
381257b
Remove unused method Fader::clips
michaelgregorius Jan 6, 2024
0aebb8c
Fader: Correctly render arbitrary ranges
michaelgregorius Jan 6, 2024
e4b8b6b
Fix whitespace
michaelgregorius Jan 6, 2024
e48bbb8
Remove unused methods in PaintHelper
michaelgregorius Jan 6, 2024
e1fd07f
Fix some builds
michaelgregorius Jan 6, 2024
99113c3
Opaque unity marker with styling option
michaelgregorius Jan 6, 2024
a44b654
Darker default color for the unity line
michaelgregorius Jan 7, 2024
e67f5f8
Remove TODO
michaelgregorius Jan 7, 2024
bb39d5a
Move code
michaelgregorius Jan 8, 2024
5627384
Render unity lines in background
michaelgregorius Jan 8, 2024
b639dc5
Don't draw transparent white lines anymore
michaelgregorius Jan 8, 2024
3bfc4e4
Full on clip color at unity
michaelgregorius Jan 8, 2024
c2dd209
Fix discrepancy between levels and unity markers
michaelgregorius Jan 8, 2024
0f3ce40
Merge remote-tracking branch 'upstream/master' into FaderInCodeWithGr…
michaelgregorius Jan 25, 2024
449ab02
Fix fader display for Equalizer shelves and peaks
michaelgregorius Feb 23, 2024
b4bfc71
Improve the rendering of the levels
michaelgregorius Mar 10, 2024
6d7e7c4
Merge remote-tracking branch 'upstream/master' into FaderInCodeWithGr…
michaelgregorius Mar 22, 2024
f2d63ec
Reduce code repetition
michaelgregorius Apr 3, 2024
2bec339
Code review changes
michaelgregorius Apr 3, 2024
b3a1dd9
Move const to the left of types
michaelgregorius Apr 3, 2024
1bd81d8
Use MEMBER instead of READ/WRITE
michaelgregorius Apr 3, 2024
ad8a31d
Use default member initializers for Fader
michaelgregorius Apr 3, 2024
a65b8aa
Remove constexpr again
michaelgregorius Apr 3, 2024
dea9423
Comprehensive code formatting in Fader class
michaelgregorius Apr 3, 2024
bb212ee
Improved capture and formatting
michaelgregorius Apr 3, 2024
a74b214
Merge remote-tracking branch 'upstream/master' into FaderInCodeWithGr…
michaelgregorius Apr 3, 2024
b0e4586
Make code clearer
michaelgregorius Apr 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed data/themes/classic/fader_background.png
Binary file not shown.
Binary file removed data/themes/classic/fader_leds.png
Binary file not shown.
6 changes: 3 additions & 3 deletions data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,9 @@ lmms--gui--MixerChannelView QGraphicsView {

/* persistent peak markers for fx peak meters */
lmms--gui--Fader {
qproperty-peakGreen: rgb( 74, 253, 133);
qproperty-peakYellow: rgb(224, 222, 18);
qproperty-peakRed: rgb( 255, 100, 100);
qproperty-peakOk: rgb( 74, 253, 133);
qproperty-peakWarn: rgb(224, 222, 18);
qproperty-peakClip: rgb( 255, 100, 100);
}

lmms--gui--TimeLineWidget {
Expand Down
Binary file removed data/themes/default/fader_background.png
Binary file not shown.
Binary file removed data/themes/default/fader_leds.png
Binary file not shown.
6 changes: 3 additions & 3 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,9 @@ lmms--gui--MixerChannelView QGraphicsView {

/* persistent peak markers for fx peak meters */
lmms--gui--Fader {
qproperty-peakGreen: #0ad45c;
qproperty-peakYellow: #d6ec52;
qproperty-peakRed: #c12038;
qproperty-peakOk: #0ad45c;
qproperty-peakWarn: #d6ec52;
qproperty-peakClip: #c12038;
}

lmms--gui--TimeLineWidget {
Expand Down
69 changes: 29 additions & 40 deletions include/Fader.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

#include "AutomatableModelView.h"
#include "embed.h"
#include "lmms_math.h"


namespace lmms::gui
Expand All @@ -66,17 +67,17 @@ class LMMS_EXPORT Fader : public QWidget, public FloatModelView
{
Q_OBJECT
public:
Q_PROPERTY( QColor peakGreen READ peakGreen WRITE setPeakGreen )
Q_PROPERTY( QColor peakRed READ peakRed WRITE setPeakRed )
Q_PROPERTY( QColor peakYellow READ peakYellow WRITE setPeakYellow )
Q_PROPERTY( bool levelsDisplayedInDBFS READ getLevelsDisplayedInDBFS WRITE setLevelsDisplayedInDBFS )

Fader( FloatModel * _model, const QString & _name, QWidget * _parent );
Fader( FloatModel * _model, const QString & _name, QWidget * _parent, QPixmap * back, QPixmap * leds, QPixmap * knob );
Q_PROPERTY(QColor peakOk MEMBER m_peakOk)
Q_PROPERTY(QColor peakClip MEMBER m_peakClip)
Q_PROPERTY(QColor peakWarn MEMBER m_peakWarn)
Q_PROPERTY(bool levelsDisplayedInDBFS MEMBER m_levelsDisplayedInDBFS)
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() override = default;

void init(FloatModel * model, QString const & name);

void setPeak_L( float fPeak );
float getPeak_L() { return m_fPeakValue_L; }

Expand All @@ -89,17 +90,8 @@ class LMMS_EXPORT Fader : public QWidget, public FloatModelView
inline float getMaxPeak() const { return m_fMaxPeak; }
inline void setMaxPeak(float maxPeak) { m_fMaxPeak = maxPeak; }

QColor const & peakGreen() const;
void setPeakGreen( const QColor & c );

QColor const & peakRed() const;
void setPeakRed( const QColor & c );

QColor const & peakYellow() const;
void setPeakYellow( const QColor & c );

inline bool getLevelsDisplayedInDBFS() const { return m_levelsDisplayedInDBFS; }
inline void setLevelsDisplayedInDBFS(bool value = true) { m_levelsDisplayedInDBFS = value; }
inline bool getRenderUnityLine() const { return m_renderUnityLine; }
inline void setRenderUnityLine(bool value = true) { m_renderUnityLine = value; }

void setDisplayConversion( bool b )
{
Expand All @@ -122,10 +114,7 @@ class LMMS_EXPORT Fader : public QWidget, public FloatModelView
void wheelEvent( QWheelEvent *ev ) override;
void paintEvent( QPaintEvent *ev ) override;

inline bool clips(float const & value) const { return value >= 1.0f; }

void paintDBFSLevels(QPaintEvent *ev, QPainter & painter);
void paintLinearLevels(QPaintEvent *ev, QPainter & painter);
void paintLevels(QPaintEvent *ev, QPainter & painter, bool linear = false);
michaelgregorius marked this conversation as resolved.
Show resolved Hide resolved

int knobPosY() const
{
Expand All @@ -136,36 +125,36 @@ class LMMS_EXPORT Fader : public QWidget, public FloatModelView
}

void setPeak( float fPeak, float &targetPeak, float &persistentPeak, QElapsedTimer &lastPeakTimer );
int calculateDisplayPeak( float fPeak );

void updateTextFloat();

// Private members
private:
float m_fPeakValue_L;
float m_fPeakValue_R;
float m_persistentPeak_L;
float m_persistentPeak_R;
float m_fMinPeak;
float m_fMaxPeak;
float m_fPeakValue_L {0.};
float m_fPeakValue_R {0.};
float m_persistentPeak_L {0.};
float m_persistentPeak_R {0.};
float m_fMinPeak {dbfsToAmp(-42)};
float m_fMaxPeak {dbfsToAmp(9)};

QElapsedTimer m_lastPeakTimer_L;
QElapsedTimer m_lastPeakTimer_R;

QPixmap m_back;
QPixmap m_leds;
QPixmap m_knob;
QPixmap m_knob {embed::getIconPixmap("fader_knob")};

bool m_levelsDisplayedInDBFS;
bool m_levelsDisplayedInDBFS {true};

int m_moveStartPoint;
float m_startValue;
int m_moveStartPoint {-1};
float m_startValue {0.};

static SimpleTextFloat * s_textFloat;

QColor m_peakGreen;
QColor m_peakRed;
QColor m_peakYellow;
QColor m_peakOk {10, 212, 92};
QColor m_peakClip {193, 32, 56};
QColor m_peakWarn {214, 236, 82};
QColor m_unityMarker {63, 63, 63, 255};

bool m_renderUnityLine {true};
} ;


Expand Down
31 changes: 27 additions & 4 deletions include/lmms_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "lmms_constants.h"
#include "lmmsconfig.h"
#include <cassert>

namespace lmms
{
Expand Down Expand Up @@ -269,18 +270,18 @@ static inline float safeDbfsToAmp( float dbfs )
//! @brief Converts linear amplitude (>0-1.0) to dBFS scale.
//! @param amp Linear amplitude, where 1.0 = 0dBFS. ** Must be larger than zero! **
//! @return Amplitude in dBFS.
static inline float ampToDbfs( float amp )
static inline float ampToDbfs(float amp)
{
return log10f( amp ) * 20.0f;
return log10f(amp) * 20.0f;
}


//! @brief Converts dBFS-scale to linear amplitude with 0dBFS = 1.0
//! @param dbfs The dBFS value to convert. ** Must be a real number - not inf/nan! **
//! @return Linear amplitude
static inline float dbfsToAmp( float dbfs )
static inline float dbfsToAmp(float dbfs)
{
return std::pow(10.f, dbfs * 0.05f );
return std::pow(10.f, dbfs * 0.05f);
}


Expand Down Expand Up @@ -352,6 +353,28 @@ static inline int numDigitsAsInt(float f)
return digits;
}

template <typename T>
michaelgregorius marked this conversation as resolved.
Show resolved Hide resolved
class LinearMap
{
public:
LinearMap(T x1, T y1, T x2, T y2)
{
T const dx = x2 - x1;
assert (dx != T(0));

m_a = (y2 - y1) / dx;
m_b = y1 - m_a * x1;
}

T map(T x) const
{
return m_a * x + m_b;
}

private:
T m_a;
T m_b;
};

} // namespace lmms

Expand Down
19 changes: 12 additions & 7 deletions plugins/CrossoverEQ/CrossoverEQControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include "Knob.h"
#include "Fader.h"

#include <QPixmap>


namespace lmms::gui
{

Expand Down Expand Up @@ -64,30 +67,32 @@ CrossoverEQControlDialog::CrossoverEQControlDialog( CrossoverEQControls * contro
xover34->setLabel( "3/4" );
xover34->setHintText( tr( "Band 3/4 crossover:" ), " Hz" );

m_fader_bg = QPixmap( PLUGIN_NAME::getIconPixmap( "fader_bg" ) );
m_fader_empty = QPixmap( PLUGIN_NAME::getIconPixmap( "fader_empty" ) );
m_fader_knob = QPixmap( PLUGIN_NAME::getIconPixmap( "fader_knob2" ) );
QPixmap const fader_knob(PLUGIN_NAME::getIconPixmap("fader_knob2"));

// faders
auto gain1 = new Fader(&controls->m_gain1, tr("Band 1 gain"), this, &m_fader_bg, &m_fader_empty, &m_fader_knob);
auto gain1 = new Fader(&controls->m_gain1, tr("Band 1 gain"), this, fader_knob);
gain1->move( 7, 56 );
gain1->setDisplayConversion( false );
gain1->setHintText( tr( "Band 1 gain:" ), " dBFS" );
gain1->setRenderUnityLine(false);

auto gain2 = new Fader(&controls->m_gain2, tr("Band 2 gain"), this, &m_fader_bg, &m_fader_empty, &m_fader_knob);
auto gain2 = new Fader(&controls->m_gain2, tr("Band 2 gain"), this, fader_knob);
gain2->move( 47, 56 );
gain2->setDisplayConversion( false );
gain2->setHintText( tr( "Band 2 gain:" ), " dBFS" );
gain2->setRenderUnityLine(false);

auto gain3 = new Fader(&controls->m_gain3, tr("Band 3 gain"), this, &m_fader_bg, &m_fader_empty, &m_fader_knob);
auto gain3 = new Fader(&controls->m_gain3, tr("Band 3 gain"), this, fader_knob);
gain3->move( 87, 56 );
gain3->setDisplayConversion( false );
gain3->setHintText( tr( "Band 3 gain:" ), " dBFS" );
gain3->setRenderUnityLine(false);

auto gain4 = new Fader(&controls->m_gain4, tr("Band 4 gain"), this, &m_fader_bg, &m_fader_empty, &m_fader_knob);
auto gain4 = new Fader(&controls->m_gain4, tr("Band 4 gain"), this, fader_knob);
gain4->move( 127, 56 );
gain4->setDisplayConversion( false );
gain4->setHintText( tr( "Band 4 gain:" ), " dBFS" );
gain4->setRenderUnityLine(false);

// leds
auto mute1 = new LedCheckBox("", this, tr("Band 1 mute"), LedCheckBox::LedColor::Green);
Expand Down
6 changes: 0 additions & 6 deletions plugins/CrossoverEQ/CrossoverEQControlDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#ifndef CROSSOVEREQ_CONTROL_DIALOG_H
#define CROSSOVEREQ_CONTROL_DIALOG_H

#include <QPixmap>
#include "EffectControlDialog.h"

namespace lmms
Expand All @@ -46,11 +45,6 @@ class CrossoverEQControlDialog : public EffectControlDialog
public:
CrossoverEQControlDialog( CrossoverEQControls * controls );
~CrossoverEQControlDialog() override = default;

private:
QPixmap m_fader_bg;
QPixmap m_fader_empty;
QPixmap m_fader_knob;
};


Expand Down
Binary file removed plugins/CrossoverEQ/fader_bg.png
Binary file not shown.
Binary file removed plugins/CrossoverEQ/fader_empty.png
Binary file not shown.
2 changes: 2 additions & 0 deletions plugins/Eq/EqControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class EqControls : public EffectControls
float m_inPeakR;
float m_outPeakL;
float m_outPeakR;

// The following are linear peaks
float m_lowShelfPeakL, m_lowShelfPeakR;
float m_para1PeakL, m_para1PeakR;
float m_para2PeakL, m_para2PeakR;
Expand Down
17 changes: 8 additions & 9 deletions plugins/Eq/EqControlsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,16 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) :
setBand( 6, &controls->m_highShelfActiveModel, &controls->m_highShelfFreqModel, &controls->m_highShelfResModel, &controls->m_highShelfGainModel, QColor(255 ,255, 255), tr( "High-shelf" ), &controls->m_highShelfPeakL, &controls->m_highShelfPeakR,0,0,0,0,0,0 );
setBand( 7, &controls->m_lpActiveModel, &controls->m_lpFreqModel, &controls->m_lpResModel, 0, QColor(255 ,255, 255), tr( "LP" ) ,0,0,0,0,0, &controls->m_lp12Model, &controls->m_lp24Model, &controls->m_lp48Model);

static auto s_faderBg = PLUGIN_NAME::getIconPixmap("faderback");
static auto s_faderLeds = PLUGIN_NAME::getIconPixmap("faderleds");
static auto s_faderKnob = PLUGIN_NAME::getIconPixmap("faderknob");
QSize const faderSize(23, 80);

auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, &s_faderBg, &s_faderLeds, &s_faderKnob,
&controls->m_inPeakL, &controls->m_inPeakR);
auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, &controls->m_inPeakL, &controls->m_inPeakR);
GainFaderIn->setFixedSize(faderSize);
GainFaderIn->move( 23, 295 );
GainFaderIn->setDisplayConversion( false );
GainFaderIn->setHintText( tr( "Gain" ), "dBv");

auto GainFaderOut = new EqFader(&controls->m_outGainModel, tr("Output gain"), this, &s_faderBg, &s_faderLeds, &s_faderKnob,
&controls->m_outPeakL, &controls->m_outPeakR);
auto GainFaderOut = new EqFader(&controls->m_outGainModel, tr("Output gain"), this, &controls->m_outPeakL, &controls->m_outPeakR);
GainFaderOut->setFixedSize(faderSize);
GainFaderOut->move( 453, 295);
GainFaderOut->setDisplayConversion( false );
GainFaderOut->setHintText( tr( "Gain" ), "dBv" );
Expand All @@ -92,8 +90,9 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) :
int distance = 126;
for( int i = 1; i < m_parameterWidget->bandCount() - 1; i++ )
{
auto gainFader = new EqFader(m_parameterWidget->getBandModels(i)->gain, tr(""), this, &s_faderBg, &s_faderLeds,
&s_faderKnob, m_parameterWidget->getBandModels(i)->peakL, m_parameterWidget->getBandModels(i)->peakR);
auto gainFader = new EqFader(m_parameterWidget->getBandModels(i)->gain, tr(""), this,
m_parameterWidget->getBandModels(i)->peakL, m_parameterWidget->getBandModels(i)->peakR);
gainFader->setFixedSize(faderSize);
gainFader->move( distance, 295 );
distance += 44;
gainFader->setMinimumHeight(80);
Expand Down
Loading
Loading