-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Vectorscope render fix #7652
Vectorscope render fix #7652
Conversation
The rendering of the Vectorscope is broken on Wayland if the size of the Vectorscope is increased. This is caused by using a `QImage` to render the scope traces which is then scaled up. Introduce a new way to paint the vector scope (goniometer) which simply paints lines or points that progressively get dimmer and which does not make use of a QImage anymore. It supports the following features: * Log mode * Zooming * Rendering the drawing performance * Selecting a different color for the traces It does not support: * HQ Mode: The new implementation provides a performance that's equivalent to Non-HQ mode. * Blurring of old data * Persistence: Might be implemented by using a factor for the dimming This commit introduces new controls: * Lines mode: Switches between painting lines or points in the new implementation * Legacy mode: Use to switch between the new and the old rendering. Only used during development as the old mode will be removed completely. Rendering of the samples/trances uses the composition mode "Plus" so that overlapping elements will appear like adding brightness. Painting the grid and lines is done using the normal composition mode "Source Over" so that it simply replaces existing pixels. Painting of the lines/points and the grids and lines is done in a "signal space", i.e. a transform where elements in the interval of [-1, 1] feel "natural". The text is painted in "widget space". The "HQ" button and the "Persistence" knob have been temporarily made members so that they can be hidden in non-legacy mode. They will later be removed completely. Rendering in "Log" mode currently paints a horizontal line for silence. It needs to be investigated why this is the case. It's likely caused by the division by the distance of the points from the origin. If this becomes very small (and non-zero) then the division might produce large values.
Use the `SampleFrame` representation as long as possible when doing the calculations in the paint method.
Remove HQ mode and persistence. Also remove the legacy option again. This removes the models, loading, saving and the GUI controls. Remove all unnecessary members from `VectorView`, adjust the constructor. Move the implementation of `paintLinesMode` into `paintEvent`. Remove methods `paintLegacyMode` and `paintLinesMode`.
Move the colors out of `VecControls` into `VectorView` as they are related to presentation.
Remove a friend relationship to `VectorView` from `VecControls` by introducing const getters for the models.
Remove the unnecessary member `m_visible` from `VectorView`. It was not initialized and only written to but never read.
Make the Vectorscope themeable by introducing Qt properties for the relevant colors. The default theme gets the values from the code whereas the classic theme gets a trace with amber color.
Rename `m_colorFG` to `m_colorTrace`. Adjust the Qt property accordingly. Remove local variable `traceColor` from paint method and use member `m_colorTrace` directly.
Remove unused member `m_colorOutline`.
Fix the horizontal lines that are rendered on silence. They seem to be produced when rendering lines that start and end at the same point. Therefore we only draw a point if the current and last point are the same.
Add some margin to the rendering of the `VectorView` so that the circle does not touch the bounary of the widget.
Clean up the layout of the Vectorscope. The checkboxes are not put on top of the vector view anymore but are organized in a horizontal layout beneath it. This gives a much tidier look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the simplified UI, and the performance improvements are impressive!
Did a quick look-over review - looks pretty good to me.
I'll test it out within the next couple days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it on Linux Mint 22 (X11), and it worked well.
I did not have time to play around with it yet, but the performance improvements and GUI polish look great. Thanks for your work. 👍 The only things I'm worried about is the lack of persistence setting and the bright dots between line segments. The bright dots probably do not matter much in the context of a DAW utility, but they will make playback of thing like "oscilloscope music" look bad (e.g. https://www.youtube.com/watch?v=XziuEdpVUe0 – the album this comes from was basically my benchmark for Vectorscope development :) ). Getting close to an analog trace was the main motivation for including the HQ mode, even though I could not figure out how to make it perform better. The persistence setting (how fast the trace should fade) is somewhat connected to that; it allows you to better match the behavior of a real analog trace. If the display gets too cluttered, reduce persistence. If you want to watch a very slow signal, increase it or set it to 1 (no fading) to keep more of the history visible. Again, probably not super important to be useful in a DAW, but takes away a lot of flexibility. (Just to be clear, I'm not asking for anything to be fixed or added back; just commenting on why things were the way they were. High performance code that works on all platforms is definitely preferable over the previous state. If it bothers me after I update, I can always open a PR myself.. :) ) |
@he29-net, I completely agree that there is still lots of room for improvement. The dots appear because the code paints individual lines which progressively get fainter. It does so using the "Plus" composition mode so that overlapping lines result in the overlaps being brighter similar to how it was done before. Unfortunately, this also applies to the start and end points of the individual line segments. To get around this one might paint poly lines but then it is in turn not possible to fade them. A more radical solution that would bring more freedom would be to use shaders to render the scope. Some days ago I have found a link to the following oscilloscope by chance on Hacker News: https://dood.al/oscilloscope/. I think it looks great and would likely also make oscillator music look much more appealing. Due to being a web application the shaders are available and could be ported with some effort. |
The rendering of the Vectorscope is broken on Wayland if the size of the Vectorscope is increased. This is caused by using a
QImage
to render the scope traces which is then scaled up.The fix introduce a new implementation of the paint method which simply paints lines or points that progressively get dimmer without using a
QImage
anymore. It is possible to switch between rendering lines or points using the "Lines" control.The following shows a comparison between the old and the new implementation (using commit c0538b1). It shows the performance difference and switching between rendering lines and points with the new implementation:
LMMS-VectorScopeExecutionTimes.webm
Feature changes
It supports the following pre-existing features:
It does not support anymore:
Style sheets
The Vectorscope now supports style sheets by introducing Qt properties for the relevant colors. The default theme gets the values from the code whereas the classic theme gets a trace with amber color.
Technical details
Rendering of the samples/trances uses the composition mode "Plus" so that overlapping elements will appear like adding brightness. Painting the grid and lines is done using the normal composition mode "Source Over" so that it simply replaces existing pixels.
Painting of the lines/points and the grids and lines is done in a "signal space", i.e. a transform where elements in the interval of [-1, 1] feel "natural". The text is painted in "widget space".
Other changes
VecControls
intoVectorView
as they are related to presentation.VectorView
fromVecControls
by introducing const getters for the models.m_visible
fromVectorView
. It was not initialized and only written to but never read.m_colorFG
tom_colorTrace
.Fixes #7518.