52 void normalize(
bool allow_positive_gain =
false);
180 void createSin(WaveFrame& wave_frame);
181 void createSaturatedSin(WaveFrame& wave_frame);
182 void createTriangle(WaveFrame& wave_frame);
183 void createSquare(WaveFrame& wave_frame);
184 void createPulse(WaveFrame& wave_frame);
185 void createSaw(WaveFrame& wave_frame);
Holds a set of predefined WaveFrame shapes that can be used as basic building blocks.
Definition wave_frame.h:143
PredefinedWaveFrames()
Constructs the PredefinedWaveFrames, initializing all predefined shapes.
Definition wave_frame.cpp:103
static const WaveFrame * getWaveFrame(Shape shape)
Retrieves a pointer to a WaveFrame representing a predefined shape.
Definition wave_frame.h:167
Shape
Supported predefined shapes.
Definition wave_frame.h:146
@ kSaturatedSin
Definition wave_frame.h:148
@ kTriangle
Definition wave_frame.h:149
@ kSquare
Definition wave_frame.h:150
@ kSaw
Definition wave_frame.h:152
@ kPulse
Definition wave_frame.h:151
@ kNumShapes
Definition wave_frame.h:153
@ kSin
Definition wave_frame.h:147
Represents a single frame of a wavetable, containing both time-domain and frequency-domain data.
Definition wave_frame.h:16
static constexpr int kWaveformBits
The number of bits that define the size of the waveform (2^kWaveformBits = kWaveformSize).
Definition wave_frame.h:19
void copy(const WaveFrame *other)
Copies another WaveFrame's time and frequency domain data into this one.
Definition wave_frame.cpp:57
static constexpr float kDefaultSampleRate
The default sample rate for a WaveFrame.
Definition wave_frame.h:29
void setSampleRate(float rate)
Sets the sample rate for this wave frame.
Definition wave_frame.h:73
float sample_rate
The sample rate associated with this frame.
Definition wave_frame.h:123
void setFrequencyRatio(float ratio)
Sets the frequency ratio for this wave frame.
Definition wave_frame.h:66
void addFrom(WaveFrame *source)
Adds another WaveFrame's data to this one, sample-by-sample, in both time and frequency domains.
Definition wave_frame.cpp:50
float frequency_ratio
The frequency ratio for this frame (e.g., for pitch scaling).
Definition wave_frame.h:122
std::complex< float > frequency_domain[kWaveformSize]
The frequency-domain representation (complex spectrum).
Definition wave_frame.h:125
void toFrequencyDomain()
Converts the currently loaded time-domain data into frequency-domain representation.
Definition wave_frame.cpp:64
static constexpr int kWaveformSize
The size of the waveform (number of samples per frame).
Definition wave_frame.h:21
static constexpr float kDefaultFrequencyRatio
The default frequency ratio for a WaveFrame (usually 1.0f).
Definition wave_frame.h:27
mono_float time_domain[2 *kWaveformSize]
The time-domain data, extended buffer size for FFT alignment.
Definition wave_frame.h:124
static constexpr int kNumExtraComplex
The number of "extra" complex bins to pad after the real frequency components.
Definition wave_frame.h:25
int index
The index of this frame in a wavetable.
Definition wave_frame.h:121
void toTimeDomain()
Converts the currently loaded frequency-domain data into time-domain representation.
Definition wave_frame.cpp:77
WaveFrame()
Constructs a WaveFrame with default frequency ratio and sample rate.
Definition wave_frame.h:36
float * getFrequencyData()
Gets a pointer to the frequency-domain data interpreted as floats.
Definition wave_frame.h:132
void removedDc()
Removes the DC offset from the waveform.
Definition wave_frame.cpp:90
static constexpr int kNumRealComplex
The number of real-valued frequency components (half the size + 1).
Definition wave_frame.h:23
mono_float getMaxZeroOffset() const
Retrieves the maximum absolute amplitude in the time-domain waveform.
Definition wave_frame.cpp:30
void multiply(mono_float value)
Multiplies all samples in both time and frequency domains by a given value.
Definition wave_frame.cpp:16
void loadTimeDomain(float *buffer)
Loads time-domain data from a given buffer and updates the frequency domain accordingly.
Definition wave_frame.cpp:23
void normalize(bool allow_positive_gain=false)
Normalizes the time-domain waveform samples to have a maximum absolute value of 1....
Definition wave_frame.cpp:38
void clear()
Clears the waveform data, resetting it to default states.
Definition wave_frame.cpp:7
Contains classes and functions used within the Vital synthesizer framework.
float mono_float
Definition common.h:33