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

A visualization component for an equalizer or filter response curve. More...

#include <equalizer_response.h>

Inheritance diagram for EqualizerResponse:
OpenGlLineRenderer SynthSlider::SliderListener OpenGlComponent

Classes

class  Listener
 Interface for objects that want to be notified when a band is selected. More...
 

Public Member Functions

 EqualizerResponse ()
 Constructs an EqualizerResponse component.
 
 ~EqualizerResponse ()
 Destructor.
 
void initEq (const vital::output_map &mono_modulations)
 Initializes the Equalizer response for a standard 3-band EQ using the provided outputs.
 
void initReverb (const vital::output_map &mono_modulations)
 Initializes the Equalizer response for a reverb's shelving EQ.
 
virtual void init (OpenGlWrapper &open_gl) override
 Initializes OpenGL resources.
 
virtual void render (OpenGlWrapper &open_gl, bool animate) override
 Renders the EQ response and control points.
 
virtual void destroy (OpenGlWrapper &open_gl) override
 Destroys OpenGL resources.
 
void setControlPointBounds (float selected_x, float selected_y, float unselected_x1, float unselected_y1, float unselected_x2, float unselected_y2)
 Sets the bounds for the control points (selected and unselected) in normalized coordinates.
 
void drawControlPoints (OpenGlWrapper &open_gl)
 Draws the control points (markers) for the EQ bands.
 
void drawResponse (OpenGlWrapper &open_gl, int index)
 Draws the response of the filters.
 
void computeFilterCoefficients ()
 Computes the filter coefficients based on current slider values and states.
 
void moveFilterSettings (Point< float > position)
 Moves the currently selected filter's cutoff and gain based on a mouse drag position.
 
void setLowSliders (SynthSlider *cutoff, SynthSlider *resonance, SynthSlider *gain)
 Assigns the sliders for the low band.
 
void setBandSliders (SynthSlider *cutoff, SynthSlider *resonance, SynthSlider *gain)
 Assigns the sliders for the mid (band) band.
 
void setHighSliders (SynthSlider *cutoff, SynthSlider *resonance, SynthSlider *gain)
 Assigns the sliders for the high band.
 
void setSelectedBand (int selected_band)
 Sets the currently selected band.
 
Point< float > getLowPosition ()
 Returns the current low band control point position in component coordinates.
 
Point< float > getBandPosition ()
 Returns the current mid (band) control point position in component coordinates.
 
Point< float > getHighPosition ()
 Returns the current high band control point position in component coordinates.
 
void resized () override
 Called when the component is resized.
 
void paintBackground (Graphics &g) override
 Paints the background and optionally draws frequency lines.
 
void mouseWheelMove (const MouseEvent &e, const MouseWheelDetails &wheel) override
 Handles mouse wheel movements for adjusting resonance if hovering over a band.
 
void mouseDown (const MouseEvent &e) override
 Handles mouse down events to select a band.
 
void mouseDrag (const MouseEvent &e) override
 Handles mouse drag events to adjust filter settings.
 
void mouseUp (const MouseEvent &e) override
 Handles mouse up events, finalizing any changes made during drag.
 
void mouseExit (const MouseEvent &e) override
 Handles mouse exit events to hide popups or reset state.
 
int getHoveredBand (const MouseEvent &e)
 Determines which band is currently hovered by the mouse.
 
void setActive (bool active)
 Sets the active state of the EQ visualization.
 
void setHighPass (bool high_pass)
 Configures the low band as a high-pass filter (or a shelf).
 
void setNotch (bool notch)
 Configures the mid band as a notch filter (or a shelf).
 
void setLowPass (bool low_pass)
 Configures the high band as a low-pass filter (or a shelf).
 
void setDbBufferRatio (float ratio)
 Sets the ratio of the dB range used as buffer.
 
void setDrawFrequencyLines (bool draw_lines)
 Sets whether to draw frequency grid lines in the background.
 
void addListener (Listener *listener)
 Adds a listener to be notified of band selections.
 
- 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.
 
virtual void parentHierarchyChanged () override
 Called when the component's parent hierarchy changes.
 
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.
 

Static Public Attributes

static constexpr int kResolution = 128
 Number of points used for resolution in the frequency response display.
 
static constexpr int kViewSampleRate = 100000
 A high view sample rate for accurate visualization (not actual audio processing).
 
static constexpr float kDefaultDbBufferRatio = 0.2f
 Ratio of dB range used as a buffer around min/max gain values.
 
static constexpr float kMouseMultiplier = 0.3f
 Mouse drag multiplier for gain/cutoff adjustments.
 
- 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 visualization component for an equalizer or filter response curve.

The EqualizerResponse component displays the frequency response of a combination of low, band, and high filters (e.g., for an EQ or reverb shelving filters). It supports interactive control via mouse dragging of filter cutoff and gain points and includes adjustable parameters for scaling the dB range and switching filter styles.

Constructor & Destructor Documentation

◆ EqualizerResponse()

EqualizerResponse::EqualizerResponse ( )

Constructs an EqualizerResponse component.

◆ ~EqualizerResponse()

EqualizerResponse::~EqualizerResponse ( )
default

Destructor.

Member Function Documentation

◆ addListener()

void EqualizerResponse::addListener ( Listener * listener)
inline

Adds a listener to be notified of band selections.

Parameters
listenerThe listener to add.

◆ computeFilterCoefficients()

void EqualizerResponse::computeFilterCoefficients ( )

Computes the filter coefficients based on current slider values and states.

◆ destroy()

void EqualizerResponse::destroy ( OpenGlWrapper & open_gl)
overridevirtual

Destroys OpenGL resources.

Parameters
open_glThe OpenGlWrapper context.

Reimplemented from OpenGlLineRenderer.

◆ drawControlPoints()

void EqualizerResponse::drawControlPoints ( OpenGlWrapper & open_gl)

Draws the control points (markers) for the EQ bands.

Parameters
open_glThe OpenGlWrapper context.

◆ drawResponse()

void EqualizerResponse::drawResponse ( OpenGlWrapper & open_gl,
int index )

Draws the response of the filters.

Parameters
open_glThe OpenGlWrapper context.
indexIndex to indicate stereo or multiple instances if needed.

◆ getBandPosition()

Point< float > EqualizerResponse::getBandPosition ( )

Returns the current mid (band) control point position in component coordinates.

Returns
A point representing the mid band's x and y position.

◆ getHighPosition()

Point< float > EqualizerResponse::getHighPosition ( )

Returns the current high band control point position in component coordinates.

Returns
A point representing the high band's x and y position.

◆ getHoveredBand()

int EqualizerResponse::getHoveredBand ( const MouseEvent & e)

Determines which band is currently hovered by the mouse.

Parameters
eThe mouse event.
Returns
An integer representing the hovered band (0 = low, 1 = mid, 2 = high, -1 = none).

◆ getLowPosition()

Point< float > EqualizerResponse::getLowPosition ( )

Returns the current low band control point position in component coordinates.

Returns
A point representing the low band's x and y position.

◆ init()

void EqualizerResponse::init ( OpenGlWrapper & open_gl)
overridevirtual

Initializes OpenGL resources.

Parameters
open_glThe OpenGlWrapper context.

Reimplemented from OpenGlLineRenderer.

◆ initEq()

void EqualizerResponse::initEq ( const vital::output_map & mono_modulations)

Initializes the Equalizer response for a standard 3-band EQ using the provided outputs.

Parameters
mono_modulationsA map of modulation outputs from the synthesizer.

◆ initReverb()

void EqualizerResponse::initReverb ( const vital::output_map & mono_modulations)

Initializes the Equalizer response for a reverb's shelving EQ.

Parameters
mono_modulationsA map of modulation outputs from the synthesizer.

◆ mouseDown()

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

Handles mouse down events to select a band.

Parameters
eThe mouse event.

◆ mouseDrag()

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

Handles mouse drag events to adjust filter settings.

Parameters
eThe mouse event.

◆ mouseExit()

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

Handles mouse exit events to hide popups or reset state.

Parameters
eThe mouse event.

◆ mouseUp()

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

Handles mouse up events, finalizing any changes made during drag.

Parameters
eThe mouse event.

◆ mouseWheelMove()

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

Handles mouse wheel movements for adjusting resonance if hovering over a band.

Parameters
eThe mouse event.
wheelThe details of the mouse wheel movement.

◆ moveFilterSettings()

void EqualizerResponse::moveFilterSettings ( Point< float > position)

Moves the currently selected filter's cutoff and gain based on a mouse drag position.

Parameters
positionThe mouse position in the component's coordinate space.

◆ paintBackground()

void EqualizerResponse::paintBackground ( Graphics & g)
overridevirtual

Paints the background and optionally draws frequency lines.

Parameters
gThe Graphics context to use for painting.

Reimplemented from OpenGlComponent.

◆ render()

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

Renders the EQ response and control points.

Parameters
open_glThe OpenGlWrapper context.
animateWhether to animate the response.

Reimplemented from OpenGlLineRenderer.

◆ resized()

void EqualizerResponse::resized ( )
inlineoverridevirtual

Called when the component is resized.

Reimplemented from OpenGlComponent.

◆ setActive()

void EqualizerResponse::setActive ( bool active)

Sets the active state of the EQ visualization.

Parameters
activeTrue if the EQ should be displayed as active, false otherwise.

◆ setBandSliders()

void EqualizerResponse::setBandSliders ( SynthSlider * cutoff,
SynthSlider * resonance,
SynthSlider * gain )

Assigns the sliders for the mid (band) band.

Parameters
cutoffThe band cutoff slider.
resonanceThe band resonance slider.
gainThe band gain slider.

◆ setControlPointBounds()

void EqualizerResponse::setControlPointBounds ( float selected_x,
float selected_y,
float unselected_x1,
float unselected_y1,
float unselected_x2,
float unselected_y2 )

Sets the bounds for the control points (selected and unselected) in normalized coordinates.

Parameters
selected_xX position of the selected band.
selected_yY position of the selected band.
unselected_x1X position of the first unselected band.
unselected_y1Y position of the first unselected band.
unselected_x2X position of the second unselected band.
unselected_y2Y position of the second unselected band.

◆ setDbBufferRatio()

void EqualizerResponse::setDbBufferRatio ( float ratio)
inline

Sets the ratio of the dB range used as buffer.

Parameters
ratioThe dB buffer ratio.

◆ setDrawFrequencyLines()

void EqualizerResponse::setDrawFrequencyLines ( bool draw_lines)
inline

Sets whether to draw frequency grid lines in the background.

Parameters
draw_linesTrue to draw frequency lines, false otherwise.

◆ setHighPass()

void EqualizerResponse::setHighPass ( bool high_pass)

Configures the low band as a high-pass filter (or a shelf).

Parameters
high_passTrue to make it a high-pass, false for shelving.

◆ setHighSliders()

void EqualizerResponse::setHighSliders ( SynthSlider * cutoff,
SynthSlider * resonance,
SynthSlider * gain )

Assigns the sliders for the high band.

Parameters
cutoffThe high band cutoff slider.
resonanceThe high band resonance slider.
gainThe high band gain slider.

◆ setLowPass()

void EqualizerResponse::setLowPass ( bool low_pass)

Configures the high band as a low-pass filter (or a shelf).

Parameters
low_passTrue to make it low-pass, false for shelving.

◆ setLowSliders()

void EqualizerResponse::setLowSliders ( SynthSlider * cutoff,
SynthSlider * resonance,
SynthSlider * gain )

Assigns the sliders for the low band.

Parameters
cutoffThe low band cutoff slider.
resonanceThe low band resonance slider.
gainThe low band gain slider.

◆ setNotch()

void EqualizerResponse::setNotch ( bool notch)

Configures the mid band as a notch filter (or a shelf).

Parameters
notchTrue to make it a notch, false for shelving.

◆ setSelectedBand()

void EqualizerResponse::setSelectedBand ( int selected_band)

Sets the currently selected band.

Parameters
selected_bandAn integer representing the band (0 = low, 1 = mid, 2 = high).

Member Data Documentation

◆ kDefaultDbBufferRatio

float EqualizerResponse::kDefaultDbBufferRatio = 0.2f
staticconstexpr

Ratio of dB range used as a buffer around min/max gain values.

◆ kMouseMultiplier

float EqualizerResponse::kMouseMultiplier = 0.3f
staticconstexpr

Mouse drag multiplier for gain/cutoff adjustments.

◆ kResolution

int EqualizerResponse::kResolution = 128
staticconstexpr

Number of points used for resolution in the frequency response display.

◆ kViewSampleRate

int EqualizerResponse::kViewSampleRate = 100000
staticconstexpr

A high view sample rate for accurate visualization (not actual audio processing).


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