Vital
Loading...
Searching...
No Matches
WaveLineSource::WaveLineSourceKeyframe Class Reference

A keyframe class that represents a particular line-based waveform configuration at a given position. More...

#include <wave_line_source.h>

Inheritance diagram for WaveLineSource::WaveLineSourceKeyframe:
WavetableKeyframe

Public Member Functions

 WaveLineSourceKeyframe ()
 Constructs a WaveLineSourceKeyframe with default parameters.
 
virtual ~WaveLineSourceKeyframe ()=default
 
void copy (const WavetableKeyframe *keyframe) override
 Copies the state from another keyframe of the same type.
 
void interpolate (const WavetableKeyframe *from_keyframe, const WavetableKeyframe *to_keyframe, float t) override
 Linearly interpolates between two keyframes.
 
void render (vital::WaveFrame *wave_frame) override
 Renders the waveform of this keyframe into a WaveFrame.
 
json stateToJson () override
 Serializes the state of this keyframe to a JSON object.
 
void jsonToState (json data) override
 Restores the keyframe's state from a JSON object.
 
std::pair< float, float > getPoint (int index) const
 Retrieves a point (x,y) by index.
 
float getPower (int index) const
 Retrieves the power value for a given point.
 
void setPoint (std::pair< float, float > point, int index)
 Sets a point’s position.
 
void setPower (float power, int index)
 Sets the power for a given point.
 
void removePoint (int index)
 Removes a point from the line definition.
 
void addMiddlePoint (int index)
 Inserts a middle point between two existing points.
 
int getNumPoints () const
 Gets the number of points defining the line.
 
void setSmooth (bool smooth)
 Sets whether the line should be smoothed.
 
void setPullPower (float power)
 Sets the pull power, which influences how interpolation occurs between keyframes.
 
float getPullPower () const
 Gets the current pull power value.
 
const LineGeneratorgetLineGenerator () const
 Provides const access to the underlying LineGenerator.
 
LineGeneratorgetLineGenerator ()
 Provides access to the underlying LineGenerator for modification.
 
- Public Member Functions inherited from WavetableKeyframe
 WavetableKeyframe ()
 Constructs a WavetableKeyframe with a default position of 0 and no owner.
 
virtual ~WavetableKeyframe ()
 
int index ()
 Gets the index of this keyframe within its owner component.
 
int position () const
 Gets the wavetable frame position of this keyframe.
 
void setPosition (int position)
 Sets the frame position of this keyframe.
 
virtual void smoothInterpolate (const WavetableKeyframe *prev_keyframe, const WavetableKeyframe *from_keyframe, const WavetableKeyframe *to_keyframe, const WavetableKeyframe *next_keyframe, float t)
 Performs a smooth (cubic) interpolation using four keyframes for even smoother transitions.
 
WavetableComponentowner ()
 Gets the WavetableComponent that owns this keyframe.
 
void setOwner (WavetableComponent *owner)
 Sets the owner of this keyframe.
 

Protected Attributes

LineGenerator line_generator_
 The generator producing the line-based waveform.
 
float pull_power_
 Controls nonlinear interpolation between keyframes.
 
- Protected Attributes inherited from WavetableKeyframe
int position_
 The position of this keyframe along the wavetable dimension.
 
WavetableComponentowner_
 The component that owns this keyframe.
 

Additional Inherited Members

- Static Public Member Functions inherited from WavetableKeyframe
static float linearTween (float point_from, float point_to, float t)
 Performs linear interpolation between two points.
 
static float cubicTween (float point_prev, float point_from, float point_to, float point_next, float range_prev, float range, float range_next, float t)
 Performs cubic interpolation taking into account a previous and next point for smoother curves.
 

Detailed Description

A keyframe class that represents a particular line-based waveform configuration at a given position.

Each WaveLineSourceKeyframe holds a LineGenerator which stores multiple points defining the wave shape. Points can be added, removed, have their positions and power values adjusted, and the shape can be smoothed. Interpolating between two keyframes merges their line definitions in a power-scaled manner, controlled by pull_power_.

Constructor & Destructor Documentation

◆ WaveLineSourceKeyframe()

WaveLineSource::WaveLineSourceKeyframe::WaveLineSourceKeyframe ( )

Constructs a WaveLineSourceKeyframe with default parameters.

◆ ~WaveLineSourceKeyframe()

virtual WaveLineSource::WaveLineSourceKeyframe::~WaveLineSourceKeyframe ( )
virtualdefault

Member Function Documentation

◆ addMiddlePoint()

void WaveLineSource::WaveLineSourceKeyframe::addMiddlePoint ( int index)
inline

Inserts a middle point between two existing points.

Parameters
indexThe index at which to insert a new point in the middle.

◆ copy()

void WaveLineSource::WaveLineSourceKeyframe::copy ( const WavetableKeyframe * keyframe)
overridevirtual

Copies the state from another keyframe of the same type.

Parameters
keyframeThe source keyframe to copy from.

Implements WavetableKeyframe.

◆ getLineGenerator() [1/2]

LineGenerator * WaveLineSource::WaveLineSourceKeyframe::getLineGenerator ( )
inline

Provides access to the underlying LineGenerator for modification.

Returns
A pointer to the line generator.

◆ getLineGenerator() [2/2]

const LineGenerator * WaveLineSource::WaveLineSourceKeyframe::getLineGenerator ( ) const
inline

Provides const access to the underlying LineGenerator.

Returns
A const pointer to the line generator.

◆ getNumPoints()

int WaveLineSource::WaveLineSourceKeyframe::getNumPoints ( ) const
inline

Gets the number of points defining the line.

Returns
The number of points in the line generator.

◆ getPoint()

std::pair< float, float > WaveLineSource::WaveLineSourceKeyframe::getPoint ( int index) const
inline

Retrieves a point (x,y) by index.

Parameters
indexThe point index.
Returns
A pair representing the point’s (x, y) coordinates.

◆ getPower()

float WaveLineSource::WaveLineSourceKeyframe::getPower ( int index) const
inline

Retrieves the power value for a given point.

The power influences how the line transitions at that point.

Parameters
indexThe point index.
Returns
The power value for that point.

◆ getPullPower()

float WaveLineSource::WaveLineSourceKeyframe::getPullPower ( ) const
inline

Gets the current pull power value.

Returns
The pull power value.

◆ interpolate()

void WaveLineSource::WaveLineSourceKeyframe::interpolate ( const WavetableKeyframe * from_keyframe,
const WavetableKeyframe * to_keyframe,
float t )
overridevirtual

Linearly interpolates between two keyframes.

Parameters
from_keyframeThe starting keyframe.
to_keyframeThe ending keyframe.
tThe interpolation factor [0,1].

Implements WavetableKeyframe.

◆ jsonToState()

void WaveLineSource::WaveLineSourceKeyframe::jsonToState ( json data)
overridevirtual

Restores the keyframe's state from a JSON object.

Parameters
dataThe JSON object containing the keyframe's state.

Reimplemented from WavetableKeyframe.

◆ removePoint()

void WaveLineSource::WaveLineSourceKeyframe::removePoint ( int index)
inline

Removes a point from the line definition.

Parameters
indexThe index of the point to remove.

◆ render()

void WaveLineSource::WaveLineSourceKeyframe::render ( vital::WaveFrame * wave_frame)
overridevirtual

Renders the waveform of this keyframe into a WaveFrame.

Parameters
wave_frameThe WaveFrame to fill with this keyframe's waveform data.

Implements WavetableKeyframe.

◆ setPoint()

void WaveLineSource::WaveLineSourceKeyframe::setPoint ( std::pair< float, float > point,
int index )
inline

Sets a point’s position.

Parameters
pointThe new (x, y) coordinates for the point.
indexThe point index to modify.

◆ setPower()

void WaveLineSource::WaveLineSourceKeyframe::setPower ( float power,
int index )
inline

Sets the power for a given point.

Parameters
powerThe new power value.
indexThe point index.

◆ setPullPower()

void WaveLineSource::WaveLineSourceKeyframe::setPullPower ( float power)
inline

Sets the pull power, which influences how interpolation occurs between keyframes.

Parameters
powerThe new pull power value.

◆ setSmooth()

void WaveLineSource::WaveLineSourceKeyframe::setSmooth ( bool smooth)
inline

Sets whether the line should be smoothed.

If smooth is true, the line transitions are more gradual.

Parameters
smoothTrue to enable smoothing, false otherwise.

◆ stateToJson()

json WaveLineSource::WaveLineSourceKeyframe::stateToJson ( )
overridevirtual

Serializes the state of this keyframe to a JSON object.

Returns
A JSON object representing the keyframe.

Reimplemented from WavetableKeyframe.

Member Data Documentation

◆ line_generator_

LineGenerator WaveLineSource::WaveLineSourceKeyframe::line_generator_
protected

The generator producing the line-based waveform.

◆ pull_power_

float WaveLineSource::WaveLineSourceKeyframe::pull_power_
protected

Controls nonlinear interpolation between keyframes.


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