Vital
|
A keyframe class that represents a particular line-based waveform configuration at a given position. More...
#include <wave_line_source.h>
Public Member Functions | |
WaveLineSourceKeyframe () | |
Constructs a WaveLineSourceKeyframe with default parameters. | |
virtual | ~WaveLineSourceKeyframe ()=default |
void | copy (const WavetableKeyframe *keyframe) override |
Copies the state from another keyframe of the same type. | |
void | interpolate (const WavetableKeyframe *from_keyframe, const WavetableKeyframe *to_keyframe, float t) override |
Linearly interpolates between two keyframes. | |
void | render (vital::WaveFrame *wave_frame) override |
Renders the waveform of this keyframe into a WaveFrame. | |
json | stateToJson () override |
Serializes the state of this keyframe to a JSON object. | |
void | jsonToState (json data) override |
Restores the keyframe's state from a JSON object. | |
std::pair< float, float > | getPoint (int index) const |
Retrieves a point (x,y) by index. | |
float | getPower (int index) const |
Retrieves the power value for a given point. | |
void | setPoint (std::pair< float, float > point, int index) |
Sets a point’s position. | |
void | setPower (float power, int index) |
Sets the power for a given point. | |
void | removePoint (int index) |
Removes a point from the line definition. | |
void | addMiddlePoint (int index) |
Inserts a middle point between two existing points. | |
int | getNumPoints () const |
Gets the number of points defining the line. | |
void | setSmooth (bool smooth) |
Sets whether the line should be smoothed. | |
void | setPullPower (float power) |
Sets the pull power, which influences how interpolation occurs between keyframes. | |
float | getPullPower () const |
Gets the current pull power value. | |
const LineGenerator * | getLineGenerator () const |
Provides const access to the underlying LineGenerator. | |
LineGenerator * | getLineGenerator () |
Provides access to the underlying LineGenerator for modification. | |
![]() | |
WavetableKeyframe () | |
Constructs a WavetableKeyframe with a default position of 0 and no owner. | |
virtual | ~WavetableKeyframe () |
int | index () |
Gets the index of this keyframe within its owner component. | |
int | position () const |
Gets the wavetable frame position of this keyframe. | |
void | setPosition (int position) |
Sets the frame position of this keyframe. | |
virtual void | smoothInterpolate (const WavetableKeyframe *prev_keyframe, const WavetableKeyframe *from_keyframe, const WavetableKeyframe *to_keyframe, const WavetableKeyframe *next_keyframe, float t) |
Performs a smooth (cubic) interpolation using four keyframes for even smoother transitions. | |
WavetableComponent * | owner () |
Gets the WavetableComponent that owns this keyframe. | |
void | setOwner (WavetableComponent *owner) |
Sets the owner of this keyframe. | |
Protected Attributes | |
LineGenerator | line_generator_ |
The generator producing the line-based waveform. | |
float | pull_power_ |
Controls nonlinear interpolation between keyframes. | |
![]() | |
int | position_ |
The position of this keyframe along the wavetable dimension. | |
WavetableComponent * | owner_ |
The component that owns this keyframe. | |
Additional Inherited Members | |
![]() | |
static float | linearTween (float point_from, float point_to, float t) |
Performs linear interpolation between two points. | |
static float | cubicTween (float point_prev, float point_from, float point_to, float point_next, float range_prev, float range, float range_next, float t) |
Performs cubic interpolation taking into account a previous and next point for smoother curves. | |
A keyframe class that represents a particular line-based waveform configuration at a given position.
Each WaveLineSourceKeyframe holds a LineGenerator
which stores multiple points defining the wave shape. Points can be added, removed, have their positions and power values adjusted, and the shape can be smoothed. Interpolating between two keyframes merges their line definitions in a power-scaled manner, controlled by pull_power_
.
WaveLineSource::WaveLineSourceKeyframe::WaveLineSourceKeyframe | ( | ) |
Constructs a WaveLineSourceKeyframe with default parameters.
|
virtualdefault |
|
inline |
Inserts a middle point between two existing points.
index | The index at which to insert a new point in the middle. |
|
overridevirtual |
Copies the state from another keyframe of the same type.
keyframe | The source keyframe to copy from. |
Implements WavetableKeyframe.
|
inline |
Provides access to the underlying LineGenerator for modification.
|
inline |
Provides const access to the underlying LineGenerator.
|
inline |
Gets the number of points defining the line.
|
inline |
Retrieves a point (x,y) by index.
index | The point index. |
|
inline |
Retrieves the power value for a given point.
The power influences how the line transitions at that point.
index | The point index. |
|
inline |
Gets the current pull power value.
|
overridevirtual |
Linearly interpolates between two keyframes.
from_keyframe | The starting keyframe. |
to_keyframe | The ending keyframe. |
t | The interpolation factor [0,1]. |
Implements WavetableKeyframe.
|
overridevirtual |
Restores the keyframe's state from a JSON object.
data | The JSON object containing the keyframe's state. |
Reimplemented from WavetableKeyframe.
|
inline |
Removes a point from the line definition.
index | The index of the point to remove. |
|
overridevirtual |
Renders the waveform of this keyframe into a WaveFrame.
wave_frame | The WaveFrame to fill with this keyframe's waveform data. |
Implements WavetableKeyframe.
|
inline |
Sets a point’s position.
point | The new (x, y) coordinates for the point. |
index | The point index to modify. |
|
inline |
Sets the power for a given point.
power | The new power value. |
index | The point index. |
|
inline |
Sets the pull power, which influences how interpolation occurs between keyframes.
power | The new pull power value. |
|
inline |
Sets whether the line should be smoothed.
If smooth is true, the line transitions are more gradual.
smooth | True to enable smoothing, false otherwise. |
|
overridevirtual |
Serializes the state of this keyframe to a JSON object.
Reimplemented from WavetableKeyframe.
|
protected |
The generator producing the line-based waveform.
|
protected |
Controls nonlinear interpolation between keyframes.