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

A class responsible for creating complete wavetables from groups of wavetable components. More...

#include <wavetable_creator.h>

Public Types

enum  AudioFileLoadStyle {
  kNone , kWavetableSplice , kVocoded , kTtwt ,
  kPitched , kNumDragLoadStyles
}
 Defines how audio files are interpreted when loading into a wavetable. More...
 

Public Member Functions

 WavetableCreator (vital::Wavetable *wavetable)
 Constructs a WavetableCreator associated with a given Wavetable object.
 
int getGroupIndex (WavetableGroup *group)
 
void addGroup (WavetableGroup *group)
 
void removeGroup (int index)
 
void moveUp (int index)
 
void moveDown (int index)
 
int numGroups () const
 Gets the total number of WavetableGroups.
 
WavetableGroupgetGroup (int index) const
 Retrieves a WavetableGroup by index.
 
float render (int position)
 
void render ()
 
void postRender (float max_span)
 
void renderToBuffer (float *buffer, int num_frames, int frame_size)
 
void init ()
 
void clear ()
 
void loadDefaultCreator ()
 
void initPredefinedWaves ()
 
void initFromAudioFile (const float *audio_buffer, int num_samples, int sample_rate, AudioFileLoadStyle load_style, FileSource::FadeStyle fade_style)
 
void setName (const std::string &name)
 Sets the name of the wavetable.
 
void setAuthor (const std::string &author)
 Sets the author of the wavetable.
 
void setFileLoaded (const std::string &path)
 Records the path of the last file loaded to create this wavetable.
 
std::string getName () const
 Gets the name of the wavetable.
 
std::string getAuthor () const
 Gets the author of the wavetable.
 
std::string getLastFileLoaded ()
 Gets the last loaded file path.
 
json updateJson (json data)
 
json stateToJson ()
 
void jsonToState (json data)
 
vital::WavetablegetWavetable ()
 Gets the internal wavetable object being created.
 

Static Public Member Functions

static bool isValidJson (json data)
 Checks if a given JSON data represents a valid wavetable creator state.
 

Protected Member Functions

void initFromSplicedAudioFile (const float *audio_buffer, int num_samples, int sample_rate, FileSource::FadeStyle fade_style)
 
void initFromVocodedAudioFile (const float *audio_buffer, int num_samples, int sample_rate, bool ttwt)
 
void initFromPitchedAudioFile (const float *audio_buffer, int num_samples, int sample_rate)
 
void initFromLineGenerator (LineGenerator *line_generator)
 

Protected Attributes

vital::WaveFrame compute_frame_combine_
 
vital::WaveFrame compute_frame_
 
std::vector< std::unique_ptr< WavetableGroup > > groups_
 
std::string last_file_loaded_
 
vital::Wavetablewavetable_
 
bool full_normalize_
 
bool remove_all_dc_
 

Detailed Description

A class responsible for creating complete wavetables from groups of wavetable components.

WavetableCreator combines multiple WavetableGroups (each containing sources and modifiers) to produce a final Wavetable object. It supports:

  • Managing multiple groups of components (sources/modifiers).
  • Rendering the entire wavetable by blending the outputs of all groups.
  • Loading wavetables from audio files and applying different load styles (splicing, vocoding, pitched analysis).
  • Initializing predefined wave shapes or line-based generators.
  • Normalizing and DC-removing the final table if desired.

The creator can serialize its state to JSON and restore it, integrating with preset/loading systems.

Member Enumeration Documentation

◆ AudioFileLoadStyle

Defines how audio files are interpreted when loading into a wavetable.

Enumerator
kNone 
kWavetableSplice 

Slice the audio into segments mapping onto wavetable frames.

kVocoded 

Apply vocoder-like analysis to extract fundamental cycles.

kTtwt 

Similar to vocoded but optimized for TTWT (text-to-wavetable).

kPitched 

Attempts to extract pitch-based cycles from the audio.

kNumDragLoadStyles 

Constructor & Destructor Documentation

◆ WavetableCreator()

WavetableCreator::WavetableCreator ( vital::Wavetable * wavetable)
inline

Constructs a WavetableCreator associated with a given Wavetable object.

By default, full normalization and DC removal are enabled.

Parameters
wavetableA pointer to the Wavetable to be created or modified.

Member Function Documentation

◆ addGroup()

void WavetableCreator::addGroup ( WavetableGroup * group)
inline

◆ clear()

void WavetableCreator::clear ( )

◆ getAuthor()

std::string WavetableCreator::getAuthor ( ) const
inline

Gets the author of the wavetable.

Returns
The author's name.

◆ getGroup()

WavetableGroup * WavetableCreator::getGroup ( int index) const
inline

Retrieves a WavetableGroup by index.

Parameters
indexThe index of the desired group.
Returns
A pointer to the WavetableGroup.

◆ getGroupIndex()

int WavetableCreator::getGroupIndex ( WavetableGroup * group)

◆ getLastFileLoaded()

std::string WavetableCreator::getLastFileLoaded ( )
inline

Gets the last loaded file path.

Returns
The last file path used for loading the wavetable.

◆ getName()

std::string WavetableCreator::getName ( ) const
inline

Gets the name of the wavetable.

Returns
The wavetable's name.

◆ getWavetable()

vital::Wavetable * WavetableCreator::getWavetable ( )
inline

Gets the internal wavetable object being created.

Returns
A pointer to the wavetable.

◆ init()

void WavetableCreator::init ( )

◆ initFromAudioFile()

void WavetableCreator::initFromAudioFile ( const float * audio_buffer,
int num_samples,
int sample_rate,
AudioFileLoadStyle load_style,
FileSource::FadeStyle fade_style )

◆ initFromLineGenerator()

void WavetableCreator::initFromLineGenerator ( LineGenerator * line_generator)
protected

◆ initFromPitchedAudioFile()

void WavetableCreator::initFromPitchedAudioFile ( const float * audio_buffer,
int num_samples,
int sample_rate )
protected

◆ initFromSplicedAudioFile()

void WavetableCreator::initFromSplicedAudioFile ( const float * audio_buffer,
int num_samples,
int sample_rate,
FileSource::FadeStyle fade_style )
protected

◆ initFromVocodedAudioFile()

void WavetableCreator::initFromVocodedAudioFile ( const float * audio_buffer,
int num_samples,
int sample_rate,
bool ttwt )
protected

◆ initPredefinedWaves()

void WavetableCreator::initPredefinedWaves ( )

◆ isValidJson()

bool WavetableCreator::isValidJson ( json data)
static

Checks if a given JSON data represents a valid wavetable creator state.

Parameters
dataThe JSON object to validate.
Returns
True if valid, false otherwise.

◆ jsonToState()

void WavetableCreator::jsonToState ( json data)

◆ loadDefaultCreator()

void WavetableCreator::loadDefaultCreator ( )

◆ moveDown()

void WavetableCreator::moveDown ( int index)

◆ moveUp()

void WavetableCreator::moveUp ( int index)

◆ numGroups()

int WavetableCreator::numGroups ( ) const
inline

Gets the total number of WavetableGroups.

Returns
The number of groups.

◆ postRender()

void WavetableCreator::postRender ( float max_span)

◆ removeGroup()

void WavetableCreator::removeGroup ( int index)

◆ render() [1/2]

void WavetableCreator::render ( )

◆ render() [2/2]

float WavetableCreator::render ( int position)

◆ renderToBuffer()

void WavetableCreator::renderToBuffer ( float * buffer,
int num_frames,
int frame_size )

◆ setAuthor()

void WavetableCreator::setAuthor ( const std::string & author)
inline

Sets the author of the wavetable.

Parameters
authorThe author name.

◆ setFileLoaded()

void WavetableCreator::setFileLoaded ( const std::string & path)
inline

Records the path of the last file loaded to create this wavetable.

Parameters
pathThe file path.

◆ setName()

void WavetableCreator::setName ( const std::string & name)
inline

Sets the name of the wavetable.

Parameters
nameThe name to assign.

◆ stateToJson()

json WavetableCreator::stateToJson ( )

◆ updateJson()

json WavetableCreator::updateJson ( json data)

Member Data Documentation

◆ compute_frame_

vital::WaveFrame WavetableCreator::compute_frame_
protected

◆ compute_frame_combine_

vital::WaveFrame WavetableCreator::compute_frame_combine_
protected

◆ full_normalize_

bool WavetableCreator::full_normalize_
protected

◆ groups_

std::vector<std::unique_ptr<WavetableGroup> > WavetableCreator::groups_
protected

◆ last_file_loaded_

std::string WavetableCreator::last_file_loaded_
protected

◆ remove_all_dc_

bool WavetableCreator::remove_all_dc_
protected

◆ wavetable_

vital::Wavetable* WavetableCreator::wavetable_
protected

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