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

Commits on Dec 31, 2023

  1. Render fader levels in code with a gradient

    Render the fader level in code using a gradient instead of using pixmaps. The problem with the pixmaps is that they don't "know" how a fader instance is configured with regards to the minimum and maximum value. This means that the display can give quite a wrong impression.
    
    The rendering of levels has been unified in the method `paintLevels`. It can render using dbFS and linear scale. The method `paintLinearLevels` has been removed completely, i.e. there's no more code that renders using pixmaps.
    
    Much of the previous code relied on the size of the background image `fader_background.png`, e.g. the initialization of the size. For now the `Fader` widget is initially resized to the size of that background image as it is present in the default and classic theme (see `Fader::init`). All rendering uses the size of the widget itself to determine where to draw what. This means that the widget is prepared to be resizable.
    
    The method `paintLevels` first renders the background of the level indicators and uses these as clipping paths for all other rendering operations, e.g. for the rendering of the levels themselves. Levels are rendered using a gradient which is defined with the following stops:
    * Two stops for the ok levels.
    * One stop for warning levels.
    * One stop for clipping levels.
    
    Peak indicators do not use the three distinct colors anymore but instead use the color of the gradient at that position of the peak. This makes everything look "smooth".
    
    The code now also renders a marker at unity position, i.e. at position 1.0 in linear levels and 0 dbFS in dbFS scale.
    
    The painting code makes lots of use of the class `PaintHelper`. This class is configured with a minimum and maximum value and can then return linear factors for given values. There are two supported modes:
    * Map min to 0 and max to 1
    * Map min to 1 and max to 0
    
    It can also compute rectangles that correspond to a given value. These methods can be given rectangles that are supposed to represent the span from min to max. The returned result is then a rectangle that fills the lower part of the source rectangle according to the given value with regards to min and max (`getMeterRect`). Another method returns a rectangle of height 1 which lies inside the given source rectangle at the corresponding level (`getPersistentPeakRect`).
    
    The method `paintLevels` uses a mapping function to map the amplitude values (current peak value, persistent peak, etc.) to the display values. There's one mapper that keeps the original value and it is used to display everything in a linear scale. Another mapper maps everything to dbFS and uses these values as display everything in a dbFS scale. The following values must be mapped for the left and right channel to make this work:
    * Min and max display values (min and max peak values)
    * The current peak value
    * The persistent peak value
    * The value for unity, i.e. 1.0 in linear levels and 0 dbFS in dbFS scale.
    
    Remove the method `calculateDisplayPeak` which was used in the old method to render linear levels.
    
    `Fader::setPeak` now uses `std::clamp` instead of doing "manual" comparisons.
    
    The LMMS plugins Compressor, EQ and Delay are still configured to use linear displays. It should be considered to switch them to dbFS/logarithmic displays as well and to remove the code that renders linearly.
    michaelgregorius committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    5aa542d View commit details
    Browse the repository at this point in the history
  2. Remove unused pixmaps from Fader

    Remove the now unused pixmaps for the background and the LEDs from the `Fader` class and remove the files from the default and classic theme directories.
    michaelgregorius committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    dac9208 View commit details
    Browse the repository at this point in the history
  3. Rename peak properties and use them to render levels

    Rename the peak properties as follows:
    * peakGreen -> peakOk
    * peakRed -> peakClip
    * peakYellow -> peakWarn
    
    The reasoning is that a style might for example use a different color than green to indicate levels that are ok.
    
    Use the properties to initialize the gradient that is used to render the levels.
    
    Initialize the properties to the colors of the current default theme so that it's not mandatory to set them in a style sheet. Up until now they have all been initialized as black.
    michaelgregorius committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    9a4082a View commit details
    Browse the repository at this point in the history
  4. Always render the knob in the middle of the fader

    Render the knob in the middle of the fader regardless of the width. The previous implementation was dependent on the fader pixmap having a matching width because it always rendered at x=0.
    michaelgregorius committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    c9e83a3 View commit details
    Browse the repository at this point in the history
  5. Set size policy of fader to minimum expanding

    Set the size policy of the fader to minimum expanding in both directions. This will make the fader grow in layouts if there is space.
    michaelgregorius committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    ec4830f View commit details
    Browse the repository at this point in the history

Commits on Jan 1, 2024

  1. Default dbFS levels and better peak values

    Default to dbFS levels for all faders and set some better minimum and maximum peak values.
    michaelgregorius committed Jan 1, 2024
    Configuration menu
    Copy the full SHA
    8051134 View commit details
    Browse the repository at this point in the history
  2. Fix faders of Crossover EQ

    Fix the faders of the Crossover EQ which were initialized and rendered much too wide and with a line at unity. The large width also resulted in the knobs being rendered outside of view.
    
    Resize the fader to the minimum size so that it is constructed at a sane default.
    
    Introduce a property that allows to control if the unity line is rendered. The property is available in style sheets and defaults to the unity lines being rendered. Adjust the paint code to evaluate the property.
    
    Initialize the faders of the Crossover EQ such that the unity line is not drawn.
    michaelgregorius committed Jan 1, 2024
    Configuration menu
    Copy the full SHA
    3b7cc15 View commit details
    Browse the repository at this point in the history
  3. Remove EqFader constructor with pixmaps

    Remove the constructor of `EqFader` that takes the pixmaps to the fader background, leds and knob. The background and leds pixmaps are not used by the base class `Fader` for rendering anymore to make the `Fader` resizable. A pixmap is still used to render the knob but the constructor that takes the knob as an argument does not do anything meaningful with it, i.e. all faders are rendered with the default knob anyway.
    
    Remove the resources for the fader background, leds and knob as they are not used and the knob was the same image as the default knob anyway.
    
    Remove the static pixmaps from the constructor of `EqControlsDialog`. Switch the instantiations of the EQ's faders to use the remaining constructor of `EqFader`. This constructor sets a different fixed size of (23, 116) compared to the removed constructor which set a size of (23, 80). Therefore all faders that used the removed constructor are now set explicitly to a fixed size of (23, 80).
    
    The constructor that's now used also calls a different base constructor than the removed one. The difference between the two base constructors of `Fader` is that one of them sets the member `m_conversionFactor` to 100.0 whereas the other one keeps the default of 1.0. The adjusted faders in `EqControlsDialog` are thus now constructed with the conversion factor set to 100. However, all of them already call `setDisplayConversion` with `false` after construction which results in the conversion factor being reset to 1.0. So the result should be the same as before the changes.
    michaelgregorius committed Jan 1, 2024
    Configuration menu
    Copy the full SHA
    796661a View commit details
    Browse the repository at this point in the history
  4. Remove background and LEDs pixmap from Fader constructor

    Remove the parameters for the background and LEDs pixmap from the second `Fader` constructor. Make the knob pixmap parameter in the constructor a const reference. Assign the reference to the knob pixmap of the `Fader` itself. This enables clients to use their own fader knobs as is the case with the Crossover EQ. The EQ now renders using it's own knobs again.
    
    Make the second constructor delegate to the first one. This will additionally set the conversion factor to 100 but this is not a problem with the current code because the only user of the second constructor, the Crossover EQ, already calls `setDisplayConversion` with the parameter set to `false`, hence reinstating a conversion factor of 1.
    
    Remove the resources for the background and LEDs from the Crossover EQ as they are not used anymore. Remove the three QPixmap members from `CrossoverEQControlDialog` as they are not needed. The background and LEDs are not used anyway and the knob is passed in as a constant reference which is copied. Hence we can use a local variable in the constructor of `CrossoverEQControlDialog`.
    michaelgregorius committed Jan 1, 2024
    Configuration menu
    Copy the full SHA
    cc6a7d9 View commit details
    Browse the repository at this point in the history
  5. Remove the init method from Fader

    Remove the `init` method from `Fader` as it is not needed anymore due to the constructor delegation. Tidy up the parameter lists and use of spaces in the constructor.
    michaelgregorius committed Jan 1, 2024
    Configuration menu
    Copy the full SHA
    50781de View commit details
    Browse the repository at this point in the history

Commits on Jan 2, 2024

  1. Merge remote-tracking branch 'upstream/master' into FaderInCodeWithGr…

    …adients
    
    Conflicts:
    * include/Fader.h
    * src/gui/widgets/Fader.cpp
    michaelgregorius committed Jan 2, 2024
    Configuration menu
    Copy the full SHA
    0126c02 View commit details
    Browse the repository at this point in the history

Commits on Jan 3, 2024

  1. Draw unity lines last

    Draw the unity lines last so that they are not affected by the white-ish overdraw in line 423 (after the changes).
    michaelgregorius committed Jan 3, 2024
    Configuration menu
    Copy the full SHA
    045a2cd View commit details
    Browse the repository at this point in the history

Commits on Jan 6, 2024

  1. Introduce range with solid warn color

    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.
    michaelgregorius committed Jan 6, 2024
    Configuration menu
    Copy the full SHA
    a644bdc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    381257b View commit details
    Browse the repository at this point in the history
  3. Fader: Correctly render arbitrary ranges

    Adjust the `Fader` so that it can correctly render arbitrary ranges of min and max peak values, e.g. that it would render a display range of [-12 dbFS, -42 dbFS] correctly.
    
    Until now the gradient was defined to start at the top of the levels rectangle and end at the bottom. As a result the top was always rendered in the "clip" color and the bottom in the "ok" color. However, this is wrong, e.g. if we configure the `Fader` with a max value of -12 dbFS and a min value of -42 dbFS. In that case the whole range of the fader should be rendered with the "ok" color.
    
    The fix is to compute the correct window coordinates of the start and end point of gradient using from the "window" of values that the `Fader` displays and then to map the in-between colors accordingly. See the added comments in the code for more details.
    
    Add the templated helper class `LinearMap` to `lmms_math.h`. The class defines a linear function/map which is initialized using two points. With the `map` function it is then possible to evaluate arbitrary X-coordinates.
    michaelgregorius committed Jan 6, 2024
    Configuration menu
    Copy the full SHA
    0aebb8c View commit details
    Browse the repository at this point in the history
  4. Fix whitespace

    michaelgregorius committed Jan 6, 2024
    Configuration menu
    Copy the full SHA
    e4b8b6b View commit details
    Browse the repository at this point in the history
  5. Remove unused methods in PaintHelper

    Remove the now unused mapping methods from `PaintHelper`. Their functionality has been replaced with the usage of `LinearMap` in the code.
    michaelgregorius committed Jan 6, 2024
    Configuration menu
    Copy the full SHA
    e48bbb8 View commit details
    Browse the repository at this point in the history
  6. Fix some builds

    Include `cassert` for some  builds that otherwise fail.
    michaelgregorius committed Jan 6, 2024
    Configuration menu
    Copy the full SHA
    e1fd07f View commit details
    Browse the repository at this point in the history
  7. Opaque unity marker with styling option

    Make the unity marker opaque by default and enable to style it with the style sheets. None of the two style sheets uses this option though.
    michaelgregorius committed Jan 6, 2024
    Configuration menu
    Copy the full SHA
    99113c3 View commit details
    Browse the repository at this point in the history

Commits on Jan 7, 2024

  1. Configuration menu
    Copy the full SHA
    a44b654 View commit details
    Browse the repository at this point in the history
  2. Remove TODO

    michaelgregorius committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    e67f5f8 View commit details
    Browse the repository at this point in the history

Commits on Jan 8, 2024

  1. Move code

    Move the computation of most mapped values at the top right after the definition of the mapper so that it is readily available in all phases of the painting code.
    michaelgregorius committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    bb39d5a View commit details
    Browse the repository at this point in the history
  2. Render unity lines in background

    Render the unity lines before rendering the levels so that they get overdrawn and do not stick out when they are crossed.
    michaelgregorius committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    5627384 View commit details
    Browse the repository at this point in the history
  3. Don't draw transparent white lines anymore

    Don't draw the transparent white lines anymore as they were mostly clipped anyway and only create "smudge".
    michaelgregorius committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    b639dc5 View commit details
    Browse the repository at this point in the history
  4. Full on clip color at unity

    Adjust the gradient so that the full on clip color shows starting at unity. There is only a very short transistion from the end of warning to clipping making it look like a solid color "standing" on top of a gradient.
    michaelgregorius committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    3bfc4e4 View commit details
    Browse the repository at this point in the history
  5. Fix discrepancy between levels and unity markers

    This commit removes the helper class `PaintHelper` and now uses two lambdas to compute the rectangles for the peak indicators and levels. It uses the linear map which maps the peak values (in dbFS or linear) to window coordinates of the widget.
    
    The change fixes a discrepancy in the following implementation for which the full on clip rectangle rendered slightly below the unity marker.
    michaelgregorius committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    c2dd209 View commit details
    Browse the repository at this point in the history

Commits on Jan 25, 2024

  1. Merge remote-tracking branch 'upstream/master' into FaderInCodeWithGr…

    …adients
    
    Conflicts:
    * include/lmms_math.h
    michaelgregorius committed Jan 25, 2024
    Configuration menu
    Copy the full SHA
    0f3ce40 View commit details
    Browse the repository at this point in the history

Commits on Feb 23, 2024

  1. Fix fader display for Equalizer shelves and peaks

    The peak values for the shelves and peaks of the Equalizer plugin are computed in `EqEffect::peakBand`. The previous implementation evaluated the bins of the corresponding frequency spectrum and determined the "loudest" one. The value of this bin was then converted to dbFS and mapped to the interval [0, inf[ where all values less or equal to -60 dbFS were mapped to 0 and a value of 40 dbFS was mapped to 1. So effectively everything was mapped somewhere into [0, 1] yet in a quite "distorted" way because a signal of 40 dbFS resulted in being displayed as unity in the fader.
    
    This commit directly returns the value of the maximum bin, i.e. it does not map first to dbFS and then linearize the result anymore. This should work because the `Fader` class assumes a "linear" input signal and if the value of the bin was previously mapped to dbFS it should have some "linear" character. Please note that this is still somewhat of a "proxy" value because ideally the summed amplitude of all relevant bins in the frequency range would be shown and not just the "loudest" one.
    
    ## Other changes
    Rename `peakBand` to `linearPeakBand` to make more clear that a linear value is returned.
    
    Handle a potential division by zero by checking the value of `fft->getEnergy()` before using it.
    
    Index into `fft->m_bands` so that no parallel incrementing of the pointer is needed. This also enables the removal of the local variable `b`.
    michaelgregorius committed Feb 23, 2024
    Configuration menu
    Copy the full SHA
    449ab02 View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2024

  1. Improve the rendering of the levels

    The levels rendering now more explicitly distinguished between the rendering of the level outline/border and the level meters. The level rectangles are "inset" with regards to the borders so that there is a margin between the level borders and the meter readings. This margin is now also applied to the top and bottom of the levels. Levels are now also rendered as rounded rectangles similar to the level borders.
    
    Only render the levels and peaks if their values are greater than the minimum level.
    
    Make the radius of the rounded rectangles more pronounced by increasing its value from 1 to 2.
    
    Decrease the margins so that the level readings become wider, i.e. so that they are rendered with more pixels.
    
    Add the lambda `computeLevelMarkerRect` so that the rendering of the level markers is more decoupled from the rendering of the peak markers.
    michaelgregorius committed Mar 10, 2024
    Configuration menu
    Copy the full SHA
    b4bfc71 View commit details
    Browse the repository at this point in the history

Commits on Mar 22, 2024

  1. Merge remote-tracking branch 'upstream/master' into FaderInCodeWithGr…

    …adients
    
    Conflicts:
    * plugins/Eq/EqEffect.cpp
    michaelgregorius committed Mar 22, 2024
    Configuration menu
    Copy the full SHA
    6d7e7c4 View commit details
    Browse the repository at this point in the history

Commits on Apr 3, 2024

  1. Reduce code repetition

    Reduce code repetition in `EqEffect::setBandPeaks` by introducing a lambda. Adjust code formatting.
    michaelgregorius committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    f2d63ec View commit details
    Browse the repository at this point in the history
  2. Code review changes

    Code review changes in `Fader.cpp`. Mostly whitespace adjustments.
    
    Split up the calculation of the meter width to make it more understandable. This also reduces the number of parentheses.
    michaelgregorius committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    2bec339 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b3a1dd9 View commit details
    Browse the repository at this point in the history
  4. Use MEMBER instead of READ/WRITE

    Use `MEMBER` instead of `READ`/`WRITE` for some properties that are not called explicitly from outside of the class.
    michaelgregorius committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    1bd81d8 View commit details
    Browse the repository at this point in the history
  5. Use default member initializers for Fader

    Use default member initializers for the members in `Fader` that have previously been initialized in the constructor list.
    
    Mark `ampToDbfs` and `dbfsToAmp` as `constexpr`. The function `dbfsToAmp` is used in the initialzation and this way nothing has to be computed at runtime.
    michaelgregorius committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    ad8a31d View commit details
    Browse the repository at this point in the history
  6. Remove constexpr again

    Remove `constexpr` from `ampToDbfs` and ` dbfsToAmp` again because the MSVC compiler does not like it. Seems that for some reason `log10f` and `std::pow` are not `constexpr` there (at least in the version used on the build server).
    michaelgregorius committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    a65b8aa View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    dea9423 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    bb212ee View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    a74b214 View commit details
    Browse the repository at this point in the history
  10. Make code clearer

    Make code clearer in `Fader::FadermouseDoubleClickEvent`. Only divide if the dialog was accepted with OK.
    michaelgregorius committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    b0e4586 View commit details
    Browse the repository at this point in the history