Vital
Loading...
Searching...
No Matches
WavetableGroup Class Reference

A class representing a group of WavetableComponents combined to form part of a wavetable. More...

#include <wavetable_group.h>

Public Member Functions

 WavetableGroup ()
 Constructs an empty WavetableGroup.
 
int getComponentIndex (WavetableComponent *component)
 Gets the index of a particular WavetableComponent within this group.
 
void addComponent (WavetableComponent *component)
 Adds a new WavetableComponent to this group.
 
void removeComponent (int index)
 Removes a component at a given index.
 
void moveUp (int index)
 Moves a component one position up in the ordering.
 
void moveDown (int index)
 Moves a component one position down in the ordering.
 
void reset ()
 Clears all components and loads a default group configuration.
 
void prerender ()
 Allows components to precompute any necessary data before rendering.
 
int numComponents () const
 Gets the number of WavetableComponents in this group.
 
WavetableComponentgetComponent (int index) const
 Retrieves a component by index.
 
bool isShepardTone ()
 Determines if all components in this group produce a Shepard tone.
 
void render (vital::WaveFrame *wave_frame, float position) const
 Renders the combined waveform for a given position from all components.
 
void renderTo (vital::Wavetable *wavetable)
 Renders the entire group directly into a Wavetable object.
 
void loadDefaultGroup ()
 Loads a default group configuration (e.g., a basic wave source).
 
int getLastKeyframePosition ()
 Gets the largest keyframe position among all components in the group.
 
json stateToJson ()
 Serializes this group's state, including all its components, to JSON.
 
void jsonToState (json data)
 Restores this group's state from a JSON object.
 

Protected Attributes

vital::WaveFrame compute_frame_
 Temporary WaveFrame for combining component outputs.
 
std::vector< std::unique_ptr< WavetableComponent > > components_
 The list of components in this group.
 

Detailed Description

A class representing a group of WavetableComponents combined to form part of a wavetable.

A WavetableGroup holds multiple WavetableComponents (sources or modifiers) that work together to generate or transform a waveform. By combining and averaging their outputs, the group produces a single resulting waveform for any given position. WavetableGroups can be stacked by the WavetableCreator to form complex, layered sounds.

Constructor & Destructor Documentation

◆ WavetableGroup()

WavetableGroup::WavetableGroup ( )
inline

Constructs an empty WavetableGroup.

Member Function Documentation

◆ addComponent()

void WavetableGroup::addComponent ( WavetableComponent * component)
inline

Adds a new WavetableComponent to this group.

Parameters
componentThe WavetableComponent to add (transfers ownership).

◆ getComponent()

WavetableComponent * WavetableGroup::getComponent ( int index) const
inline

Retrieves a component by index.

Parameters
indexThe index of the component.
Returns
A pointer to the WavetableComponent at that index.

◆ getComponentIndex()

int WavetableGroup::getComponentIndex ( WavetableComponent * component)

Gets the index of a particular WavetableComponent within this group.

Parameters
componentThe component to find.
Returns
The index of the component or -1 if not found.

◆ getLastKeyframePosition()

int WavetableGroup::getLastKeyframePosition ( )

Gets the largest keyframe position among all components in the group.

Returns
The highest keyframe position found.

◆ isShepardTone()

bool WavetableGroup::isShepardTone ( )

Determines if all components in this group produce a Shepard tone.

This is used to check if the entire group is producing a special "shepard tone" type table.

Returns
True if all components are Shepard tone sources, false otherwise.

◆ jsonToState()

void WavetableGroup::jsonToState ( json data)

Restores this group's state from a JSON object.

Clears existing components and rebuilds them from the JSON data.

Parameters
dataThe JSON object containing the group's saved state.

◆ loadDefaultGroup()

void WavetableGroup::loadDefaultGroup ( )

Loads a default group configuration (e.g., a basic wave source).

◆ moveDown()

void WavetableGroup::moveDown ( int index)

Moves a component one position down in the ordering.

Parameters
indexThe index of the component to move.

◆ moveUp()

void WavetableGroup::moveUp ( int index)

Moves a component one position up in the ordering.

Parameters
indexThe index of the component to move.

◆ numComponents()

int WavetableGroup::numComponents ( ) const
inline

Gets the number of WavetableComponents in this group.

Returns
The number of components.

◆ prerender()

void WavetableGroup::prerender ( )

Allows components to precompute any necessary data before rendering.

◆ removeComponent()

void WavetableGroup::removeComponent ( int index)

Removes a component at a given index.

Parameters
indexThe index of the component to remove.

◆ render()

void WavetableGroup::render ( vital::WaveFrame * wave_frame,
float position ) const

Renders the combined waveform for a given position from all components.

Each component is rendered and their outputs are combined to form a single WaveFrame result.

Parameters
wave_frameThe WaveFrame to fill with the resulting waveform.
positionThe position along the wavetable dimension.

◆ renderTo()

void WavetableGroup::renderTo ( vital::Wavetable * wavetable)

Renders the entire group directly into a Wavetable object.

This fills all frames of the Wavetable.

Parameters
wavetableThe Wavetable to fill.

◆ reset()

void WavetableGroup::reset ( )

Clears all components and loads a default group configuration.

◆ stateToJson()

json WavetableGroup::stateToJson ( )

Serializes this group's state, including all its components, to JSON.

Returns
A JSON object representing the group's state.

Member Data Documentation

◆ components_

std::vector<std::unique_ptr<WavetableComponent> > WavetableGroup::components_
protected

The list of components in this group.

◆ compute_frame_

vital::WaveFrame WavetableGroup::compute_frame_
protected

Temporary WaveFrame for combining component outputs.


The documentation for this class was generated from the following files: