15 line_generator_(
vital::WaveFrame::kWaveformSize) {
24 line_generator_.setSmooth(source_generator->
smooth());
25 for (
int i = 0; i < line_generator_.getNumPoints(); ++i) {
26 line_generator_.setPoint(i, source_generator->
getPoint(i));
27 line_generator_.setPower(i, source_generator->
getPower(i));
45 line_generator_.setNumPoints(num_points);
46 line_generator_.setSmooth(from_generator->
smooth());
49 for (
int i = 0; i < num_points; ++i) {
50 std::pair<float, float> from_point = from_generator->
getPoint(i);
51 std::pair<float, float> to_point = to_generator->
getPoint(i);
52 line_generator_.setPoint(i, {
53 linearTween(from_point.first, to_point.first, adjusted_t),
54 linearTween(from_point.second, to_point.second, adjusted_t),
56 line_generator_.setPower(i, linearTween(from_generator->
getPower(i), to_generator->
getPower(i), adjusted_t));
62 line_generator_.render();
71 data[
"pull_power"] = pull_power_;
72 data[
"line"] = line_generator_.stateToJson();
79 if (data.count(
"pull_power"))
80 pull_power_ = data[
"pull_power"];
81 if (data.count(
"line"))
82 line_generator_.jsonToState(data[
"line"]);
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 bool smooth() const
Indicates whether smoothing is enabled.
Definition line_generator.h:280
force_inline int getNumPoints() const
Returns the current number of points defining the line.
Definition line_generator.h:327
force_inline void setNumPoints(int num_points)
Sets the number of points currently in use.
Definition line_generator.h:360
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
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
json stateToJson() override
Serializes the state of this keyframe to a JSON object.
Definition wave_line_source.cpp:69
void interpolate(const WavetableKeyframe *from_keyframe, const WavetableKeyframe *to_keyframe, float t) override
Linearly interpolates between two keyframes.
Definition wave_line_source.cpp:31
WaveLineSourceKeyframe * getKeyframe(int index)
Retrieves a WaveLineSourceKeyframe by index.
Definition wave_line_source.cpp:116
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
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
ComponentType
Enumerates all known WavetableComponents, including sources and modifiers.
Definition wavetable_component_factory.h:28
@ kLineSource
A line-based wave source.
Definition wavetable_component_factory.h:30
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
#define VITAL_ASSERT(x)
Definition common.h:11
Contains faster but less accurate versions of utility math functions, such as exponential,...
nlohmann::json json
Definition line_generator.h:7
force_inline mono_float powerScale(mono_float value, mono_float power)
A power-scaling function to map a linear range to a curved response.
Definition futils.h:455
Contains classes and functions used within the Vital synthesizer framework.
Provides various utility functions, classes, and constants for audio, math, and general-purpose opera...