Vital
Loading...
Searching...
No Matches
wavetable_group.h
Go to the documentation of this file.
1/*
2Summary:
3WavetableGroup manages a collection of WavetableComponents, each potentially generating or modifying waveforms. It allows adding, removing, and reordering components, provides methods to render their combined output at any position in the wavetable, and handles serialization. By grouping components, it supports layering and complex combinations that form part of a larger WavetableCreator pipeline.
4 */
5
6#pragma once
7
8#include "JuceHeader.h"
9#include "wave_frame.h"
10#include "wavetable_component.h"
11
12namespace vital {
13 class Wavetable;
14} // namespace vital
15
25public:
30
38
45 components_.push_back(std::unique_ptr<WavetableComponent>(component));
46 }
47
53 void removeComponent(int index);
54
60 void moveUp(int index);
61
67 void moveDown(int index);
68
72 void reset();
73
77 void prerender();
78
84 int numComponents() const { return static_cast<int>(components_.size()); }
85
92 WavetableComponent* getComponent(int index) const { return components_[index].get(); }
93
101 bool isShepardTone();
102
111 void render(vital::WaveFrame* wave_frame, float position) const;
112
120 void renderTo(vital::Wavetable* wavetable);
121
125 void loadDefaultGroup();
126
133
140
148 void jsonToState(json data);
149
150protected:
152 std::vector<std::unique_ptr<WavetableComponent>> components_;
153
154 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WavetableGroup)
155};
A base class representing a component in a wavetable synthesis chain.
Definition wavetable_component.h:32
A class representing a group of WavetableComponents combined to form part of a wavetable.
Definition wavetable_group.h:24
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
WavetableComponent * getComponent(int index) const
Retrieves a component by index.
Definition wavetable_group.h:92
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
WavetableGroup()
Constructs an empty WavetableGroup.
Definition wavetable_group.h:29
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
int numComponents() const
Gets the number of WavetableComponents in this group.
Definition wavetable_group.h:84
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
A class representing a wavetable, holding multiple frames of waveforms and their frequency-domain rep...
Definition wavetable.h:20
nlohmann::json json
Definition line_generator.h:7
Contains classes and functions used within the Vital synthesizer framework.