62 std::unique_ptr<float[]>
data;
228 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
FileSource)
A specific WavetableKeyframe that uses the FileSource’s audio buffer.
Definition file_source.h:74
void renderWaveBlend(vital::WaveFrame *wave_frame)
Definition file_source.cpp:119
force_inline void setFadeStyle(FadeStyle fade_style)
Definition file_source.h:122
void setInterpolateFromFrame(WaveSourceKeyframe *frame)
Definition file_source.h:138
virtual ~FileSourceKeyframe()
Definition file_source.h:82
FileSourceKeyframe(SampleBuffer *sample_buffer)
Constructs a keyframe tied to a given SampleBuffer.
Definition file_source.cpp:13
float getNormalizationScale()
Computes the normalization scale factor for the current wave segment.
Definition file_source.cpp:58
double getWindowFadeSamples()
Definition file_source.h:116
double getWindowSize()
Gets the size of the extracted window in samples.
Definition file_source.h:111
force_inline void setWindowFade(double window_fade)
Definition file_source.h:120
double window_size_
Definition file_source.h:154
double window_fade_
Definition file_source.h:153
PhaseStyle phase_style_
Definition file_source.h:156
void setInterpolateToFrame(WaveSourceKeyframe *frame)
Definition file_source.h:142
int getSamplesNeeded()
Definition file_source.h:117
void render(vital::WaveFrame *wave_frame) override
Renders the waveform of this keyframe into a WaveFrame.
Definition file_source.cpp:91
FadeStyle fade_style_
Definition file_source.h:155
const float * overridden_phase_
Definition file_source.h:148
double start_position_
Definition file_source.h:152
void renderFreqInterpolate(vital::WaveFrame *wave_frame)
Definition file_source.cpp:186
force_inline const float * getCubicInterpolationBuffer()
Definition file_source.h:130
void jsonToState(json data) override
Restores the keyframe's state from a JSON object.
Definition file_source.cpp:219
WaveSourceKeyframe * interpolate_from_frame_
Definition file_source.h:149
void renderTimeInterpolate(vital::WaveFrame *wave_frame)
Definition file_source.cpp:164
force_inline const float * getDataBuffer()
Definition file_source.h:125
WaveSourceKeyframe * interpolate_to_frame_
Definition file_source.h:150
double getWindowFade()
Gets the fade size for window blending.
Definition file_source.h:115
float getScaledInterpolatedSample(float time)
Definition file_source.cpp:44
force_inline void setPhaseStyle(PhaseStyle phase_style)
Definition file_source.h:123
void copy(const WavetableKeyframe *keyframe) override
Copies the state from another keyframe of the same type.
Definition file_source.cpp:25
double getStartPosition()
Gets the current start position of the wave segment in samples.
Definition file_source.h:107
void renderNoInterpolate(vital::WaveFrame *wave_frame)
Definition file_source.cpp:148
force_inline void setOverriddenPhaseBuffer(const float *buffer)
Definition file_source.h:124
json stateToJson() override
Serializes the state of this keyframe to a JSON object.
Definition file_source.cpp:211
force_inline void setStartPosition(double start_position)
Definition file_source.h:119
void interpolate(const WavetableKeyframe *from_keyframe, const WavetableKeyframe *to_keyframe, float t) override
Linearly interpolates between two keyframes.
Definition file_source.cpp:32
SampleBuffer * sample_buffer_
Definition file_source.h:147
force_inline void setWindowSize(double window_size)
Definition file_source.h:121
A WavetableComponent that uses an external audio sample as its source.
Definition file_source.h:23
FadeStyle fade_style_
Definition file_source.h:218
int random_seed_
Definition file_source.h:224
FileSourceKeyframe compute_frame_
Definition file_source.h:212
PhaseStyle phase_style_
Definition file_source.h:219
json stateToJson() override
Serializes the component’s state and all keyframes to a JSON object.
Definition file_source.cpp:265
void loadBuffer(const float *buffer, int size, int sample_rate)
Loads audio data into the file source buffer.
Definition file_source.cpp:363
force_inline const float * getDataBuffer()
Definition file_source.h:204
force_inline const float * getCubicInterpolationBuffer()
Definition file_source.h:209
double getWindowSize()
Definition file_source.h:181
void detectPitch(int max_period=vital::WaveFrame::kWaveformSize)
Attempts to detect pitch in the loaded sample to determine window size automatically.
Definition file_source.cpp:376
bool normalize_mult_
Definition file_source.h:221
FadeStyle
Different methods to blend or interpolate the loaded audio window into a wavetable frame.
Definition file_source.h:38
@ kFreqInterpolate
Interpolate in frequency domain between cycles.
Definition file_source.h:42
@ kTimeInterpolate
Interpolate in time domain between cycles.
Definition file_source.h:41
@ kWaveBlend
Blend windowed segments into each other.
Definition file_source.h:39
@ kNoInterpolate
Use a single segment, no blending.
Definition file_source.h:40
@ kNumFadeStyles
Definition file_source.h:43
void render(vital::WaveFrame *wave_frame, float position) override
Renders the waveform at a given position into a WaveFrame.
Definition file_source.cpp:240
void setNormalizeGain(bool normalize_gain)
Definition file_source.h:176
WaveSourceKeyframe interpolate_from_frame_
Definition file_source.h:213
bool normalize_gain_
Definition file_source.h:220
static constexpr int kExtraSaveSamples
Extra samples saved for safe interpolation and boundary conditions.
Definition file_source.h:28
PhaseStyle getPhaseStyle()
Definition file_source.h:173
bool getNormalizeGain()
Definition file_source.h:174
WaveSourceKeyframe interpolate_to_frame_
Definition file_source.h:214
WavetableComponentFactory::ComponentType getType() override
Returns the type of this WavetableComponent.
Definition file_source.cpp:260
void setFadeStyle(FadeStyle fade_style)
Definition file_source.h:178
void setPhaseStyle(PhaseStyle phase_style)
Definition file_source.cpp:337
vital::utils::RandomGenerator random_generator_
Definition file_source.h:225
SampleBuffer sample_buffer_
Definition file_source.h:216
void writePhaseOverrideBuffer()
Definition file_source.cpp:348
void detectWaveEditTable()
Detects if the source audio can form a WaveEdit-style wavetable (special format).
Definition file_source.cpp:384
const SampleBuffer * buffer() const
Definition file_source.h:171
PitchDetector pitch_detector_
Definition file_source.h:226
float overridden_phase_[vital::WaveFrame::kWaveformSize]
Definition file_source.h:217
static constexpr int kExtraBufferSamples
Additional buffer samples for safe reading beyond boundaries.
Definition file_source.h:30
static constexpr int kPitchDetectMaxPeriod
Maximum period for pitch detection to limit CPU usage.
Definition file_source.h:32
double window_size_
Definition file_source.h:222
WavetableKeyframe * createKeyframe(int position) override
Creates a new keyframe at a given position.
Definition file_source.cpp:234
void setWindowSize(double window_size)
Definition file_source.h:177
FileSourceKeyframe * getKeyframe(int index)
Definition file_source.cpp:332
virtual ~FileSource()
Definition file_source.h:162
static constexpr float kMaxFileSourceSamples
Maximum number of samples allowed from the file source (in samples).
Definition file_source.h:26
FileSource()
Definition file_source.cpp:226
void jsonToState(json data) override
Restores the component’s state from a JSON object.
Definition file_source.cpp:294
PhaseStyle
Methods for handling phase information in the transformed wave.
Definition file_source.h:50
@ kNone
Keep phases as-is.
Definition file_source.h:51
@ kNumPhaseStyles
Definition file_source.h:54
@ kVocode
Assign random phases for vocoding-like effect.
Definition file_source.h:53
@ kClear
Clear phases to a known pattern.
Definition file_source.h:52
FadeStyle getFadeStyle()
Definition file_source.h:172
A utility class for estimating the pitch (fundamental period) of a given audio signal segment.
Definition pitch_detector.h:18
A keyframe that holds a single WaveFrame and supports various interpolation methods.
Definition wave_source.h:92
ComponentType
Enumerates all known WavetableComponents, including sources and modifiers.
Definition wavetable_component_factory.h:28
A base class representing a component in a wavetable synthesis chain.
Definition wavetable_component.h:32
Represents a single state of a waveform at a specific position in a wavetable.
Definition wavetable_keyframe.h:35
Represents a single frame of a wavetable, containing both time-domain and frequency-domain data.
Definition wave_frame.h:16
static constexpr int kWaveformSize
The size of the waveform (number of samples per frame).
Definition wave_frame.h:21
A basic random number generator for producing uniform distributions of floats.
Definition utils.h:61
#define force_inline
Definition common.h:23
nlohmann::json json
Definition line_generator.h:7
A simple structure holding a buffer of samples loaded from the file source.
Definition file_source.h:60
int size
Number of samples in the buffer.
Definition file_source.h:63
int sample_rate
Sample rate of the audio data.
Definition file_source.h:64
std::unique_ptr< float[]> data
Pointer to raw audio data.
Definition file_source.h:62
SampleBuffer()
Definition file_source.h:61
Provides various utility functions, classes, and constants for audio, math, and general-purpose opera...