A class for generating and storing a line shape, defined by a series of points and associated powers.
Definition line_generator.h:20
force_inline int getNumPoints() const
Returns the current number of points defining the line.
Definition line_generator.h:327
force_inline void setPower(int index, float power)
Sets the power for a specific point.
Definition line_generator.h:349
void addMiddlePoint(int index)
Inserts a point exactly between two existing points.
Definition line_generator.cpp:251
force_inline void setPoint(int index, std::pair< float, float > point)
Sets the position of a specific point.
Definition line_generator.h:337
void setSmooth(bool smooth)
Enables or disables smoothing behavior.
Definition line_generator.h:96
void removePoint(int index)
Removes the point at a specified index.
Definition line_generator.cpp:259
force_inline std::pair< float, float > getPoint(int index) const
Returns a point at the given index.
Definition line_generator.h:306
force_inline float getPower(int index) const
Returns the power at the given index.
Definition line_generator.h:317
A keyframe class that represents a particular line-based waveform configuration at a given position.
Definition wave_line_source.h:36
float getPower(int index) const
Retrieves the power value for a given point.
Definition wave_line_source.h:67
LineGenerator * getLineGenerator()
Provides access to the underlying LineGenerator for modification.
Definition wave_line_source.h:141
int getNumPoints() const
Gets the number of points defining the line.
Definition wave_line_source.h:104
void jsonToState(json data) override
Restores the keyframe's state from a JSON object.
Definition wave_line_source.cpp:76
void render(vital::WaveFrame *wave_frame) override
Renders the waveform of this keyframe into a WaveFrame.
Definition wave_line_source.cpp:60
float pull_power_
Controls nonlinear interpolation between keyframes.
Definition wave_line_source.h:145
WaveLineSourceKeyframe()
Constructs a WaveLineSourceKeyframe with default parameters.
Definition wave_line_source.cpp:14
void copy(const WavetableKeyframe *keyframe) override
Copies the state from another keyframe of the same type.
Definition wave_line_source.cpp:19
const LineGenerator * getLineGenerator() const
Provides const access to the underlying LineGenerator.
Definition wave_line_source.h:134
float getPullPower() const
Gets the current pull power value.
Definition wave_line_source.h:127
virtual ~WaveLineSourceKeyframe()=default
void removePoint(int index)
Removes a point from the line definition.
Definition wave_line_source.h:90
std::pair< float, float > getPoint(int index) const
Retrieves a point (x,y) by index.
Definition wave_line_source.h:57
void setSmooth(bool smooth)
Sets whether the line should be smoothed.
Definition wave_line_source.h:113
json stateToJson() override
Serializes the state of this keyframe to a JSON object.
Definition wave_line_source.cpp:69
void addMiddlePoint(int index)
Inserts a middle point between two existing points.
Definition wave_line_source.h:97
LineGenerator line_generator_
The generator producing the line-based waveform.
Definition wave_line_source.h:144
void interpolate(const WavetableKeyframe *from_keyframe, const WavetableKeyframe *to_keyframe, float t) override
Linearly interpolates between two keyframes.
Definition wave_line_source.cpp:31
void setPullPower(float power)
Sets the pull power, which influences how interpolation occurs between keyframes.
Definition wave_line_source.h:120
void setPoint(std::pair< float, float > point, int index)
Sets a point’s position.
Definition wave_line_source.h:75
void setPower(float power, int index)
Sets the power for a given point.
Definition wave_line_source.h:83
A WavetableComponent that generates waveforms from a series of line segments.
Definition wave_line_source.h:23
WaveLineSourceKeyframe * getKeyframe(int index)
Retrieves a WaveLineSourceKeyframe by index.
Definition wave_line_source.cpp:116
static constexpr int kDefaultLinePoints
The default number of line points used if none are specified.
Definition wave_line_source.h:26
int num_points_
The number of points defining the line-based waveform.
Definition wave_line_source.h:185
WavetableComponentFactory::ComponentType getType() override
Returns the type of this WavetableComponent.
Definition wave_line_source.cpp:97
WaveLineSource()
Constructs a WaveLineSource with a default number of points.
Definition wave_line_source.h:153
int numPoints()
Returns the current number of points in the line generator.
Definition wave_line_source.h:174
json stateToJson() override
Serializes the component’s state and all keyframes to a JSON object.
Definition wave_line_source.cpp:101
void jsonToState(json data) override
Restores the component’s state from a JSON object.
Definition wave_line_source.cpp:107
void setNumPoints(int num_points)
Sets the number of points used by the line generator.
Definition wave_line_source.cpp:112
WavetableKeyframe * createKeyframe(int position) override
Creates a new keyframe at a given position.
Definition wave_line_source.cpp:85
WaveLineSourceKeyframe compute_frame_
A keyframe for intermediate computations.
Definition wave_line_source.h:186
void render(vital::WaveFrame *wave_frame, float position) override
Renders the waveform at a given position into a WaveFrame.
Definition wave_line_source.cpp:91
virtual ~WaveLineSource()=default
ComponentType
Enumerates all known WavetableComponents, including sources and modifiers.
Definition wavetable_component_factory.h:28
A base class representing a component in a wavetable synthesis chain.
Definition wavetable_component.h:32
Represents a single state of a waveform at a specific position in a wavetable.
Definition wavetable_keyframe.h:35
int index()
Gets the index of this keyframe within its owner component.
Definition wavetable_keyframe.cpp:32
Represents a single frame of a wavetable, containing both time-domain and frequency-domain data.
Definition wave_frame.h:16
nlohmann::json json
Definition line_generator.h:7