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

Displays the frequency response of various filter models in Vital. More...

#include <filter_response.h>

Inheritance diagram for FilterResponse:
OpenGlLineRenderer OpenGlComponent

Public Types

enum  FilterShader {
  kAnalog , kDirty , kLadder , kDigital ,
  kDiode , kFormant , kComb , kPositiveFlange ,
  kNegativeFlange , kPhase , kNumFilterShaders
}
 An enumeration of different filter shader programs used for rendering. More...
 

Public Member Functions

 FilterResponse (String suffix, const vital::output_map &mono_modulations)
 Constructs a FilterResponse given a suffix and modulation outputs for a single filter configuration.
 
 FilterResponse (int index, const vital::output_map &mono_modulations, const vital::output_map &poly_modulations)
 Constructs a FilterResponse for a specific filter index, with both mono and poly modulation outputs.
 
virtual ~FilterResponse ()
 Destructor.
 
void init (OpenGlWrapper &open_gl) override
 Initializes the OpenGL resources for the filter response visualization.
 
void render (OpenGlWrapper &open_gl, bool animate) override
 Renders the filter response curve to the screen.
 
void destroy (OpenGlWrapper &open_gl) override
 Destroys the OpenGL resources used by this component.
 
void paintBackground (Graphics &g) override
 Draws the background of the component (e.g. coloring, grid lines).
 
void setCutoffSlider (SynthSlider *slider)
 Sets the slider controlling the cutoff frequency.
 
void setResonanceSlider (SynthSlider *slider)
 Sets the slider controlling the filter resonance.
 
void setFormantXSlider (SynthSlider *slider)
 Sets the slider controlling the formant X parameter (for formant filter models).
 
void setFormantYSlider (SynthSlider *slider)
 Sets the slider controlling the formant Y parameter (for formant filter models).
 
void setFilterMixSlider (SynthSlider *slider)
 Sets the slider controlling the filter mix parameter.
 
void setBlendSlider (SynthSlider *slider)
 Sets the slider controlling the blend parameter (e.g., for morphing filter responses).
 
void setTransposeSlider (SynthSlider *slider)
 Sets the slider controlling transposition of certain filter parameters.
 
void setFormantTransposeSlider (SynthSlider *slider)
 Sets the slider for formant transpose (formant shifting) parameter.
 
void setFormantResonanceSlider (SynthSlider *slider)
 Sets the slider for formant resonance parameter.
 
void setFormantSpreadSlider (SynthSlider *slider)
 Sets the slider for formant spread parameter.
 
void mouseDown (const MouseEvent &e) override
 Handles mouse down events, initiating user interaction with filter parameters.
 
void mouseDrag (const MouseEvent &e) override
 Handles mouse drag events, allowing interactive adjustment of filter parameters.
 
void mouseExit (const MouseEvent &e) override
 Handles mouse exit events, finalizing interactive changes and hiding tooltips.
 
void mouseWheelMove (const MouseEvent &e, const MouseWheelDetails &wheel) override
 Handles mouse wheel events for fine-tuning filter parameters.
 
void setActive (bool active)
 Sets whether the filter visualization is active.
 
void setModel (vital::constants::FilterModel model)
 Sets the currently selected filter model to visualize.
 
void setStyle (int style)
 Sets the style of the filter (e.g., 12dB/oct, 24dB/oct).
 
- 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 resized () override
 Called when the component is resized.
 
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 = 512
 Number of points used for drawing the filter response curve.
 
static constexpr int kDefaultVisualSampleRate = 200000
 High sample rate used for filter response visualization (not actual audio rate).
 
static constexpr int kCombAlternatePeriod = 3
 Period used for alternating patterns (specifically with comb filters).
 
static constexpr double kMouseSensitivityX = 0.3
 Sensitivity multipliers for mouse interaction along the X and Y axes.
 
static constexpr double kMouseSensitivityY = 0.3
 
- 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

Displays the frequency response of various filter models in Vital.

FilterResponse visualizes how a chosen filter (analog, digital, ladder, comb, diode, formant, etc.) affects the audio spectrum. It allows real-time interaction by clicking and dragging to change filter cutoff and resonance or formant positions. The rendering is done via OpenGL for efficiency.

Member Enumeration Documentation

◆ FilterShader

An enumeration of different filter shader programs used for rendering.

Enumerator
kAnalog 
kDirty 
kLadder 
kDigital 
kDiode 
kFormant 
kComb 
kPositiveFlange 
kNegativeFlange 
kPhase 
kNumFilterShaders 

Constructor & Destructor Documentation

◆ FilterResponse() [1/2]

FilterResponse::FilterResponse ( String suffix,
const vital::output_map & mono_modulations )

Constructs a FilterResponse given a suffix and modulation outputs for a single filter configuration.

Parameters
suffixThe suffix to identify which filter's parameters to use.
mono_modulationsA map of mono modulation outputs.

◆ FilterResponse() [2/2]

FilterResponse::FilterResponse ( int index,
const vital::output_map & mono_modulations,
const vital::output_map & poly_modulations )

Constructs a FilterResponse for a specific filter index, with both mono and poly modulation outputs.

Parameters
indexThe filter index.
mono_modulationsA map of mono modulation outputs.
poly_modulationsA map of poly modulation outputs.

◆ ~FilterResponse()

FilterResponse::~FilterResponse ( )
virtual

Destructor.

Member Function Documentation

◆ destroy()

void FilterResponse::destroy ( OpenGlWrapper & open_gl)
overridevirtual

Destroys the OpenGL resources used by this component.

Parameters
open_glThe OpenGL wrapper instance.

Reimplemented from OpenGlLineRenderer.

◆ init()

void FilterResponse::init ( OpenGlWrapper & open_gl)
overridevirtual

Initializes the OpenGL resources for the filter response visualization.

Parameters
open_glThe OpenGL wrapper instance.

Reimplemented from OpenGlLineRenderer.

◆ mouseDown()

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

Handles mouse down events, initiating user interaction with filter parameters.

Parameters
eThe mouse event.

◆ mouseDrag()

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

Handles mouse drag events, allowing interactive adjustment of filter parameters.

Parameters
eThe mouse event.

◆ mouseExit()

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

Handles mouse exit events, finalizing interactive changes and hiding tooltips.

Parameters
eThe mouse event.

◆ mouseWheelMove()

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

Handles mouse wheel events for fine-tuning filter parameters.

Parameters
eThe mouse event.
wheelDetails about the mouse wheel motion.

◆ paintBackground()

void FilterResponse::paintBackground ( Graphics & g)
overridevirtual

Draws the background of the component (e.g. coloring, grid lines).

Parameters
gThe JUCE Graphics context.

Reimplemented from OpenGlComponent.

◆ render()

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

Renders the filter response curve to the screen.

Parameters
open_glThe OpenGL wrapper instance.
animateWhether animations should be performed.

Reimplemented from OpenGlLineRenderer.

◆ setActive()

void FilterResponse::setActive ( bool active)
inline

Sets whether the filter visualization is active.

Parameters
activeTrue to activate visualization, False to disable.

◆ setBlendSlider()

void FilterResponse::setBlendSlider ( SynthSlider * slider)
inline

Sets the slider controlling the blend parameter (e.g., for morphing filter responses).

Parameters
sliderPointer to the blend SynthSlider.

◆ setCutoffSlider()

void FilterResponse::setCutoffSlider ( SynthSlider * slider)
inline

Sets the slider controlling the cutoff frequency.

Parameters
sliderPointer to the cutoff SynthSlider.

◆ setFilterMixSlider()

void FilterResponse::setFilterMixSlider ( SynthSlider * slider)
inline

Sets the slider controlling the filter mix parameter.

Parameters
sliderPointer to the filter mix SynthSlider.

◆ setFormantResonanceSlider()

void FilterResponse::setFormantResonanceSlider ( SynthSlider * slider)
inline

Sets the slider for formant resonance parameter.

Parameters
sliderPointer to the formant resonance SynthSlider.

◆ setFormantSpreadSlider()

void FilterResponse::setFormantSpreadSlider ( SynthSlider * slider)
inline

Sets the slider for formant spread parameter.

Parameters
sliderPointer to the formant spread SynthSlider.

◆ setFormantTransposeSlider()

void FilterResponse::setFormantTransposeSlider ( SynthSlider * slider)
inline

Sets the slider for formant transpose (formant shifting) parameter.

Parameters
sliderPointer to the formant transpose SynthSlider.

◆ setFormantXSlider()

void FilterResponse::setFormantXSlider ( SynthSlider * slider)
inline

Sets the slider controlling the formant X parameter (for formant filter models).

Parameters
sliderPointer to the formant X SynthSlider.

◆ setFormantYSlider()

void FilterResponse::setFormantYSlider ( SynthSlider * slider)
inline

Sets the slider controlling the formant Y parameter (for formant filter models).

Parameters
sliderPointer to the formant Y SynthSlider.

◆ setModel()

void FilterResponse::setModel ( vital::constants::FilterModel model)
inline

Sets the currently selected filter model to visualize.

Parameters
modelThe filter model enum value.

◆ setResonanceSlider()

void FilterResponse::setResonanceSlider ( SynthSlider * slider)
inline

Sets the slider controlling the filter resonance.

Parameters
sliderPointer to the resonance SynthSlider.

◆ setStyle()

void FilterResponse::setStyle ( int style)
inline

Sets the style of the filter (e.g., 12dB/oct, 24dB/oct).

Parameters
styleThe style integer associated with the filter model.

◆ setTransposeSlider()

void FilterResponse::setTransposeSlider ( SynthSlider * slider)
inline

Sets the slider controlling transposition of certain filter parameters.

Parameters
sliderPointer to the transpose SynthSlider.

Member Data Documentation

◆ kCombAlternatePeriod

int FilterResponse::kCombAlternatePeriod = 3
staticconstexpr

Period used for alternating patterns (specifically with comb filters).

◆ kDefaultVisualSampleRate

int FilterResponse::kDefaultVisualSampleRate = 200000
staticconstexpr

High sample rate used for filter response visualization (not actual audio rate).

◆ kMouseSensitivityX

double FilterResponse::kMouseSensitivityX = 0.3
staticconstexpr

Sensitivity multipliers for mouse interaction along the X and Y axes.

◆ kMouseSensitivityY

double FilterResponse::kMouseSensitivityY = 0.3
staticconstexpr

◆ kResolution

int FilterResponse::kResolution = 512
staticconstexpr

Number of points used for drawing the filter response curve.


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