40 std::unique_ptr<WavetableComponent> component = std::move(
components_[index]);
53 component->prerender();
68 wave_frame->
index = position;
71 component->render(wave_frame, position);
94 wave_frame->
time_domain[half_shift] = 1.0f - 2.0f * t;
103 int last_position = 0;
105 last_position = std::max(last_position, component->getLastKeyframePosition());
107 return last_position;
112 json json_components;
114 json json_component = component->stateToJson();
115 json_components.push_back(json_component);
118 return { {
"components", json_components } };
125 json json_components = data[
"components"];
126 for (
json json_component : json_components) {
127 std::string type = json_component[
"type"];
A WavetableComponent that acts as a direct source of waveforms.
Definition wave_source.h:25
vital::WaveFrame * getWaveFrame(int index)
Gets a WaveFrame from a specified keyframe index.
Definition wave_source.cpp:47
static WavetableComponent * createComponent(ComponentType type)
Creates a new WavetableComponent instance of a given enumerated type.
Definition wavetable_component_factory.cpp:19
@ kShepardToneSource
Definition wavetable_component_factory.h:33
A base class representing a component in a wavetable synthesis chain.
Definition wavetable_component.h:32
WavetableKeyframe * insertNewKeyframe(int position)
Inserts a new keyframe at the given position, creating and sorting it into the array.
Definition wavetable_component.cpp:8
virtual void jsonToState(json data)
Restores the component’s state from a JSON object.
Definition wavetable_component.cpp:37
void reset()
Clears all components and loads a default group configuration.
Definition wavetable_group.cpp:44
void jsonToState(json data)
Restores this group's state from a JSON object.
Definition wavetable_group.cpp:121
void addComponent(WavetableComponent *component)
Adds a new WavetableComponent to this group.
Definition wavetable_group.h:44
void moveUp(int index)
Moves a component one position up in the ordering.
Definition wavetable_group.cpp:20
void renderTo(vital::Wavetable *wavetable)
Renders the entire group directly into a Wavetable object.
Definition wavetable_group.cpp:74
int getComponentIndex(WavetableComponent *component)
Gets the index of a particular WavetableComponent within this group.
Definition wavetable_group.cpp:12
json stateToJson()
Serializes this group's state, including all its components, to JSON.
Definition wavetable_group.cpp:110
void prerender()
Allows components to precompute any necessary data before rendering.
Definition wavetable_group.cpp:50
int getLastKeyframePosition()
Gets the largest keyframe position among all components in the group.
Definition wavetable_group.cpp:101
void render(vital::WaveFrame *wave_frame, float position) const
Renders the combined waveform for a given position from all components.
Definition wavetable_group.cpp:66
void removeComponent(int index)
Removes a component at a given index.
Definition wavetable_group.cpp:36
bool isShepardTone()
Determines if all components in this group produce a Shepard tone.
Definition wavetable_group.cpp:56
vital::WaveFrame compute_frame_
Temporary WaveFrame for combining component outputs.
Definition wavetable_group.h:151
void loadDefaultGroup()
Loads a default group configuration (e.g., a basic wave source).
Definition wavetable_group.cpp:86
std::vector< std::unique_ptr< WavetableComponent > > components_
The list of components in this group.
Definition wavetable_group.h:152
void moveDown(int index)
Moves a component one position down in the ordering.
Definition wavetable_group.cpp:28
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
int index
The index of this frame in a wavetable.
Definition wave_frame.h:121
A class representing a wavetable, holding multiple frames of waveforms and their frequency-domain rep...
Definition wavetable.h:20
void loadWaveFrame(const WaveFrame *wave_frame)
Load a WaveFrame into the wavetable at the frame index specified by the WaveFrame.
Definition wavetable.cpp:89
nlohmann::json json
Definition line_generator.h:7
constexpr int kNumOscillatorWaveFrames
Number of wave frames in each oscillator’s wavetable.
Definition synth_constants.h:19