10 constexpr float kLorenzInitial1 = 0.0f;
11 constexpr float kLorenzInitial2 = 0.0f;
12 constexpr float kLorenzInitial3 = 37.6f;
13 constexpr float kLorenzA = 10.0f;
14 constexpr float kLorenzB = 28.0f;
15 constexpr float kLorenzC = 8.0f / 3.0f;
16 constexpr float kLorenzTimeScale = 1.0f;
17 constexpr float kLorenzSize = 40.0f;
18 constexpr float kLorenzScale = 1.0f / kLorenzSize;
81 state->
offset = new_offset;
87 doReset(state, mono, frequency);
89 state->
offset += phase_delta;
95 if (new_random_mask.
anyMask()) {
124 for (
int i = 0; i < update_samples; ++i) {
161 switch (random_type) {
172 result = result * 0.5f + 0.5f;
179 poly_float delta_value = (result - current_value) * (1.0f / num_samples);
180 for (
int i = 0; i < num_samples; ++i) {
181 current_value += delta_value;
182 dest[i] = current_value;
204 for (
int i = 0; i < num_samples; ++i) {
206 dest[i] =
utils::maskLoad(last_random_value, current_random_value, over);
210 dest[0] = current_random_value;
222 static constexpr float kMaxFrequency = 0.01f;
265 for (
int i = 0; i < num_samples; ++i) {
266 poly_float delta1 = (state2 - state1) * kLorenzA;
267 poly_float delta2 = (-state3 + kLorenzB) * state1 - state2;
268 poly_float delta3 = state1 * state2 - state3 * kLorenzC;
269 state1 += delta1 * t;
270 state2 += delta2 * t;
271 state3 += delta3 * t;
273 dest[i] = state1 * kLorenzScale + 0.5f;
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
RandomLfo()
Constructs a RandomLfo processor with default parameters.
Definition random_lfo.cpp:22
std::shared_ptr< double > sync_seconds_
A shared double holding the sync reference time in seconds.
Definition random_lfo.h:169
std::shared_ptr< double > last_sync_
A shared double holding the last sync time for comparison.
Definition random_lfo.h:170
utils::RandomGenerator random_generator_
A random generator to produce random values for the LFO.
Definition random_lfo.h:166
std::shared_ptr< RandomState > shared_state_
A shared RandomState (used when syncing across instances).
Definition random_lfo.h:164
void process(int num_samples) override
Processes a block of samples.
Definition random_lfo.cpp:109
RandomType
The types of random waveforms supported by RandomLfo.
Definition random_lfo.h:72
@ kSampleAndHold
Definition random_lfo.h:74
@ kNumStyles
Definition random_lfo.h:77
@ kSinInterpolate
Definition random_lfo.h:75
@ kLorenzAttractor
Definition random_lfo.h:76
@ kPerlin
Definition random_lfo.h:73
void processSampleAndHold(RandomState *state, int num_samples)
Processes the LFO in Sample-And-Hold mode.
Definition random_lfo.cpp:191
void correctToTime(double seconds)
Adjusts the LFO to match a specific time reference (in seconds), for synchronization.
Definition random_lfo.cpp:283
poly_int updatePhase(RandomState *state, int num_samples)
Updates the LFO phase and determines if a new random value is needed.
Definition random_lfo.cpp:62
poly_float last_value_
The last output value of the LFO.
Definition random_lfo.h:167
@ kStereo
Definition random_lfo.h:60
@ kReset
Definition random_lfo.h:56
@ kStyle
Definition random_lfo.h:58
@ kFrequency
Definition random_lfo.h:54
@ kSync
Definition random_lfo.h:57
void processLorenzAttractor(RandomState *state, int num_samples)
Processes the LFO using a Lorenz attractor model.
Definition random_lfo.cpp:215
void doReset(RandomState *state, bool mono, poly_float frequency)
Resets the LFO phase and random values if a reset trigger occurs.
Definition random_lfo.cpp:29
RandomState state_
The main internal RandomState for this LFO instance.
Definition random_lfo.h:163
force_inline poly_float polyVoiceNext()
Produces a poly_float with random values assigned in pairs (every 2 lanes share the same random value...
Definition utils.h:105
force_inline poly_float polyNext()
Produces a poly_float with random values in each lane.
Definition utils.h:93
Contains faster but less accurate versions of utility math functions, such as exponential,...
const poly_mask kFirstMask
A mask identifying the first voice slots in a polyphonic vector.
Definition synth_constants.h:266
const poly_mask kLeftMask
A mask identifying the left channel when comparing to kLeftOne.
Definition synth_constants.h:260
force_inline poly_float sinInterpolate(poly_float from, poly_float to, poly_float t)
Definition futils.h:409
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_int roundToInt(poly_float value)
Rounds each lane to the nearest integer.
Definition poly_utils.h:792
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 swapVoices(poly_float value)
Swaps the first half of the lanes with the second half.
Definition poly_utils.h:437
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 perlinInterpolate(poly_float from, poly_float to, poly_float t)
A specialized interpolation function used in perlin-like routines.
Definition poly_utils.h:296
force_inline poly_float swapStereo(poly_float value)
Swaps the left and right channels of a stereo poly_float.
Definition poly_utils.h:411
Contains classes and functions used within the Vital synthesizer framework.
poly_float * buffer
Pointer to the output buffer.
Definition processor.h:110
poly_float trigger_value
Trigger values for voices.
Definition processor.h:116
Holds the internal state of the RandomLfo for a given voice or channel.
Definition random_lfo.h:24
poly_float state1
Definition random_lfo.h:39
poly_float last_random_value
The previously generated random value.
Definition random_lfo.h:35
poly_float state2
Definition random_lfo.h:39
poly_float next_random_value
The next target random value for interpolation.
Definition random_lfo.h:36
poly_float state3
Definition random_lfo.h:39
poly_float offset
Current offset (phase) in the LFO cycle.
Definition random_lfo.h:34
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 poly_mask vector_call lessThan(poly_float one, poly_float two)
Definition poly_values.h:1105
static force_inline poly_mask vector_call lessThanOrEqual(poly_float one, poly_float two)
Definition poly_values.h:1108
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 greaterThan(simd_type one, simd_type two)
Compares two SIMD integer registers, element-wise, for greater than.
Definition poly_values.h:309
Provides various utility functions, classes, and constants for audio, math, and general-purpose opera...