46 if (sync_type ==
kSync) {
73 poly_float time_passed = tick_time * num_samples;
88 phased_offset =
utils::min(current_offset + phase, 1.0f);
92 phased_offset = current_offset;
96 phased_offset =
utils::mod(current_offset + phase);
102 phased_offset =
utils::min(current_offset, 1.0f);
125 ratio = ratio & smooth_mask;
155 poly_int max_index = lfo_resolution - 1;
172 smooth_mult = smooth_mult & smooth_mask;
173 current_amplitude = 1.0f;
180 for (
int i = 0; i < num_samples; ++i) {
181 delay_time_passed += tick_time;
183 current_amplitude =
utils::clamp(current_amplitude + (fade_increase & past_delay_mask), 0.0f, 1.0f);
184 phased_offset =
utils::min(current_offset + current_phase, 1.0f);
187 dest[i] = current_amplitude * current_value;
189 current_offset =
utils::min(current_offset + (delta_offset & past_delay_mask), 1.0f);
190 current_phase += delta_phase;
197 return phased_offset;
204 poly_int max_index = lfo_resolution - 1;
221 smooth_mult = smooth_mult & smooth_mask;
222 current_amplitude = 1.0f;
232 for (
int i = 0; i < num_samples; ++i) {
233 delay_time_passed += tick_time;
235 current_amplitude =
utils::clamp(current_amplitude + (fade_increase & past_delay_mask), 0.0f, 1.0f);
241 dest[i] = current_amplitude * current_value;
243 current_offset =
utils::min(current_offset + (delta_offset & past_delay_mask), max);
244 current_phase += delta_phase;
252 return current_offset;
259 poly_int max_index = lfo_resolution - 1;
276 smooth_mult = smooth_mult & smooth_mask;
277 current_amplitude = 1.0f;
285 for (
int i = 0; i < num_samples; ++i) {
286 delay_time_passed += tick_time;
288 current_amplitude =
utils::clamp(current_amplitude + (fade_increase & past_delay_mask), 0.0f, 1.0f);
290 phased_offset =
utils::mod(current_offset + current_phase);
293 dest[i] = current_amplitude * current_value;
295 current_offset =
utils::mod(current_offset + (delta_offset & past_delay_mask));
296 current_phase += delta_phase;
304 return phased_offset;
311 poly_int max_index = lfo_resolution - 1;
328 smooth_mult = smooth_mult & smooth_mask;
329 current_amplitude = 1.0f;
335 for (
int i = 0; i < num_samples; ++i) {
336 delay_time_passed += tick_time;
338 current_amplitude =
utils::clamp(current_amplitude + (fade_increase & past_delay_mask), 0.0f, 1.0f);
340 current_offset += delta_offset & past_delay_mask;
345 dest[i] = current_amplitude * current_value;
346 current_phase += delta_phase;
353 return current_offset;
360 poly_int max_index = lfo_resolution - 1;
377 smooth_mult = smooth_mult & smooth_mask;
378 current_amplitude = 1.0f;
385 for (
int i = 0; i < num_samples; ++i) {
386 delay_time_passed += tick_time;
388 current_amplitude =
utils::clamp(current_amplitude + (fade_increase & past_delay_mask), 0.0f, 1.0f);
390 current_offset += delta_offset & past_delay_mask;
395 dest[i] = current_amplitude * current_value;
396 current_phase += delta_phase;
403 return current_offset;
422 poly_float delta_offset = frequency * tick_time;
A class for generating and storing a line shape, defined by a series of points and associated powers.
Definition line_generator.h:20
force_inline int resolution() const
Gets the resolution of the line's internal buffer.
Definition line_generator.h:266
force_inline vital::mono_float * getCubicInterpolationBuffer() const
Gets a pointer to the buffer used for cubic interpolation.
Definition line_generator.h:298
Base class for all signal-processing units in Vital.
Definition processor.h:212
force_inline Input * input(unsigned int index=0) const
Retrieves the Input pointer at a given index.
Definition processor.h:587
force_inline int getSampleRate() const
Retrieves the current (effective) sample rate.
Definition processor.h:326
force_inline bool isControlRate() const
Checks if this Processor is running at control rate (buffer_size == 1).
Definition processor.h:342
force_inline poly_mask getResetMask(int input_index) const
Retrieves a mask indicating which voices triggered a note-on event. Compares the input's trigger_valu...
Definition processor.h:360
force_inline Output * output(unsigned int index=0) const
Retrieves the Output pointer at a given index.
Definition processor.h:616
force_inline poly_mask getReleaseMask()
Determines which voices are in the release state based on note triggers.
Definition synth_lfo.h:163
void processTrigger()
Handles trigger events (note on/off), resets, and updates masks for held states.
Definition synth_lfo.cpp:19
LfoState audio_rate_state_
State used during audio-rate processing.
Definition synth_lfo.h:254
poly_float processAudioRateSustainEnvelope(int num_samples, poly_float current_phase, poly_float current_offset, poly_float delta_offset)
Processes the LFO in "Sustain Envelope" mode at audio rate.
Definition synth_lfo.cpp:200
poly_float trigger_delay_
The delay (in seconds) to apply before the LFO starts after a trigger.
Definition synth_lfo.h:258
void process(int num_samples) override
Processes a block of samples, updating the LFO output.
Definition synth_lfo.cpp:441
void correctToTime(double seconds)
Updates the LFO to align with a given time in seconds, enabling synchronization with an external cloc...
Definition synth_lfo.cpp:460
void processAudioRate(int num_samples)
Processes the LFO at audio rate (per sample).
Definition synth_lfo.cpp:406
static constexpr float kMinHalfLife
Definition synth_lfo.h:118
@ kValue
Definition synth_lfo.h:56
@ kOscPhase
Definition synth_lfo.h:57
@ kOscFrequency
Definition synth_lfo.h:58
std::shared_ptr< double > sync_seconds_
Shared pointer to an external time reference for syncing.
Definition synth_lfo.h:262
poly_int trigger_sample_
The sample index at which the note was triggered.
Definition synth_lfo.h:257
poly_float processAudioRateLoopPoint(int num_samples, poly_float current_phase, poly_float current_offset, poly_float delta_offset)
Processes the LFO in "LoopPoint" mode at audio rate.
Definition synth_lfo.cpp:307
void processControlRate(int num_samples)
Processes the LFO at control rate (e.g., once per block) instead of every sample.
Definition synth_lfo.cpp:63
poly_mask held_mask_
A mask indicating which voices are currently held (for sustain envelope modes).
Definition synth_lfo.h:256
@ kEnvelope
Definition synth_lfo.h:75
@ kSustainEnvelope
Definition synth_lfo.h:76
@ kSync
Definition synth_lfo.h:74
@ kLoopPoint
Definition synth_lfo.h:77
@ kTrigger
Definition synth_lfo.h:73
@ kLoopHold
Definition synth_lfo.h:78
LineGenerator * source_
The LineGenerator providing the waveform data for the LFO.
Definition synth_lfo.h:260
force_inline poly_float getValueAtPhase(mono_float *buffer, poly_float resolution, poly_int max_index, poly_float phase)
Retrieves the LFO value at a given phase using a cubic interpolation on the line generator data.
Definition synth_lfo.h:129
LfoState control_rate_state_
State used during control-rate processing.
Definition synth_lfo.h:253
poly_float processAudioRateEnvelope(int num_samples, poly_float current_phase, poly_float current_offset, poly_float delta_offset)
Processes the LFO in "Envelope" sync mode at audio rate.
Definition synth_lfo.cpp:151
SynthLfo(LineGenerator *source)
Constructs a SynthLfo processor with a given LineGenerator source.
Definition synth_lfo.cpp:11
bool was_control_rate_
Tracks if the previous processing block was at control rate.
Definition synth_lfo.h:252
poly_float processAudioRateLfo(int num_samples, poly_float current_phase, poly_float current_offset, poly_float delta_offset)
Processes the LFO in regular LFO mode (Trigger or Sync) at audio rate.
Definition synth_lfo.cpp:255
poly_float processAudioRateLoopHold(int num_samples, poly_float current_phase, poly_float current_offset, poly_float delta_offset)
Processes the LFO in "LoopHold" mode at audio rate.
Definition synth_lfo.cpp:356
static constexpr float kHalfLifeRatio
Definition synth_lfo.h:117
@ kPhase
Definition synth_lfo.h:35
@ kFade
Definition synth_lfo.h:40
@ kSmoothMode
Definition synth_lfo.h:39
@ kSmoothTime
Definition synth_lfo.h:41
@ kDelay
Definition synth_lfo.h:43
@ kFrequency
Definition synth_lfo.h:34
@ kSyncType
Definition synth_lfo.h:38
@ kStereoPhase
Definition synth_lfo.h:42
@ kNoteCount
Definition synth_lfo.h:44
@ kNoteTrigger
Definition synth_lfo.h:37
#define force_inline
Definition common.h:23
force_inline poly_float exp2(poly_float exponent)
Approximates 2^exponent for poly_float values using a polynomial approximation.
Definition futils.h:45
force_inline poly_float mod(poly_float value)
Returns the fractional part of each lane by subtracting the floored value.
Definition poly_utils.h:814
force_inline poly_float clamp(poly_float value, mono_float min, mono_float max)
Clamps each lane of a vector to [min, max].
Definition poly_utils.h:306
force_inline poly_float toFloat(poly_int integers)
Casts a poly_int to poly_float lane-by-lane.
Definition poly_utils.h:733
force_inline poly_float encodePhaseAndVoice(poly_float phase, poly_float voice)
Encodes a phase [0..1) and a voice index into a single float, storing the voice in the integer portio...
Definition poly_utils.h:979
force_inline poly_float min(poly_float left, poly_float right)
Returns the minimum of two poly_floats lane-by-lane.
Definition poly_utils.h:334
force_inline poly_float getCycleOffsetFromSeconds(double seconds, poly_float frequency)
Computes a cycle offset given a time in seconds and a frequency.
Definition poly_utils.h:885
force_inline poly_float max(poly_float left, poly_float right)
Returns the maximum of two poly_floats lane-by-lane.
Definition poly_utils.h:327
force_inline poly_float maskLoad(poly_float zero_value, poly_float one_value, poly_mask reset_mask)
Selects between two values (zero_value or one_value) based on a mask in each lane.
Definition poly_utils.h:351
force_inline poly_float interpolate(poly_float from, poly_float to, mono_float t)
Performs a linear interpolation between two poly_floats using a scalar t in [0..1].
Definition poly_utils.h:182
Contains classes and functions used within the Vital synthesizer framework.
float mono_float
Definition common.h:33
poly_float * buffer
Pointer to the output buffer.
Definition processor.h:110
poly_int trigger_offset
Sample offset (per voice) for triggers.
Definition processor.h:117
poly_float trigger_value
Trigger values for voices.
Definition processor.h:116
poly_float offset
The current LFO offset (phase offset).
Definition synth_lfo.h:112
poly_float delay_time_passed
How much time has passed since the LFO was triggered or started its delay.
Definition synth_lfo.h:108
poly_float smooth_value
The stored value for applying smoothing between updates.
Definition synth_lfo.h:110
poly_float fade_amplitude
The current fade-in amplitude value.
Definition synth_lfo.h:109
poly_float phase
The current LFO phase.
Definition synth_lfo.h:113
Represents a vector of floating-point values using SIMD instructions.
Definition poly_values.h:600
static force_inline mask_simd_type vector_call greaterThanOrEqual(simd_type one, simd_type two)
Compares two SIMD float registers, element-wise, for greater than or equal.
Definition poly_values.h:987
static force_inline mask_simd_type vector_call equal(simd_type one, simd_type two)
Compares two SIMD float registers for equality, element-wise.
Definition poly_values.h:954
static force_inline mask_simd_type vector_call greaterThan(simd_type one, simd_type two)
Compares two SIMD float registers, element-wise, for greater than.
Definition poly_values.h:971
Represents a vector of integer values using SIMD instructions.
Definition poly_values.h:56
static force_inline uint32_t vector_call anyMask(simd_type value)
Returns a bitmask that indicates which bytes/elements in the register are non-zero.
Definition poly_values.h:352
static force_inline simd_type vector_call equal(simd_type one, simd_type two)
Compares two SIMD integer registers for equality, element-wise.
Definition poly_values.h:291
Provides various utility functions, classes, and constants for audio, math, and general-purpose opera...