Vital
Loading...
Searching...
No Matches
FileSource::FileSourceKeyframe Class Reference

A specific WavetableKeyframe that uses the FileSource’s audio buffer. More...

#include <file_source.h>

Inheritance diagram for FileSource::FileSourceKeyframe:
WavetableKeyframe

Public Member Functions

 FileSourceKeyframe (SampleBuffer *sample_buffer)
 Constructs a keyframe tied to a given SampleBuffer.
 
virtual ~FileSourceKeyframe ()
 
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.
 
float getNormalizationScale ()
 Computes the normalization scale factor for the current wave segment.
 
void render (vital::WaveFrame *wave_frame) override
 Renders the waveform of this keyframe into a WaveFrame.
 
void renderWaveBlend (vital::WaveFrame *wave_frame)
 
void renderNoInterpolate (vital::WaveFrame *wave_frame)
 
void renderTimeInterpolate (vital::WaveFrame *wave_frame)
 
void renderFreqInterpolate (vital::WaveFrame *wave_frame)
 
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.
 
double getStartPosition ()
 Gets the current start position of the wave segment in samples.
 
double getWindowSize ()
 Gets the size of the extracted window in samples.
 
double getWindowFade ()
 Gets the fade size for window blending.
 
double getWindowFadeSamples ()
 
int getSamplesNeeded ()
 
force_inline void setStartPosition (double start_position)
 
force_inline void setWindowFade (double window_fade)
 
force_inline void setWindowSize (double window_size)
 
force_inline void setFadeStyle (FadeStyle fade_style)
 
force_inline void setPhaseStyle (PhaseStyle phase_style)
 
force_inline void setOverriddenPhaseBuffer (const float *buffer)
 
force_inline const float * getDataBuffer ()
 
force_inline const float * getCubicInterpolationBuffer ()
 
float getScaledInterpolatedSample (float time)
 
void setInterpolateFromFrame (WaveSourceKeyframe *frame)
 
void setInterpolateToFrame (WaveSourceKeyframe *frame)
 
- 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

SampleBuffersample_buffer_
 
const float * overridden_phase_
 
WaveSourceKeyframeinterpolate_from_frame_
 
WaveSourceKeyframeinterpolate_to_frame_
 
double start_position_
 
double window_fade_
 
double window_size_
 
FadeStyle fade_style_
 
PhaseStyle phase_style_
 
- 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 specific WavetableKeyframe that uses the FileSource’s audio buffer.

FileSourceKeyframe represents one "snapshot" of the file-based wavetable. It provides methods to render the wave frame based on a chosen fade/interpolation style and phase style, and can interpolate between keyframes or compute normalization scales.

Constructor & Destructor Documentation

◆ FileSourceKeyframe()

FileSource::FileSourceKeyframe::FileSourceKeyframe ( SampleBuffer * sample_buffer)

Constructs a keyframe tied to a given SampleBuffer.

Constructs a FileSourceKeyframe tied to a sample buffer.

Parameters
sample_bufferA pointer to the buffer of audio samples associated with this file source.

Initializes default parameters for window size, fade, and phase style.

◆ ~FileSourceKeyframe()

virtual FileSource::FileSourceKeyframe::~FileSourceKeyframe ( )
inlinevirtual

Member Function Documentation

◆ copy()

void FileSource::FileSourceKeyframe::copy ( const WavetableKeyframe * keyframe)
overridevirtual

Copies the state from another keyframe of the same type.

Parameters
keyframeThe source keyframe to copy from.

Implements WavetableKeyframe.

◆ getCubicInterpolationBuffer()

force_inline const float * FileSource::FileSourceKeyframe::getCubicInterpolationBuffer ( )
inline

◆ getDataBuffer()

force_inline const float * FileSource::FileSourceKeyframe::getDataBuffer ( )
inline

◆ getNormalizationScale()

float FileSource::FileSourceKeyframe::getNormalizationScale ( )

Computes the normalization scale factor for the current wave segment.

Ensures consistent amplitude for rendering.

Returns
A scale factor for normalization.

◆ getSamplesNeeded()

int FileSource::FileSourceKeyframe::getSamplesNeeded ( )
inline

◆ getScaledInterpolatedSample()

force_inline float FileSource::FileSourceKeyframe::getScaledInterpolatedSample ( float time)

◆ getStartPosition()

double FileSource::FileSourceKeyframe::getStartPosition ( )
inline

Gets the current start position of the wave segment in samples.

◆ getWindowFade()

double FileSource::FileSourceKeyframe::getWindowFade ( )
inline

Gets the fade size for window blending.

◆ getWindowFadeSamples()

double FileSource::FileSourceKeyframe::getWindowFadeSamples ( )
inline

◆ getWindowSize()

double FileSource::FileSourceKeyframe::getWindowSize ( )
inline

Gets the size of the extracted window in samples.

◆ interpolate()

void FileSource::FileSourceKeyframe::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 FileSource::FileSourceKeyframe::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.

◆ render()

void FileSource::FileSourceKeyframe::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.

◆ renderFreqInterpolate()

void FileSource::FileSourceKeyframe::renderFreqInterpolate ( vital::WaveFrame * wave_frame)

◆ renderNoInterpolate()

void FileSource::FileSourceKeyframe::renderNoInterpolate ( vital::WaveFrame * wave_frame)

◆ renderTimeInterpolate()

void FileSource::FileSourceKeyframe::renderTimeInterpolate ( vital::WaveFrame * wave_frame)

◆ renderWaveBlend()

void FileSource::FileSourceKeyframe::renderWaveBlend ( vital::WaveFrame * wave_frame)

◆ setFadeStyle()

force_inline void FileSource::FileSourceKeyframe::setFadeStyle ( FadeStyle fade_style)
inline

◆ setInterpolateFromFrame()

void FileSource::FileSourceKeyframe::setInterpolateFromFrame ( WaveSourceKeyframe * frame)
inline

◆ setInterpolateToFrame()

void FileSource::FileSourceKeyframe::setInterpolateToFrame ( WaveSourceKeyframe * frame)
inline

◆ setOverriddenPhaseBuffer()

force_inline void FileSource::FileSourceKeyframe::setOverriddenPhaseBuffer ( const float * buffer)
inline

◆ setPhaseStyle()

force_inline void FileSource::FileSourceKeyframe::setPhaseStyle ( PhaseStyle phase_style)
inline

◆ setStartPosition()

force_inline void FileSource::FileSourceKeyframe::setStartPosition ( double start_position)
inline

◆ setWindowFade()

force_inline void FileSource::FileSourceKeyframe::setWindowFade ( double window_fade)
inline

◆ setWindowSize()

force_inline void FileSource::FileSourceKeyframe::setWindowSize ( double window_size)
inline

◆ stateToJson()

json FileSource::FileSourceKeyframe::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

◆ fade_style_

FadeStyle FileSource::FileSourceKeyframe::fade_style_
protected

◆ interpolate_from_frame_

WaveSourceKeyframe* FileSource::FileSourceKeyframe::interpolate_from_frame_
protected

◆ interpolate_to_frame_

WaveSourceKeyframe* FileSource::FileSourceKeyframe::interpolate_to_frame_
protected

◆ overridden_phase_

const float* FileSource::FileSourceKeyframe::overridden_phase_
protected

◆ phase_style_

PhaseStyle FileSource::FileSourceKeyframe::phase_style_
protected

◆ sample_buffer_

SampleBuffer* FileSource::FileSourceKeyframe::sample_buffer_
protected

◆ start_position_

double FileSource::FileSourceKeyframe::start_position_
protected

◆ window_fade_

double FileSource::FileSourceKeyframe::window_fade_
protected

◆ window_size_

double FileSource::FileSourceKeyframe::window_size_
protected

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