|
Vital
|
An editor component for displaying and editing an LFO (Low-Frequency Oscillator) shape. More...
#include <lfo_editor.h>
Public Types | |
| enum | { kSetPhaseToPoint = kNumMenuOptions , kSetPhaseToPower , kSetPhaseToGrid , kImportLfo , kExportLfo } |
Public Types inherited from LineEditor | |
| enum | MenuOptions { kCancel , kCopy , kPaste , kSave , kEnterPhase , kEnterValue , kResetPower , kRemovePoint , kInit , kFlipHorizontal , kFlipVertical , kNumMenuOptions } |
| Context menu options available in the line editor. More... | |
Public Member Functions | |
| LfoEditor (LineGenerator *lfo_source, String prefix, const vital::output_map &mono_modulations, const vital::output_map &poly_modulations) | |
| Constructs the LfoEditor. | |
| virtual | ~LfoEditor () |
| Destructor. | |
| void | parentHierarchyChanged () override |
| Called when the component’s parent hierarchy changes. | |
| virtual void | mouseDown (const MouseEvent &e) override |
| Handles mouse down events. | |
| virtual void | mouseDoubleClick (const MouseEvent &e) override |
| Handles mouse double-click events. | |
| virtual void | mouseUp (const MouseEvent &e) override |
| Handles mouse up events. | |
| void | respondToCallback (int point, int power, int result) override |
| Responds to selection callbacks from the popup menu. | |
| void | setPhase (float phase) |
| Sets the LFO’s start phase. | |
| void | render (OpenGlWrapper &open_gl, bool animate) override |
| Renders the LFO editor using OpenGL. | |
Public Member Functions inherited from LineEditor | |
| LineEditor (LineGenerator *line_source) | |
| Constructs the LineEditor. | |
| virtual | ~LineEditor () |
| Destructor. | |
| void | resetWavePath () |
| Resets the wave path, recalculating positions based on current points and powers. | |
| void | resized () override |
| Called when the component is resized. | |
| float | padY (float y) |
| Pads a Y coordinate to fit the drawing area with vertical padding. | |
| float | unpadY (float y) |
| Removes padding from a padded Y coordinate. | |
| float | padX (float x) |
| Pads an X coordinate to fit the drawing area with horizontal padding. | |
| float | unpadX (float x) |
| Removes padding from a padded X coordinate. | |
| virtual void | mouseMove (const MouseEvent &e) override |
| virtual void | mouseDrag (const MouseEvent &e) override |
| bool | hasMatchingSystemClipboard () |
| Checks if the system clipboard contains a compatible line data JSON. | |
| void | paintLine (const MouseEvent &e) |
| Paints the line by adding points according to a pattern when in paint mode. | |
| void | drawDown (const MouseEvent &e) |
| Handles the initial mouse press (not in paint mode) for dragging points or powers. | |
| void | drawDrag (const MouseEvent &e) |
| Handles mouse dragging to move points or adjust powers. | |
| void | drawUp (const MouseEvent &e) |
| Handles mouse release to finalize point or power positions. | |
| void | mouseWheelMove (const MouseEvent &e, const MouseWheelDetails &wheel) override |
| void | mouseExit (const MouseEvent &e) override |
| void | clearActiveMouseActions () |
| void | renderGrid (OpenGlWrapper &open_gl, bool animate) |
| Renders the grid lines that show snapping lines or painting sections. | |
| void | renderPoints (OpenGlWrapper &open_gl, bool animate) |
| Renders the points and power handles on the curve. | |
| void | init (OpenGlWrapper &open_gl) override |
| Initializes OpenGL resources for rendering the line. | |
| void | render (OpenGlWrapper &open_gl, bool animate) override |
| Renders the line using OpenGL. | |
| void | destroy (OpenGlWrapper &open_gl) override |
| Destroys OpenGL resources allocated by this line renderer. | |
| void | setSizeRatio (float ratio) |
| Sets the size ratio, scaling UI elements accordingly. | |
| float | sizeRatio () const |
| Gets the current size ratio. | |
| void | setLoop (bool loop) |
| Enables or disables looping of the line at the edges. | |
| void | setSmooth (bool smooth) |
| Enables or disables smoothing of the curve. | |
| bool | getSmooth () const |
| Checks if smoothing is enabled. | |
| void | setPaint (bool paint) |
| Enables or disables paint mode. | |
| void | setPaintPattern (std::vector< std::pair< float, float > > pattern) |
| Sets a pattern of points used when painting the line. | |
| virtual void | setGridSizeX (int size) |
| Sets the horizontal grid size. | |
| virtual void | setGridSizeY (int size) |
| Sets the vertical grid size. | |
| int | getGridSizeX () |
| Gets the current horizontal grid size. | |
| int | getGridSizeY () |
| Gets the current vertical grid size. | |
| void | setModel (LineGenerator *model) |
| Sets the LineGenerator model defining the curve. | |
| LineGenerator * | getModel () |
| Gets the current LineGenerator model. | |
| void | showTextEntry () |
| Shows the text editor for entering a precise value or phase. | |
| void | hideTextEntry () |
| Hides the text entry editor. | |
| void | textEditorReturnKeyPressed (TextEditor &editor) override |
| void | textEditorFocusLost (TextEditor &editor) override |
| void | textEditorEscapeKeyPressed (TextEditor &editor) override |
| void | setSliderPositionFromText () |
| Sets the position of the selected point/power from the text field. | |
| void | setAllowFileLoading (bool allow) |
| Allows or disallows file loading actions (copy/paste from files). | |
| void | addListener (Listener *listener) |
| Adds a listener for line editor events. | |
| void | setActive (bool active) |
| Sets whether the line editor is active (enabled). | |
| force_inline void | resetPositions () |
| Marks positions as needing recalculation on next render. | |
| OpenGlComponent * | getTextEditorComponent () |
| Gets the OpenGlComponent for text editing (if any). | |
Public Member Functions inherited from OpenGlLineRenderer | |
| OpenGlLineRenderer (int num_points, bool loop=false) | |
| Constructs an OpenGlLineRenderer for a given number of points. | |
| virtual | ~OpenGlLineRenderer () |
| Destructor. | |
| force_inline void | setColor (Colour color) |
| Sets the line color. | |
| force_inline void | setLineWidth (float width) |
| Sets the line width in pixels. | |
| force_inline void | setBoost (float boost) |
| Sets a global boost value affecting line thickness. | |
| force_inline float | boostLeftAt (int index) const |
| Gets the left-side boost at a given point index. | |
| force_inline float | boostRightAt (int index) const |
| Gets the right-side boost at a given point index. | |
| force_inline float | yAt (int index) const |
| Gets the y-coordinate of a point at a given index. | |
| force_inline float | xAt (int index) const |
| Gets the x-coordinate of a point at a given index. | |
| force_inline void | setBoostLeft (int index, float val) |
| Sets the left-side boost for a point, marking data as dirty. | |
| force_inline void | setBoostRight (int index, float val) |
| Sets the right-side boost for a point, marking data as dirty. | |
| force_inline void | setYAt (int index, float val) |
| Sets the y-coordinate of a point, marking data as dirty. | |
| force_inline void | setXAt (int index, float val) |
| Sets the x-coordinate of a point, marking data as dirty. | |
| void | setFillVertices (bool left) |
| Sets fill vertices according to the current line and boost data. | |
| void | setLineVertices (bool left) |
| Sets line vertices according to the current line and boost data. | |
| force_inline void | setFill (bool fill) |
| Enables or disables filling below the line. | |
| force_inline void | setFillColor (Colour fill_color) |
| Sets a uniform fill color if only one color is needed. | |
| force_inline void | setFillColors (Colour fill_color_from, Colour fill_color_to) |
| Sets a gradient fill from one color to another. | |
| force_inline void | setFillCenter (float fill_center) |
| Sets the vertical center for the fill area. | |
| force_inline void | setFit (bool fit) |
| Enables fitting the line inside the available area. | |
| force_inline void | setBoostAmount (float boost_amount) |
| Sets the boost amount that affects line thickness. | |
| force_inline void | setFillBoostAmount (float boost_amount) |
| Sets the boost amount that affects fill thickness. | |
| force_inline void | setIndex (int index) |
| Sets an index used for custom behavior (e.g., multiple line sets). | |
| void | boostLeftRange (float start, float end, int buffer_vertices, float min) |
| Boosts left-side range of the line. | |
| void | boostRightRange (float start, float end, int buffer_vertices, float min) |
| Boosts right-side range of the line. | |
| void | boostRange (float *boosts, float start, float end, int buffer_vertices, float min) |
| Boosts a range for the given boost array. | |
| void | boostRange (vital::poly_float start, vital::poly_float end, int buffer_vertices, vital::poly_float min) |
| Boosts left and right arrays using poly_float parameters. | |
| void | decayBoosts (vital::poly_float mult) |
| Decays all boosts by a multiplicative factor, allowing animated damping. | |
| void | enableBackwardBoost (bool enable) |
| Enables backward boost calculation for symmetrical line deformation. | |
| force_inline int | numPoints () const |
| Gets the number of points in the line. | |
| force_inline Colour | color () const |
| Gets the current line color. | |
| void | drawLines (OpenGlWrapper &open_gl, bool left) |
| Draws the line and optional fill using OpenGL. | |
| bool | anyBoostValue () |
| Checks if any boost value is set. | |
Public Member Functions inherited from OpenGlComponent | |
| OpenGlComponent (String name="") | |
| Constructs an OpenGlComponent. | |
| virtual | ~OpenGlComponent () |
| Destructor. | |
| void | addRoundedCorners () |
| Adds rounded corners to the component's edges. | |
| void | addBottomRoundedCorners () |
| Adds rounded corners only at the bottom of the component. | |
| void | renderCorners (OpenGlWrapper &open_gl, bool animate, Colour color, float rounding) |
| Renders the corner shapes using the given color and rounding amount. | |
| void | renderCorners (OpenGlWrapper &open_gl, bool animate) |
| Renders corners with default body color and rounding. | |
| virtual void | paintBackground (Graphics &g) |
| Paints a standard background for the component. | |
| void | repaintBackground () |
| Requests a repaint of the component's background on the OpenGL layer. | |
| Colour | getBodyColor () const |
| Retrieves the component's body color. | |
| void | setParent (const SynthSection *parent) |
| Sets a pointer to the parent SynthSection for skin value lookups. | |
| float | findValue (Skin::ValueId value_id) |
| Finds a float value from the skin associated with this component's parent. | |
| void | setSkinValues (const Skin &skin) |
| Applies the skin overrides to this component's colors. | |
| void | setSkinOverride (Skin::SectionOverride skin_override) |
| Sets a skin override to control the component's color scheme. | |
| force_inline void | checkGlError () |
| Checks for and asserts that there are no OpenGL errors. | |
| void | setBackgroundColor (const Colour &color) |
| Sets the background color of the component for painting operations. | |
Static Public Attributes | |
| static constexpr float | kBoostDecay = 0.9f |
| Decay factor used when reducing boost intensity over time. | |
| static constexpr float | kSpeedDecayMult = 5.0f |
| Multiplier for adjusting boost decay speed depending on phase changes. | |
Static Public Attributes inherited from LineEditor | |
| static constexpr float | kPositionWidth = 9.0f |
| Width in pixels for main position markers. | |
| static constexpr float | kPowerWidth = 7.0f |
| Width in pixels for power markers (curve shaping handles). | |
| static constexpr float | kRingThickness = 0.45f |
| Fractional thickness for marker ring rendering. | |
| static constexpr float | kGrabRadius = 12.0f |
| Radius in pixels for detecting grabbing a point or power handle. | |
| static constexpr float | kDragRadius = 20.0f |
| Radius in pixels for dragging a point or power handle. | |
| static constexpr int | kResolution = 64 |
| Resolution used for intermediate line calculations. | |
| static constexpr int | kNumWrapPoints = 8 |
| Number of wrap points for looping lines. | |
| static constexpr int | kDrawPoints = kResolution + LineGenerator::kMaxPoints |
| Number of points drawn: resolution plus max points from LineGenerator. | |
| static constexpr int | kTotalPoints = kDrawPoints + 2 * kNumWrapPoints |
| Total points including wrap-around. | |
| static constexpr int | kMaxGridSizeX = 32 |
| Maximum grid sizes for horizontal and vertical lines. | |
| static constexpr int | kMaxGridSizeY = 24 |
| static constexpr float | kPaddingY = 6.0f |
| Vertical padding in pixels. | |
| static constexpr float | kPaddingX = 0.0f |
| Horizontal padding in pixels. | |
| static constexpr float | kPowerMouseMultiplier = 9.0f |
| Multiplier for mouse movements when adjusting power handles. | |
| static constexpr float | kMinPointDistanceForPower = 3.0f |
| Minimum horizontal distance (in pixels) between points to show power handles. | |
Static Public Attributes inherited from OpenGlLineRenderer | |
| static constexpr int | kLineFloatsPerVertex = 3 |
| Floats per vertex in the line data (x, y, and potentially others). | |
| static constexpr int | kFillFloatsPerVertex = 4 |
| Floats per vertex in the fill data (x, y, and boost value). | |
| static constexpr int | kLineVerticesPerPoint = 6 |
| Number of vertices per point in the line representation. | |
| static constexpr int | kFillVerticesPerPoint = 2 |
| Number of vertices per point in the fill representation. | |
| static constexpr int | kLineFloatsPerPoint = kLineVerticesPerPoint * kLineFloatsPerVertex |
| Floats per point in the line data (6 vertices * 3 floats each). | |
| static constexpr int | kFillFloatsPerPoint = kFillVerticesPerPoint * kFillFloatsPerVertex |
| Floats per point in the fill data (2 vertices * 4 floats each). | |
Additional Inherited Members | |
Static Public Member Functions inherited from OpenGlComponent | |
| static bool | setViewPort (Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl) |
| Sets the OpenGL viewport to match a specified rectangle within a component. | |
| static bool | setViewPort (Component *component, OpenGlWrapper &open_gl) |
| Convenience overload that sets the viewport for the entire component's local bounds. | |
| static void | setScissor (Component *component, OpenGlWrapper &open_gl) |
| Sets the OpenGL scissor region to the entire component's local bounds. | |
| static void | setScissorBounds (Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl) |
| Sets the OpenGL scissor region to a specified rectangle within a component. | |
| static std::unique_ptr< OpenGLShaderProgram::Uniform > | getUniform (const OpenGlWrapper &open_gl, const OpenGLShaderProgram &program, const char *name) |
| Retrieves a uniform from the shader program if it exists. | |
| static std::unique_ptr< OpenGLShaderProgram::Attribute > | getAttribute (const OpenGlWrapper &open_gl, const OpenGLShaderProgram &program, const char *name) |
| Retrieves an attribute from the shader program if it exists. | |
| static String | translateFragmentShader (const String &code) |
| Translates a fragment shader code snippet to be compatible with the current GL version. | |
| static String | translateVertexShader (const String &code) |
| Translates a vertex shader code snippet to be compatible with the current GL version. | |
Protected Member Functions inherited from LineEditor | |
| void | drawPosition (OpenGlWrapper &open_gl, Colour color, float fraction_x) |
| Draws a position marker at a specific fraction of the X-axis. | |
| void | setEditingCircleBounds () |
| Sets bounds for the editing circles (hover and drag indicators). | |
| void | setGridPositions () |
| Calculates and sets positions for grid lines. | |
| void | setPointPositions () |
| Calculates and sets positions for point and power handle quads. | |
| void | setGlPositions () |
| Updates OpenGL buffers with the latest positions if needed. | |
| int | getActivePoint () |
| Gets the currently active point index. | |
| int | getActivePower () |
| Gets the currently active power handle index. | |
| int | getActiveGridSection () |
| Gets the currently active grid section index for painting. | |
| bool | isPainting () |
| Checks if painting mode is currently active. | |
| bool | isPaintEnabled () |
| Checks if paint mode is globally enabled. | |
| vital::poly_float | adjustBoostPhase (vital::poly_float phase) |
| Adjusts a given phase value for boost calculations. | |
| virtual void | enableTemporaryPaintToggle (bool toggle) |
| Temporarily enables or disables paint mode using a toggle (e.g., via a modifier key). | |
Protected Member Functions inherited from OpenGlComponent | |
| bool | setViewPort (OpenGlWrapper &open_gl) |
| Sets the viewport for this component using the current OpenGlWrapper. | |
Protected Attributes inherited from LineEditor | |
| bool | active_ |
| std::vector< Listener * > | listeners_ |
Protected Attributes inherited from OpenGlComponent | |
| std::unique_ptr< OpenGlCorners > | corners_ |
| Optional corners for rounded edges. | |
| bool | only_bottom_corners_ |
| Flag to round only the bottom corners. | |
| Colour | background_color_ |
| The background color of the component. | |
| Colour | body_color_ |
| The body color of the component. | |
| const SynthSection * | parent_ |
| Pointer to parent SynthSection for skin lookups. | |
| Skin::SectionOverride | skin_override_ |
| Skin override for custom appearance. | |
| const vital::StatusOutput * | num_voices_readout_ |
| StatusOutput for voice count lookups. | |
An editor component for displaying and editing an LFO (Low-Frequency Oscillator) shape.
The LfoEditor allows for interactive manipulation of an LFO curve. Users can set LFO points, adjust the phase, import/export LFO shapes, and apply transformations like flipping horizontally or vertically. This component integrates with the synth’s internal LFO system and updates in real-time based on the current LFO phase and frequency.
| anonymous enum |
| LfoEditor::LfoEditor | ( | LineGenerator * | lfo_source, |
| String | prefix, | ||
| const vital::output_map & | mono_modulations, | ||
| const vital::output_map & | poly_modulations ) |
Constructs the LfoEditor.
| lfo_source | The LineGenerator representing the LFO’s internal data source. |
| prefix | A string prefix to identify this LFO (e.g., "lfo1"). |
| mono_modulations | Map of mono modulation outputs. |
| poly_modulations | Map of poly modulation outputs. |
|
virtual |
Destructor.
|
overridevirtual |
Handles mouse double-click events.
| e | The mouse event. |
Double-clicking interacts with the editor points or power handles. Delegates to LineEditor for default behavior.
Reimplemented from LineEditor.
|
overridevirtual |
Handles mouse down events.
| e | The mouse event. |
Displays a context menu if the user right-clicks (popup menu). Otherwise, delegates to LineEditor.
Reimplemented from LineEditor.
|
overridevirtual |
Handles mouse up events.
| e | The mouse event. |
If no popup menu was open, delegates to LineEditor’s default behavior.
Reimplemented from LineEditor.
|
overridevirtual |
Called when the component’s parent hierarchy changes.
Used to find the SynthGuiInterface parent and to locate LFO-related status outputs such as phase and frequency.
Reimplemented from OpenGlComponent.
|
overridevirtual |
Renders the LFO editor using OpenGL.
| open_gl | The OpenGL wrapper. |
| animate | Whether to animate the LFO curve or not. |
Reimplemented from OpenGlLineRenderer.
|
overridevirtual |
Responds to selection callbacks from the popup menu.
| point | The currently active point index, or -1 if none. |
| power | The currently active power handle index, or -1 if none. |
| result | The selected menu item ID. |
Reimplemented from LineEditor.
| void LfoEditor::setPhase | ( | float | phase | ) |
Sets the LFO’s start phase.
| phase | The phase value to set (0.0 to 1.0). |
|
staticconstexpr |
Decay factor used when reducing boost intensity over time.
|
staticconstexpr |
Multiplier for adjusting boost decay speed depending on phase changes.