Vital
|
A WavetableComponent that applies a wave-folding transformation to a waveform. More...
#include <wave_fold_modifier.h>
Classes | |
class | WaveFoldModifierKeyframe |
A keyframe class that stores the fold boost parameter for wave-folding at a given position. More... | |
Public Member Functions | |
WaveFoldModifier () | |
Constructs a WaveFoldModifier with no additional initialization. | |
virtual | ~WaveFoldModifier () |
WavetableKeyframe * | createKeyframe (int position) override |
Creates a new keyframe at a given position. | |
void | render (vital::WaveFrame *wave_frame, float position) override |
Renders the waveform at a given position into a WaveFrame. | |
WavetableComponentFactory::ComponentType | getType () override |
Returns the type of this WavetableComponent. | |
WaveFoldModifierKeyframe * | getKeyframe (int index) |
Retrieves a WaveFoldModifierKeyframe at a given index. | |
![]() | |
WavetableComponent () | |
Constructs a WavetableComponent with a default linear interpolation style. | |
virtual | ~WavetableComponent () |
virtual json | stateToJson () |
Serializes the component’s state and all keyframes to a JSON object. | |
virtual void | jsonToState (json data) |
Restores the component’s state from a JSON object. | |
virtual void | prerender () |
Called before rendering to perform any needed precomputation. | |
virtual bool | hasKeyframes () |
Indicates whether this component relies on multiple keyframes. | |
void | reset () |
Clears all keyframes and inserts a default one at position 0. | |
void | interpolate (WavetableKeyframe *dest, float position) |
Interpolates a destination keyframe at a given position. | |
WavetableKeyframe * | insertNewKeyframe (int position) |
Inserts a new keyframe at the given position, creating and sorting it into the array. | |
void | reposition (WavetableKeyframe *keyframe) |
Repositions a keyframe in the keyframe list after its position changed. | |
void | remove (WavetableKeyframe *keyframe) |
Removes a specific keyframe from the component. | |
int | numFrames () const |
Gets the number of keyframes. | |
int | indexOf (WavetableKeyframe *keyframe) const |
Finds the index of a given keyframe. | |
WavetableKeyframe * | getFrameAt (int index) const |
Gets a keyframe by index. | |
int | getIndexFromPosition (int position) const |
Finds the insertion index for a given position to keep keyframes sorted. | |
WavetableKeyframe * | getFrameAtPosition (int position) |
Gets a keyframe by position if one matches exactly, or nullptr otherwise. | |
int | getLastKeyframePosition () |
Gets the highest position among all keyframes. | |
void | setInterpolationStyle (InterpolationStyle type) |
Sets the global interpolation style. | |
InterpolationStyle | getInterpolationStyle () const |
Gets the current global interpolation style. | |
Protected Attributes | |
WaveFoldModifierKeyframe | compute_frame_ |
A keyframe for intermediate computations. | |
![]() | |
std::vector< std::unique_ptr< WavetableKeyframe > > | keyframes_ |
The list of keyframes sorted by position. | |
InterpolationStyle | interpolation_style_ |
Current interpolation style (none, linear, cubic). | |
Additional Inherited Members | |
![]() | |
enum | InterpolationStyle { kNone , kLinear , kCubic , kNumInterpolationStyles } |
Defines how interpolation is performed between keyframes. More... | |
A WavetableComponent that applies a wave-folding transformation to a waveform.
WaveFoldModifier nonlinearly warps the waveform’s amplitude values, using a wave-folding approach reminiscent of analog wavefolders. By boosting and folding the waveform, it can add rich harmonic content and transform simple waves into more complex timbres. The amount of folding is controlled by a "fold boost" parameter in the keyframes.
|
inline |
Constructs a WaveFoldModifier with no additional initialization.
|
inlinevirtual |
|
overridevirtual |
Creates a new keyframe at a given position.
Implemented by subclasses to produce a keyframe type suited to their functionality.
position | The wavetable frame index (0 to kNumOscillatorWaveFrames-1). |
Implements WavetableComponent.
WaveFoldModifier::WaveFoldModifierKeyframe * WaveFoldModifier::getKeyframe | ( | int | index | ) |
Retrieves a WaveFoldModifierKeyframe at a given index.
index | The index of the desired keyframe. |
|
overridevirtual |
Returns the type of this WavetableComponent.
Used to identify the specific component for serialization and UI mapping.
Implements WavetableComponent.
|
overridevirtual |
Renders the waveform at a given position into a WaveFrame.
Uses interpolation between keyframes based on the current interpolation style to produce a waveform for the given position.
wave_frame | The WaveFrame to fill with the resulting waveform. |
position | The position along the wavetable dimension [0, kNumOscillatorWaveFrames-1]. |
Implements WavetableComponent.
|
protected |
A keyframe for intermediate computations.