Skip to content

Commit

Permalink
Introduce range with solid warn color
Browse files Browse the repository at this point in the history
Introduce a second point in the gradient for the warn colors so that we get a certain range with the full/solid warn color.

The colors are distributed as follows now. The solid ok range goes from -inf dbFS to -12 dbFS. The warn range goes from -6 dbFS to 0 dbFS. In between the colors are interpolated. Values above 0 dbFS interpolate from the warn color to the clip color.

This is now quite similar to the previous implementation.

# Analysis of the previous pixmap implementation
The pixmap implementation used pixmaps with a height of 116 pixels to map 51 dbFS (-42 dbFS to 9 dbFS) across the whole height. The pixels of the LED pixmap were distributed as follows along the Y-axis:
* Margin: 4
* Red: 18
* Yellow: 14
* Green: 76
* Margin: 4

Due to the margins the actual red, yellow and green areas only represent a range of (1 - (4+4) / 116) * 51 ~ 47,48 dbFS. This range is distributed as follows across the colors:
Red: 7.91 dbFS
Yellow: 6.16 dbFS
Green: 33.41 dbFS

The borders between the colors are located along the following dbFS values:
* Red/yellow: 9 - (4 + 18) / 116 * 51 dbFS ~ -0.67 dbFS
* Yellow/green: 9 - (4 + 18 + 14) / 116 * 51 dbFS ~ -6.83 dbFS
* The green marker is rendered for values above -40.24 dbFS.
  • Loading branch information
michaelgregorius committed Jan 6, 2024
1 parent 045a2cd commit a644bdc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/gui/widgets/Fader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ void Fader::paintLevels(QPaintEvent * ev, QPainter & painter, bool linear)
float const mappedPersistentPeakL(mapper(m_persistentPeak_L));
float const mappedPersistentPeakR(mapper(m_persistentPeak_R));
float const mappedUnity(mapper(1.f));
float const mappedLastOk(mapper(dbfsToAmp(-12.f)));
float const mappedWarnEnd(mappedUnity);
float const mappedWarnStart(mapper(dbfsToAmp(-6.f)));
float const mappedOkEnd(mapper(dbfsToAmp(-12.f)));

PaintHelper ph(mappedMinPeak, mappedMaxPeak);

Expand All @@ -399,8 +401,9 @@ void Fader::paintLevels(QPaintEvent * ev, QPainter & painter, bool linear)

QLinearGradient linearGrad(0, margin, 0, leftMeterRect.y() + leftMeterRect.height());
linearGrad.setColorAt(0, clippingColor);
linearGrad.setColorAt(ph.mapMaxZeroAndMinOne(mappedUnity), warnColor);
linearGrad.setColorAt(ph.mapMaxZeroAndMinOne(mappedLastOk), okColor);
linearGrad.setColorAt(ph.mapMaxZeroAndMinOne(mappedWarnEnd), warnColor);
linearGrad.setColorAt(ph.mapMaxZeroAndMinOne(mappedWarnStart), warnColor);
linearGrad.setColorAt(ph.mapMaxZeroAndMinOne(mappedOkEnd), okColor);
linearGrad.setColorAt(1, okColor);

// Draw left levels
Expand Down

0 comments on commit a644bdc

Please sign in to comment.