12 if (window_shape ==
kCos)
17 return t < 1.0f ? 0.0f : 1.0f;
19 return t * cosf(
vital::kPi * (t * 1.5f + 0.5f));
26 static constexpr float kDefaultOffset = 0.25f;
53 if (t >= left_position_)
62 if (t <= right_position_)
73 data[
"left_position"] = left_position_;
74 data[
"right_position"] = right_position_;
80 left_position_ = data[
"left_position"];
81 right_position_ = data[
"right_position"];
A keyframe class that stores the window shape and positions at a given table position.
Definition wave_window_modifier.h:51
json stateToJson() override
Serializes the state of this keyframe to a JSON object.
Definition wave_window_modifier.cpp:71
WaveWindowModifierKeyframe()
Constructs a WaveWindowModifierKeyframe with a default window shape and positions.
Definition wave_window_modifier.cpp:24
void render(vital::WaveFrame *wave_frame) override
Renders the waveform of this keyframe into a WaveFrame.
Definition wave_window_modifier.cpp:49
WindowShape window_shape_
The chosen window shape for this keyframe.
Definition wave_window_modifier.h:116
float right_position_
The right boundary of the windowing region.
Definition wave_window_modifier.h:115
float left_position_
The left boundary of the windowing region.
Definition wave_window_modifier.h:114
void setWindowShape(WindowShape window_shape)
Sets the window shape for this keyframe.
Definition wave_window_modifier.h:103
void jsonToState(json data) override
Restores the keyframe's state from a JSON object.
Definition wave_window_modifier.cpp:78
void interpolate(const WavetableKeyframe *from_keyframe, const WavetableKeyframe *to_keyframe, float t) override
Linearly interpolates between two keyframes.
Definition wave_window_modifier.cpp:39
void copy(const WavetableKeyframe *keyframe) override
Copies the state from another keyframe of the same type.
Definition wave_window_modifier.cpp:32
json stateToJson() override
Serializes the component’s state and all keyframes to a JSON object.
Definition wave_window_modifier.cpp:101
void render(vital::WaveFrame *wave_frame, float position) override
Renders the waveform at a given position into a WaveFrame.
Definition wave_window_modifier.cpp:90
static float applyWindow(WindowShape window_shape, float t)
Applies the chosen window shape to a given normalized position.
Definition wave_window_modifier.cpp:10
WaveWindowModifierKeyframe compute_frame_
A keyframe for intermediate computations.
Definition wave_window_modifier.h:156
WaveWindowModifierKeyframe * getKeyframe(int index)
Retrieves a WaveWindowModifierKeyframe by index.
Definition wave_window_modifier.cpp:112
WindowShape window_shape_
The global window shape used.
Definition wave_window_modifier.h:157
void jsonToState(json data) override
Restores the component’s state from a JSON object.
Definition wave_window_modifier.cpp:107
WavetableComponentFactory::ComponentType getType() override
Returns the type of this WavetableComponent.
Definition wave_window_modifier.cpp:97
WavetableKeyframe * createKeyframe(int position) override
Creates a new keyframe at a given position.
Definition wave_window_modifier.cpp:84
WindowShape
Defines different windowing curves.
Definition wave_window_modifier.h:25
@ kWiggle
A more complex wiggle-based shape.
Definition wave_window_modifier.h:30
@ kCos
A cosine-based window (smooth rise/fall).
Definition wave_window_modifier.h:26
@ kHalfSin
A half-sine window shape.
Definition wave_window_modifier.h:27
@ kSquare
A sudden step (square) window.
Definition wave_window_modifier.h:29
ComponentType
Enumerates all known WavetableComponents, including sources and modifiers.
Definition wavetable_component_factory.h:28
@ kWaveWindow
Modifier that applies window functions to the wave.
Definition wavetable_component_factory.h:37
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
virtual void jsonToState(json data)
Restores the component’s state from a JSON object.
Definition wavetable_component.cpp:37
std::vector< std::unique_ptr< WavetableKeyframe > > keyframes_
The list of keyframes sorted by position.
Definition wavetable_component.h:219
Represents a single state of a waveform at a specific position in a wavetable.
Definition wavetable_keyframe.h:35
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
Represents a single frame of a wavetable, containing both time-domain and frequency-domain data.
Definition wave_frame.h:16
void toFrequencyDomain()
Converts the currently loaded time-domain data into frequency-domain representation.
Definition wave_frame.cpp:64
static constexpr int kWaveformSize
The size of the waveform (number of samples per frame).
Definition wave_frame.h:21
mono_float time_domain[2 *kWaveformSize]
The time-domain data, extended buffer size for FFT alignment.
Definition wave_frame.h:124
nlohmann::json json
Definition line_generator.h:7
constexpr mono_float kPi
Pi constant.
Definition common.h:36