Vital
Loading...
Searching...
No Matches
wave_warp_modifier.h
Go to the documentation of this file.
1/*
2Summary:
3WaveWarpModifier allows nonlinear reshaping of a waveform by warping it horizontally (time-axis) and vertically (amplitude-axis). Users can set warp powers and choose asymmetric transformations, creating a wide range of waveform distortions. Interpolation between keyframes and these nonlinear transformations can produce evolving, dynamic waves that move beyond simple linear scaling.
4 */
5
6#pragma once
7
8#include "JuceHeader.h"
10
25public:
36 public:
42
43 void copy(const WavetableKeyframe* keyframe) override;
44 void interpolate(const WavetableKeyframe* from_keyframe,
45 const WavetableKeyframe* to_keyframe, float t) override;
46 void render(vital::WaveFrame* wave_frame) override;
47 json stateToJson() override;
48 void jsonToState(json data) override;
49
56
63
69 void setHorizontalPower(float horizontal_power) { horizontal_power_ = horizontal_power; }
70
76 void setVerticalPower(float vertical_power) { vertical_power_ = vertical_power; }
77
85 void setHorizontalAsymmetric(bool horizontal_asymmetric) { horizontal_asymmetric_ = horizontal_asymmetric; }
86
92 void setVerticalAsymmetric(bool vertical_asymmetric) { vertical_asymmetric_ = vertical_asymmetric; }
93
94 protected:
97
100
101 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WaveWarpModifierKeyframe)
102 };
103
108 virtual ~WaveWarpModifier() = default;
109
110 WavetableKeyframe* createKeyframe(int position) override;
111 void render(vital::WaveFrame* wave_frame, float position) override;
113 json stateToJson() override;
114 void jsonToState(json data) override;
115
121 void setHorizontalAsymmetric(bool horizontal_asymmetric) { horizontal_asymmetric_ = horizontal_asymmetric; }
122
128 void setVerticalAsymmetric(bool vertical_asymmetric) { vertical_asymmetric_ = vertical_asymmetric; }
129
136
143
150 WaveWarpModifierKeyframe* getKeyframe(int index);
151
152protected:
156
157 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WaveWarpModifier)
158};
A keyframe class holding horizontal and vertical warp parameters at a given position.
Definition wave_warp_modifier.h:35
float vertical_power_
Controls vertical (amplitude-axis) warping.
Definition wave_warp_modifier.h:96
bool vertical_asymmetric_
If true, vertical warping is asymmetric.
Definition wave_warp_modifier.h:99
float horizontal_power_
Controls horizontal (time-axis) warping.
Definition wave_warp_modifier.h:95
float getVerticalPower()
Gets the vertical warp power.
Definition wave_warp_modifier.h:62
WaveWarpModifierKeyframe()
Constructs a WaveWarpModifierKeyframe with default warp powers and symmetric warping.
Definition wave_warp_modifier.cpp:35
void interpolate(const WavetableKeyframe *from_keyframe, const WavetableKeyframe *to_keyframe, float t) override
Linearly interpolates between two keyframes.
Definition wave_warp_modifier.cpp:48
void render(vital::WaveFrame *wave_frame) override
Renders the waveform of this keyframe into a WaveFrame.
Definition wave_warp_modifier.cpp:59
void jsonToState(json data) override
Restores the keyframe's state from a JSON object.
Definition wave_warp_modifier.cpp:102
void setVerticalAsymmetric(bool vertical_asymmetric)
Sets whether vertical warping is asymmetric.
Definition wave_warp_modifier.h:92
void copy(const WavetableKeyframe *keyframe) override
Copies the state from another keyframe of the same type.
Definition wave_warp_modifier.cpp:42
void setHorizontalAsymmetric(bool horizontal_asymmetric)
Sets whether horizontal warping is asymmetric.
Definition wave_warp_modifier.h:85
json stateToJson() override
Serializes the state of this keyframe to a JSON object.
Definition wave_warp_modifier.cpp:95
void setHorizontalPower(float horizontal_power)
Sets the horizontal warp power.
Definition wave_warp_modifier.h:69
void setVerticalPower(float vertical_power)
Sets the vertical warp power.
Definition wave_warp_modifier.h:76
float getHorizontalPower()
Gets the horizontal warp power.
Definition wave_warp_modifier.h:55
bool horizontal_asymmetric_
If true, horizontal warping is asymmetric.
Definition wave_warp_modifier.h:98
virtual ~WaveWarpModifierKeyframe()
Definition wave_warp_modifier.h:41
A WavetableComponent that applies nonlinear horizontal and vertical warping to a waveform.
Definition wave_warp_modifier.h:24
WaveWarpModifierKeyframe compute_frame_
Keyframe used for intermediate computation.
Definition wave_warp_modifier.h:153
WavetableKeyframe * createKeyframe(int position) override
Creates a new keyframe at a given position.
Definition wave_warp_modifier.cpp:108
bool horizontal_asymmetric_
Controls horizontal warping symmetry.
Definition wave_warp_modifier.h:154
void setVerticalAsymmetric(bool vertical_asymmetric)
Sets whether vertical warping is asymmetric.
Definition wave_warp_modifier.h:128
void render(vital::WaveFrame *wave_frame, float position) override
Renders the waveform at a given position into a WaveFrame.
Definition wave_warp_modifier.cpp:114
bool getHorizontalAsymmetric() const
Checks if horizontal warping is asymmetric.
Definition wave_warp_modifier.h:135
bool getVerticalAsymmetric() const
Checks if vertical warping is asymmetric.
Definition wave_warp_modifier.h:142
json stateToJson() override
Serializes the component’s state and all keyframes to a JSON object.
Definition wave_warp_modifier.cpp:126
void jsonToState(json data) override
Restores the component’s state from a JSON object.
Definition wave_warp_modifier.cpp:133
WaveWarpModifier()
Constructs a WaveWarpModifier with symmetric warping by default.
Definition wave_warp_modifier.h:107
virtual ~WaveWarpModifier()=default
void setHorizontalAsymmetric(bool horizontal_asymmetric)
Sets whether horizontal warping is asymmetric.
Definition wave_warp_modifier.h:121
bool vertical_asymmetric_
Controls vertical warping symmetry.
Definition wave_warp_modifier.h:155
WavetableComponentFactory::ComponentType getType() override
Returns the type of this WavetableComponent.
Definition wave_warp_modifier.cpp:122
WaveWarpModifierKeyframe * getKeyframe(int index)
Retrieves a WaveWarpModifierKeyframe by index.
Definition wave_warp_modifier.cpp:139
ComponentType
Enumerates all known WavetableComponents, including sources and modifiers.
Definition wavetable_component_factory.h:28
A base class representing a component in a wavetable synthesis chain.
Definition wavetable_component.h:32
Represents a single state of a waveform at a specific position in a wavetable.
Definition wavetable_keyframe.h:35
Represents a single frame of a wavetable, containing both time-domain and frequency-domain data.
Definition wave_frame.h:16
nlohmann::json json
Definition line_generator.h:7