Vital
|
Represents a single state of a waveform at a specific position in a wavetable. More...
#include <wavetable_keyframe.h>
Public Member Functions | |
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 | copy (const WavetableKeyframe *keyframe)=0 |
Copies the state from another keyframe of the same type. | |
virtual void | interpolate (const WavetableKeyframe *from_keyframe, const WavetableKeyframe *to_keyframe, float t)=0 |
Linearly interpolates between two keyframes. | |
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. | |
virtual void | render (vital::WaveFrame *wave_frame)=0 |
Renders the waveform of this keyframe into a WaveFrame. | |
virtual json | stateToJson () |
Serializes the state of this keyframe to a JSON object. | |
virtual void | jsonToState (json data) |
Restores the keyframe's state from a JSON object. | |
WavetableComponent * | owner () |
Gets the WavetableComponent that owns this keyframe. | |
void | setOwner (WavetableComponent *owner) |
Sets the owner of this keyframe. | |
Static Public Member Functions | |
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. | |
Protected Attributes | |
int | position_ |
The position of this keyframe along the wavetable dimension. | |
WavetableComponent * | owner_ |
The component that owns this keyframe. | |
Represents a single state of a waveform at a specific position in a wavetable.
WavetableKeyframe acts as a snapshot of a waveform configuration at a particular frame index. Wavetable components typically have multiple keyframes spaced across the wavetable dimension. Interpolating between these keyframes produces smooth changes in the waveform over the course of the table.
Each keyframe stores:
Subclasses define how the keyframe’s waveform data is stored and how interpolation and rendering are performed.
|
inline |
Constructs a WavetableKeyframe with a default position of 0 and no owner.
|
inlinevirtual |
|
pure virtual |
Copies the state from another keyframe of the same type.
keyframe | The source keyframe to copy from. |
Implemented in FileSource::FileSourceKeyframe, FrequencyFilterModifier::FrequencyFilterModifierKeyframe, PhaseModifier::PhaseModifierKeyframe, SlewLimitModifier::SlewLimitModifierKeyframe, WaveFoldModifier::WaveFoldModifierKeyframe, WaveLineSource::WaveLineSourceKeyframe, WaveSourceKeyframe, WaveWarpModifier::WaveWarpModifierKeyframe, and WaveWindowModifier::WaveWindowModifierKeyframe.
|
static |
Performs cubic interpolation taking into account a previous and next point for smoother curves.
point_prev | The value before the start. |
point_from | The starting value. |
point_to | The ending value. |
point_next | The value after the end. |
range_prev | The horizontal distance to point_prev. |
range | The horizontal distance between point_from and point_to. |
range_next | The horizontal distance to point_next. |
t | The interpolation factor [0,1]. |
int WavetableKeyframe::index | ( | ) |
Gets the index of this keyframe within its owner component.
|
pure virtual |
Linearly interpolates between two keyframes.
from_keyframe | The starting keyframe. |
to_keyframe | The ending keyframe. |
t | The interpolation factor [0,1]. |
Implemented in FileSource::FileSourceKeyframe, FrequencyFilterModifier::FrequencyFilterModifierKeyframe, PhaseModifier::PhaseModifierKeyframe, SlewLimitModifier::SlewLimitModifierKeyframe, WaveFoldModifier::WaveFoldModifierKeyframe, WaveLineSource::WaveLineSourceKeyframe, WaveSourceKeyframe, WaveWarpModifier::WaveWarpModifierKeyframe, and WaveWindowModifier::WaveWindowModifierKeyframe.
|
virtual |
Restores the keyframe's state from a JSON object.
data | The JSON object containing the keyframe's state. |
Reimplemented in FileSource::FileSourceKeyframe, FrequencyFilterModifier::FrequencyFilterModifierKeyframe, PhaseModifier::PhaseModifierKeyframe, SlewLimitModifier::SlewLimitModifierKeyframe, WaveFoldModifier::WaveFoldModifierKeyframe, WaveLineSource::WaveLineSourceKeyframe, WaveSourceKeyframe, WaveWarpModifier::WaveWarpModifierKeyframe, and WaveWindowModifier::WaveWindowModifierKeyframe.
|
static |
Performs linear interpolation between two points.
point_from | The starting value. |
point_to | The ending value. |
t | The interpolation factor [0,1]. |
|
inline |
Gets the WavetableComponent that owns this keyframe.
|
inline |
Gets the wavetable frame position of this keyframe.
|
pure virtual |
Renders the waveform of this keyframe into a WaveFrame.
wave_frame | The WaveFrame to fill with this keyframe's waveform data. |
Implemented in FileSource::FileSourceKeyframe, FrequencyFilterModifier::FrequencyFilterModifierKeyframe, PhaseModifier::PhaseModifierKeyframe, SlewLimitModifier::SlewLimitModifierKeyframe, WaveFoldModifier::WaveFoldModifierKeyframe, WaveLineSource::WaveLineSourceKeyframe, WaveSourceKeyframe, WaveWarpModifier::WaveWarpModifierKeyframe, and WaveWindowModifier::WaveWindowModifierKeyframe.
|
inline |
Sets the owner of this keyframe.
owner | The WavetableComponent that owns this keyframe. |
|
inline |
Sets the frame position of this keyframe.
position | The new frame position. |
|
inlinevirtual |
Performs a smooth (cubic) interpolation using four keyframes for even smoother transitions.
By default does nothing. Subclasses can implement cubic interpolation if desired.
prev_keyframe | The keyframe before from_keyframe. |
from_keyframe | The starting keyframe. |
to_keyframe | The ending keyframe. |
next_keyframe | The keyframe after to_keyframe. |
t | The interpolation factor [0,1]. |
Reimplemented in WaveSourceKeyframe.
|
virtual |
Serializes the state of this keyframe to a JSON object.
Reimplemented in FileSource::FileSourceKeyframe, FrequencyFilterModifier::FrequencyFilterModifierKeyframe, PhaseModifier::PhaseModifierKeyframe, SlewLimitModifier::SlewLimitModifierKeyframe, WaveFoldModifier::WaveFoldModifierKeyframe, WaveLineSource::WaveLineSourceKeyframe, WaveSourceKeyframe, WaveWarpModifier::WaveWarpModifierKeyframe, and WaveWindowModifier::WaveWindowModifierKeyframe.
|
protected |
The component that owns this keyframe.
|
protected |
The position of this keyframe along the wavetable dimension.