13using json = nlohmann::json;
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
int numFrames() const
Gets the number of keyframes.
Definition wavetable_component.h:155
virtual WavetableKeyframe * createKeyframe(int position)=0
Creates a new keyframe at a given position.
WavetableKeyframe * getFrameAt(int index) const
Gets a keyframe by index.
Definition wavetable_component.h:177
InterpolationStyle
Defines how interpolation is performed between keyframes.
Definition wavetable_component.h:38
@ kLinear
Linear interpolation between adjacent keyframes.
Definition wavetable_component.h:40
@ kNone
No interpolation, just jumps between keyframes.
Definition wavetable_component.h:39
@ kNumInterpolationStyles
Definition wavetable_component.h:42
@ kCubic
Cubic interpolation for smoother transitions.
Definition wavetable_component.h:41
virtual json stateToJson()
Serializes the component’s state and all keyframes to a JSON object.
Definition wavetable_component.cpp:49
void interpolate(WavetableKeyframe *dest, float position)
Interpolates a destination keyframe at a given position.
Definition wavetable_component.cpp:68
void reset()
Clears all keyframes and inserts a default one at position 0.
Definition wavetable_component.cpp:62
WavetableKeyframe * insertNewKeyframe(int position)
Inserts a new keyframe at the given position, creating and sorting it into the array.
Definition wavetable_component.cpp:8
virtual void jsonToState(json data)
Restores the component’s state from a JSON object.
Definition wavetable_component.cpp:37
virtual void prerender()
Called before rendering to perform any needed precomputation.
Definition wavetable_component.h:101
int getLastKeyframePosition()
Gets the highest position among all keyframes.
Definition wavetable_component.cpp:127
int indexOf(WavetableKeyframe *keyframe) const
Finds the index of a given keyframe.
Definition wavetable_component.h:163
void setInterpolationStyle(InterpolationStyle type)
Sets the global interpolation style.
Definition wavetable_component.h:209
std::vector< std::unique_ptr< WavetableKeyframe > > keyframes_
The list of keyframes sorted by position.
Definition wavetable_component.h:219
WavetableKeyframe * getFrameAtPosition(int position)
Gets a keyframe by position if one matches exactly, or nullptr otherwise.
Definition wavetable_component.cpp:119
InterpolationStyle getInterpolationStyle() const
Gets the current global interpolation style.
Definition wavetable_component.h:216
virtual void render(vital::WaveFrame *wave_frame, float position)=0
Renders the waveform at a given position into a WaveFrame.
WavetableComponent()
Constructs a WavetableComponent with a default linear interpolation style.
Definition wavetable_component.h:48
virtual WavetableComponentFactory::ComponentType getType()=0
Returns the type of this WavetableComponent.
int getIndexFromPosition(int position) const
Finds the insertion index for a given position to keep keyframes sorted.
Definition wavetable_component.cpp:107
void remove(WavetableKeyframe *keyframe)
Removes a specific keyframe from the component.
Definition wavetable_component.cpp:31
virtual bool hasKeyframes()
Indicates whether this component relies on multiple keyframes.
Definition wavetable_component.h:108
virtual ~WavetableComponent()
Definition wavetable_component.h:49
void reposition(WavetableKeyframe *keyframe)
Repositions a keyframe in the keyframe list after its position changed.
Definition wavetable_component.cpp:21
InterpolationStyle interpolation_style_
Current interpolation style (none, linear, cubic).
Definition wavetable_component.h:220
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
Contains classes and functions used within the Vital synthesizer framework.