11 beats_per_second_(beats_per_second),
13 delay_time_1_(nullptr),
14 delay_time_2_(nullptr),
81 return num_voice_pairs;
96 for (
int s = 0; s < num_samples; ++s) {
112 for (
int i = 0; i < num_voices; ++i) {
114 float pair_offset = i * 0.25f / num_voices;
121 float delay_t = 0.0f;
123 delay_t = i / (num_voices - 1.0f);
145 mono_float tick_increment = 1.0f / num_samples;
153 for (
int i = 0; i < num_voices; ++i) {
156 for (
int s = 0; s < num_samples; ++s) {
163 for (
int s = 0; s < num_samples; ++s) {
164 current_dry += delta_dry;
165 current_wet += delta_wet;
166 audio_out[s] = current_dry * audio_in[s] + current_wet * audio_out[s];
poly_float dry_
Current dry amount (for wet/dry mixing).
Definition chorus_module.h:100
static constexpr mono_float kMaxChorusModulation
The maximum modulation depth in seconds (for delay time modulation).
Definition chorus_module.h:21
Value * voices_
Control for the number of chorus voices.
Definition chorus_module.h:86
poly_float phase_
Current modulation phase.
Definition chorus_module.h:98
static constexpr int kMaxDelayPairs
The maximum number of delay line pairs (voices).
Definition chorus_module.h:25
const Output * beats_per_second_
A reference for tempo synchronization.
Definition chorus_module.h:85
void init() override
Initializes the chorus module, setting up controls and linking parameters.
Definition chorus_module.cpp:30
MultiDelay * delays_[kMaxDelayPairs]
The delay processors that implement the chorus voices.
Definition chorus_module.h:105
Output * wet_output_
Control for the wet/dry mix.
Definition chorus_module.h:96
void processWithInput(const poly_float *audio_in, int num_samples) override
Processes the input audio through the chorus effect.
Definition chorus_module.cpp:84
cr::Output delay_status_outputs_[kMaxDelayPairs]
Outputs for delay status or frequency debug information.
Definition chorus_module.h:90
void enable(bool enable) override
Enables or disables the chorus module.
Definition chorus_module.cpp:60
ChorusModule(const Output *beats_per_second)
Constructs a ChorusModule.
Definition chorus_module.cpp:9
int last_num_voices_
Tracks the last known number of voices to detect changes.
Definition chorus_module.h:88
static constexpr mono_float kMaxChorusDelay
The maximum chorus delay time in seconds.
Definition chorus_module.h:23
Output * frequency_
Control for modulation frequency (can be free-running or tempo-synced).
Definition chorus_module.h:92
Output * delay_time_1_
Control for the first delay time parameter.
Definition chorus_module.h:93
cr::Value delay_frequencies_[kMaxDelayPairs]
Holds frequency parameter values for each delay line.
Definition chorus_module.h:104
Output * delay_time_2_
Control for the second delay time parameter.
Definition chorus_module.h:94
poly_float wet_
Current wet amount (for wet/dry mixing).
Definition chorus_module.h:99
Output * mod_depth_
Control for modulation depth.
Definition chorus_module.h:95
int getNextNumVoicePairs()
Retrieves and updates the number of active voice pairs based on control inputs.
Definition chorus_module.cpp:73
void correctToTime(double seconds) override
Adjusts the internal phase to align with a given time, useful for syncing to host position.
Definition chorus_module.cpp:170
@ kMono
Definition delay.h:82
virtual void processWithInput(const poly_float *audio_in, int num_samples) override
Processes a block of audio from a given input buffer.
Definition delay.cpp:83
@ kFrequency
Base delay frequency.
Definition delay.h:70
@ kFeedback
Feedback amount.
Definition delay.h:72
@ kWet
Wet mix amount.
Definition delay.h:69
@ kFilterCutoff
Filter cutoff (in MIDI note).
Definition delay.h:75
@ kFilterSpread
Filter spread around cutoff.
Definition delay.h:76
@ kStyle
Delay style selection.
Definition delay.h:74
virtual Output * registerOutput(Output *output, int index)
Registers a new Output in the output list at a specified index.
Definition processor.cpp:223
force_inline int getSampleRate() const
Retrieves the current (effective) sample rate.
Definition processor.h:326
virtual void hardReset()
Called to perform a "hard" reset for all voices.
Definition processor.h:272
void plug(const Output *source)
Connects an external Output to this Processor's first input.
Definition processor.cpp:79
virtual void process(int num_samples)=0
Main processing function. Called by the ProcessorRouter.
force_inline Output * output(unsigned int index=0) const
Retrieves the Output pointer at a given index.
Definition processor.h:616
virtual void init()
Called after constructor, used for any additional initialization. Subclasses can override....
Definition processor.h:258
virtual void reset(poly_mask reset_mask)
Called to reset the Processor's per-voice state (e.g., on note-on).
Definition processor.h:267
virtual void addIdleProcessor(Processor *processor)
Adds a Processor that should remain idle (not processed) in the router.
Definition processor_router.cpp:146
virtual void process(int num_samples) override
Processes audio through all Processors managed by this router.
Definition processor_router.cpp:57
A ProcessorRouter that encapsulates a cohesive unit of functionality in the synthesizer.
Definition synth_module.h:129
Value * createBaseControl(std::string name, bool audio_rate=false, bool smooth_value=false)
Creates a simple control processor for a given parameter name.
Definition synth_module.cpp:22
Output * createTempoSyncSwitch(std::string name, Processor *frequency, const Output *beats_per_second, bool poly, Input *midi=nullptr)
Creates a tempo sync switch that toggles between tempo-based frequency and free-running frequency.
Definition synth_module.cpp:289
virtual void enable(bool enable) override
Enables or disables this SynthModule and its owned processors.
Definition synth_module.cpp:516
Output * createMonoModControl(std::string name, bool audio_rate=false, bool smooth_value=false, Output *internal_modulation=nullptr)
Creates a monophonic mod control, including applying parameter scaling.
Definition synth_module.cpp:104
virtual void set(poly_float value)
Sets the internal value to a new poly_float.
Definition value.cpp:17
force_inline mono_float value() const
Returns the current mono_float value of the first lane.
Definition value.h:60
A control-rate variant of the Value processor.
Definition value.h:82
Declares classes for time-domain memory storage and retrieval with cubic interpolation.
const poly_mask kFullMask
A mask covering all lanes of a poly_float vector.
Definition synth_constants.h:257
const poly_mask kFirstMask
A mask identifying the first voice slots in a polyphonic vector.
Definition synth_constants.h:266
const poly_mask kRightMask
A mask identifying the right channel when comparing to kRightOne.
Definition synth_constants.h:263
const cr::Value kValueOne(1.0f)
force_inline poly_float equalPowerFadeInverse(poly_float t)
The inverse equal-power fade from t to t+1.0.
Definition futils.h:448
force_inline poly_float equalPowerFade(poly_float t)
Produces an equal-power crossfade (sin-based) between 0.0 and 1.0.
Definition futils.h:436
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 void zeroBuffer(mono_float *buffer, int size)
Zeros a mono buffer (standard array).
Definition poly_utils.h:570
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 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 sin(poly_float value)
Computes the sine of each element (in radians).
Definition poly_utils.h:159
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.
Delay< Memory > MultiDelay
MultiDelay is a Delay processor specialized with Memory.
Definition delay.h:310
constexpr mono_float kPi
Pi constant.
Definition common.h:36
constexpr int kMaxSampleRate
Maximum expected sample rate in Hz.
Definition common.h:43
float mono_float
Definition common.h:33
Holds and manages a buffer of samples (poly_float) for a Processor's output.
Definition processor.h:35
poly_float * buffer
Pointer to the output buffer.
Definition processor.h:110
Processor * owner
Owning processor.
Definition processor.h:112
Represents a vector of floating-point values using SIMD instructions.
Definition poly_values.h:600