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

OpenGL-based component for visualizing wavetables in different formats. More...

#include <wavetable_3d.h>

Inheritance diagram for Wavetable3d:
OpenGlComponent AudioFileDropSource

Classes

class  Listener
 Interface for components that need to respond to wavetable loading or transformations. More...
 

Public Types

enum  MenuOptions {
  kCancel , kCopy , kPaste , kInit ,
  kSave , kTextToWavetable , kResynthesizePreset , kLogIn ,
  kNumMenuOptions
}
 Menu options for right-click context menu. More...
 
enum  RenderType { kWave3d , kWave2d , kFrequencyAmplitudes , kNumRenderTypes }
 Render types for different visualization modes. More...
 

Public Member Functions

 Wavetable3d (int index, const vital::output_map &mono_modulations, const vital::output_map &poly_modulations)
 
virtual ~Wavetable3d ()
 Destructor.
 
void init (OpenGlWrapper &open_gl) override
 
void render (OpenGlWrapper &open_gl, bool animate) override
 
void renderWave (OpenGlWrapper &open_gl)
 
void renderSpectrum (OpenGlWrapper &open_gl)
 
void destroy (OpenGlWrapper &open_gl) override
 
void paintBackground (Graphics &g) override
 
void resized () override
 Handles component resizing, recalculating layout and scaling.
 
void mouseDown (const MouseEvent &e) override
 
void mouseDrag (const MouseEvent &e) override
 
void mouseExit (const MouseEvent &e) override
 
void mouseWheelMove (const MouseEvent &e, const MouseWheelDetails &wheel) override
 
void setFrameSlider (SynthSlider *slider)
 
void setSpectralMorphSlider (Slider *slider)
 
void setDistortionSlider (Slider *slider)
 
void setDistortionPhaseSlider (Slider *slider)
 
void setViewSettings (float horizontal_angle, float vertical_angle, float draw_width, float wave_height, float y_offset)
 Sets view settings for the 3D display (angles, width, height, offset).
 
void setRenderType (RenderType render_type)
 
RenderType getRenderType () const
 
void setSpectralMorphType (int spectral_morph_type)
 
void setDistortionType (int distortion_type)
 
void respondToMenuCallback (int option)
 
bool hasMatchingSystemClipboard ()
 
void setActive (bool active)
 
bool isActive ()
 
void audioFileLoaded (const File &file) override
 
void updateDraggingPosition (int x, int y)
 
void fileDragEnter (const StringArray &files, int x, int y) override
 Handles file drag enter events.
 
void fileDragMove (const StringArray &files, int x, int y) override
 Handles file drag move events.
 
void fileDragExit (const StringArray &files) override
 Handles file drag exit events, resetting the load style.
 
void addListener (Listener *listener)
 
void setLoadingWavetable (bool loading)
 
void setDirty ()
 Marks the internal state as dirty, forcing a redraw.
 
vital::WavetablegetWavetable ()
 
- 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.
 
- Public Member Functions inherited from AudioFileDropSource
 AudioFileDropSource ()
 Constructs an AudioFileDropSource and registers basic audio formats.
 
bool isInterestedInFileDrag (const StringArray &files) override
 Checks if the drag operation includes exactly one file and if it matches supported audio formats.
 
void filesDropped (const StringArray &files, int x, int y) override
 Called when files are dropped onto the component.
 
void addListener (Listener *listener)
 Adds a listener to receive audio file load notifications.
 
String getExtensions ()
 Gets a wildcard pattern representing all supported audio formats.
 
AudioFormatManager & formatManager ()
 Provides access to the underlying AudioFormatManager.
 

Static Public Member Functions

static void paint3dLine (Graphics &g, vital::Wavetable *wavetable, int index, Colour color, float width, float height, float wave_height_percent, float wave_range_x, float frame_range_x, float wave_range_y, float frame_range_y, float start_x, float start_y, float offset_x, float offset_y)
 Static helper method for painting a single 3D line (waveform frame) onto a Graphics object.
 
static void paint3dBackground (Graphics &g, vital::Wavetable *wavetable, bool active, Colour background_color, Colour wave_color1, Colour wave_color2, float width, float height, float wave_height_percent, float wave_range_x, float frame_range_x, float wave_range_y, float frame_range_y, float start_x, float start_y, float offset_x, float offset_y)
 Static helper method for painting the 3D background of the wavetable (all frames) onto a Graphics object.
 
- 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.
 

Static Public Attributes

static constexpr float kDefaultVerticalAngle = 1.132f
 Default angles and scaling parameters for 3D rendering.
 
static constexpr float kDefaultHorizontalAngle = -0.28f
 
static constexpr float kDefaultDrawWidthPercent = 0.728f
 
static constexpr float kDefaultWaveHeightPercent = 0.083f
 
static constexpr float kPositionWidth = 8.0f
 
static constexpr float kPositionLineWidthRatio = 1.8f
 
static constexpr int kColorJump = 16
 
static constexpr int kDownsampleResolutionAmount = 0
 
static constexpr int kResolution = vital::Wavetable::kWaveformSize >> kDownsampleResolutionAmount
 
static constexpr int kNumBits = vital::WaveFrame::kWaveformBits
 
static constexpr int kBackgroundResolution = 128
 
static constexpr int kExtraShadows = 20
 
static constexpr float k2dWaveHeightPercent = 0.25f
 

Additional Inherited Members

- 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.
 
- Protected Attributes inherited from AudioFileDropSource
AudioFormatManager format_manager_
 Manages and recognizes different audio file formats.
 

Detailed Description

OpenGL-based component for visualizing wavetables in different formats.

The Wavetable3d component can render:

  • A 3D representation of multiple frames of a wavetable.
  • A 2D single-frame waveform view.
  • A frequency amplitude view of the wavetable.

It supports loading wavetables from JSON, copying/pasting, resynthesis, and text-to-wavetable conversions. It also integrates with parameter modulation for frame, spectral morph, and distortion adjustments.

Member Enumeration Documentation

◆ MenuOptions

Menu options for right-click context menu.

Enumerator
kCancel 
kCopy 
kPaste 
kInit 
kSave 
kTextToWavetable 
kResynthesizePreset 
kLogIn 
kNumMenuOptions 

◆ RenderType

Render types for different visualization modes.

Enumerator
kWave3d 
kWave2d 
kFrequencyAmplitudes 
kNumRenderTypes 

Constructor & Destructor Documentation

◆ Wavetable3d()

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

Constructor.

Parameters
indexThe oscillator index this wavetable visualization represents.
mono_modulationsA map of mono output parameters.
poly_modulationsA map of poly output parameters.

◆ ~Wavetable3d()

Wavetable3d::~Wavetable3d ( )
virtualdefault

Destructor.

Member Function Documentation

◆ addListener()

void Wavetable3d::addListener ( Listener * listener)
inline

Adds a listener to be notified of wavetable changes.

Parameters
listenerThe listener.

◆ audioFileLoaded()

void Wavetable3d::audioFileLoaded ( const File & file)
overridevirtual

Called when an audio file is loaded by dragging onto the component.

Parameters
fileThe loaded file.

Implements AudioFileDropSource.

◆ destroy()

void Wavetable3d::destroy ( OpenGlWrapper & open_gl)
overridevirtual

Destroys OpenGL resources.

Parameters
open_glThe OpenGlWrapper managing state.

Reimplemented from OpenGlComponent.

◆ fileDragEnter()

void Wavetable3d::fileDragEnter ( const StringArray & files,
int x,
int y )
inlineoverride

Handles file drag enter events.

◆ fileDragExit()

void Wavetable3d::fileDragExit ( const StringArray & files)
inlineoverride

Handles file drag exit events, resetting the load style.

◆ fileDragMove()

void Wavetable3d::fileDragMove ( const StringArray & files,
int x,
int y )
inlineoverride

Handles file drag move events.

◆ getRenderType()

RenderType Wavetable3d::getRenderType ( ) const
inline

Gets the current render type.

Returns
The current render type.

◆ getWavetable()

vital::Wavetable * Wavetable3d::getWavetable ( )
inline

Gets the current wavetable.

Returns
A pointer to the current vital::Wavetable.

◆ hasMatchingSystemClipboard()

bool Wavetable3d::hasMatchingSystemClipboard ( )

Checks if the system clipboard currently has a matching wavetable JSON.

Returns
True if clipboard data is a valid wavetable.

◆ init()

void Wavetable3d::init ( OpenGlWrapper & open_gl)
overridevirtual

Initializes OpenGL resources.

Parameters
open_glThe OpenGlWrapper managing state.

Reimplemented from OpenGlComponent.

◆ isActive()

bool Wavetable3d::isActive ( )
inline

Checks if the visualization is active.

Returns
True if active, false otherwise.

◆ mouseDown()

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

Handles mouse-down events for context menu and frame dragging.

Parameters
eThe mouse event.

◆ mouseDrag()

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

Handles mouse dragging to change the frame slider value.

Parameters
eThe mouse event.

◆ mouseExit()

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

Hides the frame slider popup on mouse exit.

Parameters
eThe mouse event.

◆ mouseWheelMove()

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

Handles mouse wheel to change the frame slider value.

Parameters
eThe mouse event.
wheelThe mouse wheel details.

◆ paint3dBackground()

void Wavetable3d::paint3dBackground ( Graphics & g,
vital::Wavetable * wavetable,
bool active,
Colour background_color,
Colour wave_color1,
Colour wave_color2,
float width,
float height,
float wave_height_percent,
float wave_range_x,
float frame_range_x,
float wave_range_y,
float frame_range_y,
float start_x,
float start_y,
float offset_x,
float offset_y )
static

Static helper method for painting the 3D background of the wavetable (all frames) onto a Graphics object.

◆ paint3dLine()

void Wavetable3d::paint3dLine ( Graphics & g,
vital::Wavetable * wavetable,
int index,
Colour color,
float width,
float height,
float wave_height_percent,
float wave_range_x,
float frame_range_x,
float wave_range_y,
float frame_range_y,
float start_x,
float start_y,
float offset_x,
float offset_y )
static

Static helper method for painting a single 3D line (waveform frame) onto a Graphics object.

◆ paintBackground()

void Wavetable3d::paintBackground ( Graphics & g)
overridevirtual

Paints the background, including the 3D wavetable shadow lines.

Parameters
gThe JUCE Graphics context.

Reimplemented from OpenGlComponent.

◆ render()

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

Renders the wavetable visualization each frame.

Parameters
open_glThe OpenGlWrapper managing state.
animateIf true, apply animations.

Implements OpenGlComponent.

◆ renderSpectrum()

void Wavetable3d::renderSpectrum ( OpenGlWrapper & open_gl)

Renders the frequency amplitude visualization.

Parameters
open_glThe OpenGlWrapper managing state.

◆ renderWave()

void Wavetable3d::renderWave ( OpenGlWrapper & open_gl)

Renders the wave visualization (2D or 3D).

Parameters
open_glThe OpenGlWrapper managing state.

◆ resized()

void Wavetable3d::resized ( )
overridevirtual

Handles component resizing, recalculating layout and scaling.

Reimplemented from OpenGlComponent.

◆ respondToMenuCallback()

void Wavetable3d::respondToMenuCallback ( int option)

Responds to a menu callback action (copy, paste, init, etc.).

Parameters
optionThe chosen menu option.

◆ setActive()

void Wavetable3d::setActive ( bool active)
inline

Sets the active state of this visualization.

Parameters
activeTrue if active, false otherwise.

◆ setDirty()

void Wavetable3d::setDirty ( )
inline

Marks the internal state as dirty, forcing a redraw.

◆ setDistortionPhaseSlider()

void Wavetable3d::setDistortionPhaseSlider ( Slider * slider)
inline

Sets the slider controlling distortion phase.

Parameters
sliderThe Slider for distortion phase.

◆ setDistortionSlider()

void Wavetable3d::setDistortionSlider ( Slider * slider)
inline

Sets the slider controlling distortion amount.

Parameters
sliderThe Slider for distortion.

◆ setDistortionType()

void Wavetable3d::setDistortionType ( int distortion_type)
inline

Sets the distortion type index.

Parameters
distortion_typeThe distortion type.

◆ setFrameSlider()

void Wavetable3d::setFrameSlider ( SynthSlider * slider)
inline

Sets the slider controlling the wavetable frame.

Parameters
sliderThe SynthSlider for frame control.

◆ setLoadingWavetable()

void Wavetable3d::setLoadingWavetable ( bool loading)
inline

Sets whether the wavetable is currently loading or being changed.

Parameters
loadingTrue if currently loading a wavetable.

◆ setRenderType()

void Wavetable3d::setRenderType ( RenderType render_type)

Sets the render type (3D wave, 2D wave, or frequency amplitude).

Parameters
render_typeThe render type.

◆ setSpectralMorphSlider()

void Wavetable3d::setSpectralMorphSlider ( Slider * slider)
inline

Sets the slider controlling spectral morph amount.

Parameters
sliderThe Slider for spectral morph.

◆ setSpectralMorphType()

void Wavetable3d::setSpectralMorphType ( int spectral_morph_type)
inline

Sets the spectral morph type index.

Parameters
spectral_morph_typeThe spectral morph type.

◆ setViewSettings()

void Wavetable3d::setViewSettings ( float horizontal_angle,
float vertical_angle,
float draw_width,
float wave_height,
float y_offset )

Sets view settings for the 3D display (angles, width, height, offset).

◆ updateDraggingPosition()

void Wavetable3d::updateDraggingPosition ( int x,
int y )

Updates the dragging position to determine how the audio file will be interpreted.

Parameters
xThe x-position of the drag.
yThe y-position of the drag.

Member Data Documentation

◆ k2dWaveHeightPercent

float Wavetable3d::k2dWaveHeightPercent = 0.25f
staticconstexpr

◆ kBackgroundResolution

int Wavetable3d::kBackgroundResolution = 128
staticconstexpr

◆ kColorJump

int Wavetable3d::kColorJump = 16
staticconstexpr

◆ kDefaultDrawWidthPercent

float Wavetable3d::kDefaultDrawWidthPercent = 0.728f
staticconstexpr

◆ kDefaultHorizontalAngle

float Wavetable3d::kDefaultHorizontalAngle = -0.28f
staticconstexpr

◆ kDefaultVerticalAngle

float Wavetable3d::kDefaultVerticalAngle = 1.132f
staticconstexpr

Default angles and scaling parameters for 3D rendering.

◆ kDefaultWaveHeightPercent

float Wavetable3d::kDefaultWaveHeightPercent = 0.083f
staticconstexpr

◆ kDownsampleResolutionAmount

int Wavetable3d::kDownsampleResolutionAmount = 0
staticconstexpr

◆ kExtraShadows

int Wavetable3d::kExtraShadows = 20
staticconstexpr

◆ kNumBits

int Wavetable3d::kNumBits = vital::WaveFrame::kWaveformBits
staticconstexpr

◆ kPositionLineWidthRatio

float Wavetable3d::kPositionLineWidthRatio = 1.8f
staticconstexpr

◆ kPositionWidth

float Wavetable3d::kPositionWidth = 8.0f
staticconstexpr

◆ kResolution

int Wavetable3d::kResolution = vital::Wavetable::kWaveformSize >> kDownsampleResolutionAmount
staticconstexpr

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