17 float range_prev,
float range,
float range_next,
float t) {
19 float slope_from = 0.0f;
20 float slope_to = 0.0f;
21 if (range_prev > 0.0f)
22 slope_from = (point_to - point_prev) / (1.0f + range_prev / range);
23 if (range_next > 0.0f)
24 slope_to = (point_next - point_from) / (1.0f + range_next / range);
25 float delta = point_to - point_from;
27 float movement =
linearTween(point_from, point_to, t);
28 float smooth = t * (1.0f - t) * ((1.0f - t) * (slope_from - delta) + t * (delta - slope_to));
29 return movement + smooth;
int indexOf(WavetableKeyframe *keyframe) const
Finds the index of a given keyframe.
Definition wavetable_component.h:163
static float linearTween(float point_from, float point_to, float t)
Performs linear interpolation between two points.
Definition wavetable_keyframe.cpp:11
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.
Definition wavetable_keyframe.cpp:16
int index()
Gets the index of this keyframe within its owner component.
Definition wavetable_keyframe.cpp:32
WavetableComponent * owner()
Gets the WavetableComponent that owns this keyframe.
Definition wavetable_keyframe.h:152
int position_
The position of this keyframe along the wavetable dimension.
Definition wavetable_keyframe.h:162
virtual json stateToJson()
Serializes the state of this keyframe to a JSON object.
Definition wavetable_keyframe.cpp:37
virtual void jsonToState(json data)
Restores the keyframe's state from a JSON object.
Definition wavetable_keyframe.cpp:41
nlohmann::json json
Definition line_generator.h:7
force_inline poly_float interpolate(poly_float from, poly_float to, mono_float t)
Performs a linear interpolation between two poly_floats using a scalar t in [0..1].
Definition poly_utils.h:182
Provides various utility functions, classes, and constants for audio, math, and general-purpose opera...