72 virtual void process(
int num_samples)
override;
85 void setupFilter(
const FilterState& filter_state)
override;
145 template <poly_
float(*saturateResonance)(poly_
float), poly_
float(*saturateInput)(poly_
float)>
163 current_resonance =
utils::maskLoad(current_resonance, resonance_, reset_mask);
165 current_peak1 =
utils::maskLoad(current_peak1, peak1_amount_, reset_mask);
166 current_peak3 =
utils::maskLoad(current_peak3, peak3_amount_, reset_mask);
167 current_peak5 =
utils::maskLoad(current_peak5, peak5_amount_, reset_mask);
171 mono_float tick_increment = 1.0f / num_samples;
172 poly_float delta_resonance = (resonance_ - current_resonance) * tick_increment;
173 poly_float delta_drive = (drive_ - current_drive) * tick_increment;
174 poly_float delta_peak1 = (peak1_amount_ - current_peak1) * tick_increment;
175 poly_float delta_peak3 = (peak3_amount_ - current_peak3) * tick_increment;
176 poly_float delta_peak5 = (peak5_amount_ - current_peak5) * tick_increment;
181 poly_float base_midi = midi_cutoff_buffer[num_samples - 1];
185 for (
int i = 0; i < num_samples; ++i) {
186 poly_float midi_delta = midi_cutoff_buffer[i] - base_midi;
188 poly_float coefficient = coefficient_lookup->cubicLookup(frequency);
191 current_resonance += delta_resonance;
192 current_drive += delta_drive;
193 current_peak1 += delta_peak1;
194 current_peak3 += delta_peak3;
195 current_peak5 += delta_peak5;
198 tick<saturateResonance, saturateInput>(audio_in[i], coefficient,
199 current_resonance, current_drive,
200 current_peak1, current_peak3, current_peak5);
203 audio_out[i] = (audio_in[i] + invert_mult_ * allpass_output_) * 0.5f;
220 template <poly_
float(*saturateResonance)(poly_
float), poly_
float(*saturateInput)(poly_
float)>
221 force_inline void tick(poly_float audio_in, poly_float coefficient,
223 poly_float peak1, poly_float peak3, poly_float peak5) {
225 poly_float filter_state_lows = remove_lows_stage_.
tickBasic(allpass_output_,
227 poly_float filter_state_highs = remove_highs_stage_.
tickBasic(filter_state_lows,
231 poly_float filter_state = saturateResonance(
resonance * (filter_state_lows - filter_state_highs));
234 poly_float filter_input =
utils::mulAdd(drive * audio_in, invert_mult_, filter_state);
235 poly_float all_pass_input = saturateInput(filter_input);
238 poly_float stage_out;
240 stage_out = stages_[i].
tickBasic(all_pass_input, coefficient);
241 all_pass_input =
utils::mulAdd(all_pass_input, stage_out, -2.0f);
243 poly_float peak1_out = all_pass_input;
247 stage_out = stages_[i].
tickBasic(all_pass_input, coefficient);
248 all_pass_input =
utils::mulAdd(all_pass_input, stage_out, -2.0f);
250 poly_float peak3_out = all_pass_input;
254 stage_out = stages_[i].
tickBasic(all_pass_input, coefficient);
255 all_pass_input =
utils::mulAdd(all_pass_input, stage_out, -2.0f);
257 poly_float peak5_out = all_pass_input;
260 poly_float all_pass_output_1_3 =
utils::mulAdd(peak1 * peak1_out, peak3, peak3_out);
261 allpass_output_ =
utils::mulAdd(all_pass_output_1_3, peak5, peak5_out);
272 poly_float resonance_;
282 poly_float peak1_amount_;
287 poly_float peak3_amount_;
292 poly_float peak5_amount_;
297 poly_float invert_mult_;
307 OnePoleFilter<> remove_lows_stage_;
308 OnePoleFilter<> remove_highs_stage_;
313 poly_float allpass_output_;
force_inline poly_float tickBasic(poly_float audio_in, poly_float coefficient)
Processes a single sample in a basic (non-saturating) manner.
Definition one_pole_filter.h:56
A multi-stage phaser filter for the Vital synthesizer.
Definition phaser_filter.h:19
PhaserFilter(bool clean)
Constructs a PhaserFilter object.
Definition phaser_filter.cpp:11
static constexpr int kMaxStages
Maximum number of stages (3 clusters of 4 stages = 12 total).
Definition phaser_filter.h:49
static constexpr mono_float kMinCutoff
Minimum cutoff frequency in Hz (used internally).
Definition phaser_filter.h:34
static constexpr mono_float kClearRatio
A ratio used to remove/clear low frequencies or high frequencies in the phaser path.
Definition phaser_filter.h:39
static constexpr mono_float kMaxResonance
Maximum resonance value.
Definition phaser_filter.h:29
static constexpr mono_float kMinResonance
Minimum resonance value.
Definition phaser_filter.h:24
poly_float getDrive()
Gets the current drive setting.
Definition phaser_filter.h:114
static constexpr int kPeakStage
Number of all-pass stages per peak cluster. (4 stages per cluster)
Definition phaser_filter.h:44
void reset(poly_mask reset_mask) override
Resets internal filter states for the specified voices.
Definition phaser_filter.cpp:22
virtual ~PhaserFilter()
Virtual destructor.
Definition phaser_filter.h:60
poly_float getPeak1Amount()
Gets the current peak1 (lowest peak cluster) mix amount.
Definition phaser_filter.h:120
poly_float getResonance()
Gets the current resonance value.
Definition phaser_filter.h:108
poly_float getPeak3Amount()
Gets the current peak3 (second peak cluster) mix amount.
Definition phaser_filter.h:126
void hardReset() override
Performs a full reset of the filter states (for all voices).
Definition phaser_filter.cpp:34
virtual Processor * clone() const override
Creates a clone (deep copy) of the PhaserFilter.
Definition phaser_filter.h:66
virtual void process(int num_samples) override
Processes the audio buffer through the phaser effect.
Definition phaser_filter.cpp:48
void setClean(bool clean)
Toggles between a clean or distorted phaser mode.
Definition phaser_filter.h:102
void processWithInput(const poly_float *audio_in, int num_samples) override
Processes a given input buffer through the phaser effect.
Definition phaser_filter.cpp:58
poly_float getPeak5Amount()
Gets the current peak5 (highest peak cluster) mix amount.
Definition phaser_filter.h:132
void setupFilter(const FilterState &filter_state) override
Sets up the filter parameters (resonance, drive, peaks) based on the FilterState.
Definition phaser_filter.cpp:71
Base class for all signal-processing units in Vital.
Definition processor.h:212
force_inline int getSampleRate() const
Retrieves the current (effective) sample rate.
Definition processor.h:326
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
void loadSettings(Processor *processor)
Loads state from a Processor’s input signals (MIDI cutoff, drive, style, etc.).
Definition synth_filter.cpp:30
const poly_float * midi_cutoff_buffer
Pointer to the buffer storing per-sample MIDI cutoff.
Definition synth_filter.h:111
Abstract base class for Vital’s synthesizer filters.
Definition synth_filter.h:19
@ kReset
Reset signal.
Definition synth_filter.h:56
FilterState filter_state_
Internal storage of the most recent FilterState, used by derived filters.
Definition synth_filter.h:151
static const CoefficientLookup * getCoefficientLookup()
Retrieves a pointer to the static coefficient lookup table.
Definition synth_filter.h:48
OneDimLookup< computeOnePoleFilterCoefficient, 2048 > CoefficientLookup
A lookup table for quick computation of one-pole filter coefficients.
Definition synth_filter.h:37
#define force_inline
Definition common.h:23
force_inline poly_float midiOffsetToRatio(poly_float note_offset)
Converts a MIDI note offset to a frequency ratio.
Definition futils.h:184
force_inline poly_float mulAdd(poly_float a, poly_float b, poly_float c)
Performs a fused multiply-add on SIMD data: (a * b) + c.
Definition poly_utils.h:61
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 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 midiNoteToFrequency(poly_float value)
Converts a MIDI note to a frequency (vectorized).
Definition poly_utils.h:123
Contains classes and functions used within the Vital synthesizer framework.
float mono_float
Definition common.h:33
Declares the Processor class and related structures for handling audio processing in a polyphonic con...
poly_float * buffer
Pointer to the output buffer.
Definition processor.h:110
Represents a vector of floating-point values using SIMD instructions.
Definition poly_values.h:600
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