Vital
|
OpenGL-based component for visualizing wavetables in different formats. More...
#include <wavetable_3d.h>
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::Wavetable * | getWavetable () |
![]() | |
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. | |
![]() | |
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 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 | |
![]() | |
bool | setViewPort (OpenGlWrapper &open_gl) |
Sets the viewport for this component using the current OpenGlWrapper. | |
![]() | |
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. | |
![]() | |
AudioFormatManager | format_manager_ |
Manages and recognizes different audio file formats. | |
OpenGL-based component for visualizing wavetables in different formats.
The Wavetable3d component can render:
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.
Wavetable3d::Wavetable3d | ( | int | index, |
const vital::output_map & | mono_modulations, | ||
const vital::output_map & | poly_modulations ) |
Constructor.
index | The oscillator index this wavetable visualization represents. |
mono_modulations | A map of mono output parameters. |
poly_modulations | A map of poly output parameters. |
|
virtualdefault |
Destructor.
|
inline |
Adds a listener to be notified of wavetable changes.
listener | The listener. |
|
overridevirtual |
Called when an audio file is loaded by dragging onto the component.
file | The loaded file. |
Implements AudioFileDropSource.
|
overridevirtual |
Destroys OpenGL resources.
open_gl | The OpenGlWrapper managing state. |
Reimplemented from OpenGlComponent.
|
inlineoverride |
Handles file drag enter events.
|
inlineoverride |
Handles file drag exit events, resetting the load style.
|
inlineoverride |
Handles file drag move events.
|
inline |
Gets the current render type.
|
inline |
Gets the current wavetable.
bool Wavetable3d::hasMatchingSystemClipboard | ( | ) |
Checks if the system clipboard currently has a matching wavetable JSON.
|
overridevirtual |
Initializes OpenGL resources.
open_gl | The OpenGlWrapper managing state. |
Reimplemented from OpenGlComponent.
|
inline |
Checks if the visualization is active.
|
override |
Handles mouse-down events for context menu and frame dragging.
e | The mouse event. |
|
override |
Handles mouse dragging to change the frame slider value.
e | The mouse event. |
|
override |
Hides the frame slider popup on mouse exit.
e | The mouse event. |
|
override |
Handles mouse wheel to change the frame slider value.
e | The mouse event. |
wheel | The mouse wheel details. |
|
static |
Static helper method for painting the 3D background of the wavetable (all frames) onto a Graphics object.
|
static |
Static helper method for painting a single 3D line (waveform frame) onto a Graphics object.
|
overridevirtual |
Paints the background, including the 3D wavetable shadow lines.
g | The JUCE Graphics context. |
Reimplemented from OpenGlComponent.
|
overridevirtual |
Renders the wavetable visualization each frame.
open_gl | The OpenGlWrapper managing state. |
animate | If true, apply animations. |
Implements OpenGlComponent.
void Wavetable3d::renderSpectrum | ( | OpenGlWrapper & | open_gl | ) |
Renders the frequency amplitude visualization.
open_gl | The OpenGlWrapper managing state. |
void Wavetable3d::renderWave | ( | OpenGlWrapper & | open_gl | ) |
Renders the wave visualization (2D or 3D).
open_gl | The OpenGlWrapper managing state. |
|
overridevirtual |
Handles component resizing, recalculating layout and scaling.
Reimplemented from OpenGlComponent.
void Wavetable3d::respondToMenuCallback | ( | int | option | ) |
Responds to a menu callback action (copy, paste, init, etc.).
option | The chosen menu option. |
|
inline |
Sets the active state of this visualization.
active | True if active, false otherwise. |
|
inline |
Marks the internal state as dirty, forcing a redraw.
|
inline |
Sets the slider controlling distortion phase.
slider | The Slider for distortion phase. |
|
inline |
Sets the slider controlling distortion amount.
slider | The Slider for distortion. |
|
inline |
Sets the distortion type index.
distortion_type | The distortion type. |
|
inline |
Sets the slider controlling the wavetable frame.
slider | The SynthSlider for frame control. |
|
inline |
Sets whether the wavetable is currently loading or being changed.
loading | True if currently loading a wavetable. |
void Wavetable3d::setRenderType | ( | RenderType | render_type | ) |
Sets the render type (3D wave, 2D wave, or frequency amplitude).
render_type | The render type. |
|
inline |
Sets the slider controlling spectral morph amount.
slider | The Slider for spectral morph. |
|
inline |
Sets the spectral morph type index.
spectral_morph_type | The spectral morph type. |
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).
void Wavetable3d::updateDraggingPosition | ( | int | x, |
int | y ) |
Updates the dragging position to determine how the audio file will be interpreted.
x | The x-position of the drag. |
y | The y-position of the drag. |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
Default angles and scaling parameters for 3D rendering.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |