Vital
Loading...
Searching...
No Matches
EnvelopeEditor Class Reference

A graphical editor for envelope shapes with interactive points and power curves. More...

#include <envelope_editor.h>

Inheritance diagram for EnvelopeEditor:
OpenGlLineRenderer SynthSlider::SliderListener OpenGlComponent

Public Member Functions

 EnvelopeEditor (const String &prefix, const vital::output_map &mono_modulations, const vital::output_map &poly_modulations)
 Constructs an EnvelopeEditor.
 
 ~EnvelopeEditor ()
 Destructor.
 
void paintBackground (Graphics &g) override
 Paints the background of the editor.
 
void resized () override
 Resized callback to layout and reposition components.
 
void resetEnvelopeLine (int index)
 Resets the envelope line for a given voice index.
 
void guiChanged (SynthSlider *slider) override
 Called when a slider value changes.
 
void setDelaySlider (SynthSlider *delay_slider)
 Sets the sliders corresponding to different envelope parameters.
 
void setAttackSlider (SynthSlider *attack_slider)
 
void setAttackPowerSlider (SynthSlider *attack_slider)
 
void setHoldSlider (SynthSlider *hold_slider)
 
void setDecaySlider (SynthSlider *decay_slider)
 
void setDecayPowerSlider (SynthSlider *decay_slider)
 
void setSustainSlider (SynthSlider *sustain_slider)
 
void setReleaseSlider (SynthSlider *release_slider)
 
void setReleasePowerSlider (SynthSlider *release_slider)
 
void setSizeRatio (float ratio)
 Sets the size ratio for UI scaling.
 
void parentHierarchyChanged () override
 Called when the component’s parent hierarchy changes.
 
void pickHoverPosition (Point< float > position)
 Determines hover state based on mouse position.
 
void mouseMove (const MouseEvent &e) override
 Mouse event callbacks for interactions.
 
void mouseExit (const MouseEvent &e) override
 
void mouseDown (const MouseEvent &e) override
 
void mouseDrag (const MouseEvent &e) override
 
void mouseDoubleClick (const MouseEvent &e) override
 
void mouseUp (const MouseEvent &e) override
 
void mouseWheelMove (const MouseEvent &e, const MouseWheelDetails &wheel) override
 Handles mouse wheel events for zooming.
 
void magnifyZoom (Point< float > delta)
 Zooms the envelope display via magnification (e.g., pinch gestures).
 
void magnifyReset ()
 Resets the magnification zoom to a default level.
 
void init (OpenGlWrapper &open_gl) override
 Initializes OpenGL resources.
 
void render (OpenGlWrapper &open_gl, bool animate) override
 Renders the envelope using OpenGL.
 
void destroy (OpenGlWrapper &open_gl) override
 Destroys the OpenGL resources.
 
void resetPositions ()
 Flags that the positions need to be reset and recalculated.
 
- 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.
 
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.
 
- Public Member Functions inherited from SynthSlider::SliderListener
virtual ~SliderListener ()
 
virtual void hoverStarted (SynthSlider *slider)
 
virtual void hoverEnded (SynthSlider *slider)
 
virtual void mouseDown (SynthSlider *slider)
 
virtual void mouseUp (SynthSlider *slider)
 
virtual void beginModulationEdit (SynthSlider *slider)
 
virtual void endModulationEdit (SynthSlider *slider)
 
virtual void menuFinished (SynthSlider *slider)
 
virtual void focusLost (SynthSlider *slider)
 
virtual void doubleClick (SynthSlider *slider)
 
virtual void modulationsChanged (const std::string &name)
 
virtual void modulationAmountChanged (SynthSlider *slider)
 
virtual void modulationRemoved (SynthSlider *slider)
 

Static Public Attributes

static constexpr float kMarkerWidth = 9.0f
 Width in pixels of the main markers (ADHSR points).
 
static constexpr float kRingThickness = 0.45f
 Thickness fraction for the marker rings.
 
static constexpr float kPowerMarkerWidth = 7.0f
 Width in pixels of the power markers (for adjusting curve power).
 
static constexpr float kMarkerHoverRadius = 12.0f
 Radius in pixels for hovering detection over markers.
 
static constexpr float kMarkerGrabRadius = 20.0f
 Radius in pixels for grabbing markers.
 
static constexpr float kTailDecay = 0.965f
 Decay factor for tail end animations.
 
static constexpr float kPaddingX = 0.018f
 Horizontal padding ratio for the display.
 
static constexpr float kPaddingY = 0.06f
 Vertical padding ratio for the display.
 
static constexpr float kMinPointDistanceForPower = 3.0f
 Minimum point distance for enabling power handle editing.
 
static constexpr float kPowerMouseMultiplier = 0.06f
 Multiplier for mouse movements when adjusting power.
 
static constexpr float kTimeDisplaySize = 0.05f
 Display size ratio for time text.
 
static constexpr int kRulerDivisionSize = 4
 Division size for major time ruler lines.
 
static constexpr int kMaxGridLines = 36
 Maximum number of grid lines displayed.
 
static constexpr int kMaxTimesShown = 24
 Maximum number of time markers shown.
 
static constexpr int kNumPointsPerSection = 98
 Number of points per envelope section.
 
static constexpr int kNumSections = 4
 Number of envelope sections (e.g., Delay->Attack->Hold->Decay->Release mapped to 4 sections plus 1 extra point).
 
static constexpr int kTotalPoints = kNumSections * kNumPointsPerSection + 1
 Total number of points for the entire envelope line.
 
- 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 OpenGlComponent
bool setViewPort (OpenGlWrapper &open_gl)
 Sets the viewport for this component using the current OpenGlWrapper.
 
- Protected Attributes inherited from OpenGlComponent
std::unique_ptr< OpenGlCornerscorners_
 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 SynthSectionparent_
 Pointer to parent SynthSection for skin lookups.
 
Skin::SectionOverride skin_override_
 Skin override for custom appearance.
 
const vital::StatusOutputnum_voices_readout_
 StatusOutput for voice count lookups.
 

Detailed Description

A graphical editor for envelope shapes with interactive points and power curves.

The EnvelopeEditor class provides an interface to visualize and edit a complex envelope (ADHSR) using interactive markers. The user can adjust delay, attack, hold, decay, sustain, and release times, as well as the curvature (power) of the envelope segments. The envelope is rendered using OpenGL and supports zooming and hovering over individual envelope points or power handles.

Constructor & Destructor Documentation

◆ EnvelopeEditor()

EnvelopeEditor::EnvelopeEditor ( const String & prefix,
const vital::output_map & mono_modulations,
const vital::output_map & poly_modulations )

Constructs an EnvelopeEditor.

Parameters
prefixPrefix for envelope parameters (e.g., "env1").
mono_modulationsA map of mono modulation outputs.
poly_modulationsA map of poly modulation outputs.

◆ ~EnvelopeEditor()

EnvelopeEditor::~EnvelopeEditor ( )

Destructor.

Member Function Documentation

◆ destroy()

void EnvelopeEditor::destroy ( OpenGlWrapper & open_gl)
overridevirtual

Destroys the OpenGL resources.

Parameters
open_glThe OpenGL wrapper.

Reimplemented from OpenGlLineRenderer.

◆ guiChanged()

void EnvelopeEditor::guiChanged ( SynthSlider * slider)
overridevirtual

Called when a slider value changes.

Parameters
sliderThe slider that changed.

Reimplemented from SynthSlider::SliderListener.

◆ init()

void EnvelopeEditor::init ( OpenGlWrapper & open_gl)
overridevirtual

Initializes OpenGL resources.

Parameters
open_glThe OpenGL wrapper.

Reimplemented from OpenGlLineRenderer.

◆ magnifyReset()

void EnvelopeEditor::magnifyReset ( )

Resets the magnification zoom to a default level.

◆ magnifyZoom()

void EnvelopeEditor::magnifyZoom ( Point< float > delta)

Zooms the envelope display via magnification (e.g., pinch gestures).

Parameters
deltaScroll delta for magnification.

◆ mouseDoubleClick()

void EnvelopeEditor::mouseDoubleClick ( const MouseEvent & e)
override

◆ mouseDown()

void EnvelopeEditor::mouseDown ( const MouseEvent & e)
override

◆ mouseDrag()

void EnvelopeEditor::mouseDrag ( const MouseEvent & e)
override

◆ mouseExit()

void EnvelopeEditor::mouseExit ( const MouseEvent & e)
override

◆ mouseMove()

void EnvelopeEditor::mouseMove ( const MouseEvent & e)
override

Mouse event callbacks for interactions.

◆ mouseUp()

void EnvelopeEditor::mouseUp ( const MouseEvent & e)
override

◆ mouseWheelMove()

void EnvelopeEditor::mouseWheelMove ( const MouseEvent & e,
const MouseWheelDetails & wheel )
override

Handles mouse wheel events for zooming.

Parameters
eMouse event.
wheelWheel details.

◆ paintBackground()

void EnvelopeEditor::paintBackground ( Graphics & g)
overridevirtual

Paints the background of the editor.

Parameters
gGraphics context.

Reimplemented from OpenGlComponent.

◆ parentHierarchyChanged()

void EnvelopeEditor::parentHierarchyChanged ( )
overridevirtual

Called when the component’s parent hierarchy changes.

Reimplemented from OpenGlComponent.

◆ pickHoverPosition()

void EnvelopeEditor::pickHoverPosition ( Point< float > position)

Determines hover state based on mouse position.

Parameters
positionThe mouse position.

◆ render()

void EnvelopeEditor::render ( OpenGlWrapper & open_gl,
bool animate )
overridevirtual

Renders the envelope using OpenGL.

Parameters
open_glThe OpenGL wrapper.
animateWhether to animate the line based on current voice states.

Reimplemented from OpenGlLineRenderer.

◆ resetEnvelopeLine()

void EnvelopeEditor::resetEnvelopeLine ( int index)

Resets the envelope line for a given voice index.

Parameters
indexVoice index (-1 for default envelope).

◆ resetPositions()

void EnvelopeEditor::resetPositions ( )
inline

Flags that the positions need to be reset and recalculated.

◆ resized()

void EnvelopeEditor::resized ( )
inlineoverridevirtual

Resized callback to layout and reposition components.

Reimplemented from OpenGlComponent.

◆ setAttackPowerSlider()

void EnvelopeEditor::setAttackPowerSlider ( SynthSlider * attack_slider)

◆ setAttackSlider()

void EnvelopeEditor::setAttackSlider ( SynthSlider * attack_slider)

◆ setDecayPowerSlider()

void EnvelopeEditor::setDecayPowerSlider ( SynthSlider * decay_slider)

◆ setDecaySlider()

void EnvelopeEditor::setDecaySlider ( SynthSlider * decay_slider)

◆ setDelaySlider()

void EnvelopeEditor::setDelaySlider ( SynthSlider * delay_slider)

Sets the sliders corresponding to different envelope parameters.

◆ setHoldSlider()

void EnvelopeEditor::setHoldSlider ( SynthSlider * hold_slider)

◆ setReleasePowerSlider()

void EnvelopeEditor::setReleasePowerSlider ( SynthSlider * release_slider)

◆ setReleaseSlider()

void EnvelopeEditor::setReleaseSlider ( SynthSlider * release_slider)

◆ setSizeRatio()

void EnvelopeEditor::setSizeRatio ( float ratio)
inline

Sets the size ratio for UI scaling.

Parameters
ratioThe new size ratio.

◆ setSustainSlider()

void EnvelopeEditor::setSustainSlider ( SynthSlider * sustain_slider)

Member Data Documentation

◆ kMarkerGrabRadius

float EnvelopeEditor::kMarkerGrabRadius = 20.0f
staticconstexpr

Radius in pixels for grabbing markers.

◆ kMarkerHoverRadius

float EnvelopeEditor::kMarkerHoverRadius = 12.0f
staticconstexpr

Radius in pixels for hovering detection over markers.

◆ kMarkerWidth

float EnvelopeEditor::kMarkerWidth = 9.0f
staticconstexpr

Width in pixels of the main markers (ADHSR points).

◆ kMaxGridLines

int EnvelopeEditor::kMaxGridLines = 36
staticconstexpr

Maximum number of grid lines displayed.

◆ kMaxTimesShown

int EnvelopeEditor::kMaxTimesShown = 24
staticconstexpr

Maximum number of time markers shown.

◆ kMinPointDistanceForPower

float EnvelopeEditor::kMinPointDistanceForPower = 3.0f
staticconstexpr

Minimum point distance for enabling power handle editing.

◆ kNumPointsPerSection

int EnvelopeEditor::kNumPointsPerSection = 98
staticconstexpr

Number of points per envelope section.

◆ kNumSections

int EnvelopeEditor::kNumSections = 4
staticconstexpr

Number of envelope sections (e.g., Delay->Attack->Hold->Decay->Release mapped to 4 sections plus 1 extra point).

◆ kPaddingX

float EnvelopeEditor::kPaddingX = 0.018f
staticconstexpr

Horizontal padding ratio for the display.

◆ kPaddingY

float EnvelopeEditor::kPaddingY = 0.06f
staticconstexpr

Vertical padding ratio for the display.

◆ kPowerMarkerWidth

float EnvelopeEditor::kPowerMarkerWidth = 7.0f
staticconstexpr

Width in pixels of the power markers (for adjusting curve power).

◆ kPowerMouseMultiplier

float EnvelopeEditor::kPowerMouseMultiplier = 0.06f
staticconstexpr

Multiplier for mouse movements when adjusting power.

◆ kRingThickness

float EnvelopeEditor::kRingThickness = 0.45f
staticconstexpr

Thickness fraction for the marker rings.

◆ kRulerDivisionSize

int EnvelopeEditor::kRulerDivisionSize = 4
staticconstexpr

Division size for major time ruler lines.

◆ kTailDecay

float EnvelopeEditor::kTailDecay = 0.965f
staticconstexpr

Decay factor for tail end animations.

◆ kTimeDisplaySize

float EnvelopeEditor::kTimeDisplaySize = 0.05f
staticconstexpr

Display size ratio for time text.

◆ kTotalPoints

int EnvelopeEditor::kTotalPoints = kNumSections * kNumPointsPerSection + 1
staticconstexpr

Total number of points for the entire envelope line.


The documentation for this class was generated from the following files: