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

New vector graph implementation #7158

Open
wants to merge 126 commits into
base: master
Choose a base branch
from
Open

New vector graph implementation #7158

wants to merge 126 commits into from

Conversation

szeli1
Copy link
Contributor

@szeli1 szeli1 commented Mar 23, 2024

This pull request adds a new widget to LMMS called VectorGraph.
This widget has been implemented in the WaveShaper effect.
A new effect called "FFTFilter" was planned but removed from the final pull request.

I consider this pull request finished.

There was one vector graph implementation before this in pr #4367.

This new widget does not have a fixed size (unlike Graph.h) and uses points for the base graph instead of samples. This allows better workflow and smoother output. The lines (and samples) between points are automatically generated in paintEvent. The graph supports outputs with custom sample count. The graph supports different types of lines such as "sine", "peak", "steps", "random". The graph also supports automatable point attributes and interaction between two graphs inside the same widget (called "effector graphs").
The changes are compatible with older versions.

How to use:
Press somewhere in the widget with left click to add a new point.
Delete points by pressing right click and dragging over them.
Click a point with left click to select it. This will show an editing menu. Whit the menu almost all of the point attributes are editable. VectorGraphDataArray can block access to some attribute settings if setup correctly.
In editing mode double click with the left mouse button on a float attribute to show an input dialog.
In editing mode drag the widget to an automationTrack with ctrl + left mouse to connect it. Automated points will show up with a different color.
The user can remove the automation by clicking on an attribute with the right mouse button. This will show a context menu with the full name of the attribute at the top.
By clicking the top left square, the user can change the currently edited VectorGraphDataArray. The number in the top left corner shows the currently edited VectorGraphDataArray's location in VectorGraphModel m_dataArrays.
By double left clicking on a point, an input dialog shows up which can edit the x and y position of the point.
The point's line type can be selected by pressing the "switch graph line type" setting in editing mode. The "1. attribute value" and the "2. attribute value" setting is used different ways in different line types.
The point's automated and effected float attribute can be selected by pressing the "switch graph automated value" and "switch graph effected value" setting in editing mode. Only one attribute can be effected or automated from the 4 automatable attributes (y coordinate, curve, valueA ("1. attribute value"), valueB ("2. attribute value")).
How one graph effects the other can be changed in editing mode with the effect settings. In WaveShaper these settings allow the green graph to be effected with the white graph. These settings allow more easy automation and different interactions between the 2 graph such as "add" and "clamp". Use these effects by selecting a point on the green graph (in this case) and clicking on different effects to enable them. An example which these effects can be useful is when a VectorGraphDataArray is used for displaying a sound frequency spectrum, and an other VectorGraphDataArray can interact with these constantly changing graph points.

Different implementations can give different restrictions to different VectorGraphDataArrays.

these images are currently outdated
Finished1
Finished2
Finished3
Finished5

TODO list:

  • rewrite comments

  • rename functions and values

  • test all the features / settings

  • do TODO-s

  • automation:

  • -- add automation support:

  • -- save FloatModels

  • -- safe deletion (currently not safe??) needs testing

  • event when a dataArray's size gets to 0

  • scaled graph option in VectorGraphView which scales the last used output to be displayed in the widget (does not call getValues (renamed to getSamples)). need testing

  • call dataChanged() in setDataArray

  • journalling in PointGraphModel

  • setDataArray keep attributes option, formatArray option which runs formatArray

  • context menu in gui (clear automation, connect to controller)

  • display hints (full text) while editing

  • ability to edit multiple graphs using m_isLastSelectedArray

  • handle effector arrays when deleting VectorGraphDataArray

  • update formatArray

  • licensing email

  • new button in gui which switches between the currently selected graphs

  • add new effects: clamp

  • dragging

  • redo clamps

  • filter implementation

  • remove qDebug

Finished4

Final WaveShaper VectorGraph implementation:
Finished10
Finished11
Finished12
Different VectorGraphDataArrays effecting each other, one is automated:
Finished13
Finished14

Keep in mind that this widget can have harmful bugs/errors.
Feel free to make suggestions and criticize my coding style / decisions.

@szeli1 szeli1 marked this pull request as draft March 23, 2024 20:32
@szeli1
Copy link
Contributor Author

szeli1 commented May 4, 2024

Added new class and moved the input dialog and the context menu there.
This does not effect any reviewed code up to this point. (but the new class needs to be reviewed)

@szeli1 szeli1 requested a review from Veratil May 4, 2024 15:10
@szeli1
Copy link
Contributor Author

szeli1 commented May 6, 2024

Added new m_isAnEffector bool and related get and set, removed more than 4 heap allocations. Separated m_effectOnlyPoints to m_effectPoints and m_effectLines allowing better transitions between automated points.

@szeli1
Copy link
Contributor Author

szeli1 commented May 7, 2024

Most of the heap allocations were removed.
In the current configuration:
The best case for PaintEvent is 0 heap allocations.
The worst case for PaintEvent is 1 heap allocation.
The best case for updating the samples (getSamples()) is 0 heap allocations.
A reasonable worst case for updating the samples is 4 heap allocations.

This is after removing 9 heap allocations.

Added new button in WaveShaper for simplifying the graph. This can improve performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants