18 high_pass_1_.
reset(reset_mask);
19 high_pass_2_.
reset(reset_mask);
20 stage1_.
reset(reset_mask);
21 stage2_.
reset(reset_mask);
22 stage3_.
reset(reset_mask);
23 stage4_.
reset(reset_mask);
36 post_multiply_ = 0.0f;
52 poly_float current_post_multiply = post_multiply_;
53 poly_float current_high_pass_ratio = high_pass_ratio_;
54 poly_float current_high_pass_amount = high_pass_amount_;
69 current_post_multiply =
71 current_high_pass_ratio =
73 current_high_pass_amount =
74 utils::maskLoad(current_high_pass_amount, high_pass_amount_, reset_mask);
78 mono_float tick_increment = 1.0f / num_samples;
79 poly_float delta_resonance = (resonance_ - current_resonance) * tick_increment;
80 poly_float delta_drive = (drive_ - current_drive) * tick_increment;
81 poly_float delta_post_multiply = (post_multiply_ - current_post_multiply) * tick_increment;
82 poly_float delta_high_pass_ratio = (high_pass_ratio_ - current_high_pass_ratio) * tick_increment;
83 poly_float delta_high_pass_amount = (high_pass_amount_ - current_high_pass_amount) * tick_increment;
92 poly_float base_midi = midi_cutoff_buffer[num_samples - 1];
98 coefficient_lookup->
cubicLookup(high_pass_frequency_ratio);
101 for (
int i = 0; i < num_samples; ++i) {
102 poly_float midi_delta = midi_cutoff_buffer[i] - base_midi;
109 current_resonance += delta_resonance;
110 current_drive += delta_drive;
111 current_post_multiply += delta_post_multiply;
112 current_high_pass_ratio += delta_high_pass_ratio;
113 current_high_pass_amount += delta_high_pass_amount;
116 tick(audio_in[i], coefficient, current_high_pass_ratio, current_high_pass_amount,
117 high_pass_feedback_coefficient, current_resonance, current_drive);
132 static constexpr float kHighPassStart = -9.0f;
133 static constexpr float kHighPassEnd = -1.0f;
134 static constexpr float kHighPassRange = kHighPassEnd - kHighPassStart;
139 resonance_percent *= resonance_percent * resonance_percent;
144 drive_ = (resonance_ * 0.5f + 1.0f) * filter_state.
drive;
154 high_pass_amount_ = blend_amount * blend_amount;
157 high_pass_ratio_ =
futils::exp2(blend_amount * kHighPassRange + kHighPassStart);
158 high_pass_amount_ = 1.0f;
183 poly_float high_pass_coefficient = coefficient * high_pass_ratio;
184 poly_float high_pass_coefficient2 = high_pass_coefficient * 2.0f;
185 poly_float high_pass_coefficient_squared = high_pass_coefficient * high_pass_coefficient;
186 poly_float high_pass_coefficient_diff = high_pass_coefficient_squared - high_pass_coefficient;
187 poly_float high_pass_feedback_mult = high_pass_coefficient2 - high_pass_coefficient_squared - 1.0f;
190 poly_float high_pass_mult_stage2 = -high_pass_coefficient + 1.0f;
196 poly_float high_pass_input = (audio_in - high_pass_feedback) * high_pass_normalizer;
199 poly_float high_pass_1_out = high_pass_1_.
tickBasic(high_pass_input, high_pass_coefficient);
200 poly_float high_pass_2_out = high_pass_2_.
tickBasic(high_pass_1_out, high_pass_coefficient);
203 poly_float high_pass_out = high_pass_input - high_pass_1_out * 2.0f + high_pass_2_out;
219 poly_float feedback = high_pass_feedback_.
tickBasic(feedback_input, high_pass_feedback_coefficient);
222 stage1_.
tick(feedback_input - feedback, coefficient);
A diode ladder filter implementation for the Vital synthesizer.
Definition diode_filter.h:20
void hardReset() override
Performs a complete hard reset of all internal states (for all voices).
Definition diode_filter.cpp:32
force_inline void tick(poly_float audio_in, poly_float coefficient, poly_float high_pass_ratio, poly_float high_pass_amount, poly_float high_pass_feedback_coefficient, poly_float resonance, poly_float drive)
Processes a single sample of audio through the diode ladder filter stages.
Definition diode_filter.cpp:175
void reset(poly_mask reset_mask) override
Resets internal filter states (such as one-pole filters) with the given reset mask.
Definition diode_filter.cpp:17
static constexpr mono_float kMinResonance
Minimum resonance value for the diode filter.
Definition diode_filter.h:25
void setupFilter(const FilterState &filter_state) override
Sets up filter parameters from the given FilterState.
Definition diode_filter.cpp:131
DiodeFilter()
Default constructor.
Definition diode_filter.cpp:9
virtual void process(int num_samples) override
Processes audio data through the diode filter.
Definition diode_filter.cpp:46
static constexpr mono_float kHighPassFrequency
High-pass cutoff frequency in Hz (used internally).
Definition diode_filter.h:40
static constexpr mono_float kMaxResonance
Maximum resonance value for the diode filter.
Definition diode_filter.h:30
A one-dimensional lookup table for a given function with a specified resolution.
Definition lookup_table.h:31
force_inline poly_float cubicLookup(poly_float value) const
Performs a cubic interpolation lookup on the precomputed data.
Definition lookup_table.h:61
force_inline poly_float getNextState()
Gets the next filter state value (without saturation).
Definition one_pole_filter.h:120
force_inline void reset(poly_mask reset_mask)
Resets the filter state for the voices indicated by a mask.
Definition one_pole_filter.h:36
force_inline poly_float getCurrentState()
Gets the current state of the filter output.
Definition one_pole_filter.h:106
force_inline poly_float getNextSatState()
Gets the next saturated filter state value.
Definition one_pole_filter.h:113
force_inline poly_float tick(poly_float audio_in, poly_float coefficient)
Processes a single sample, applying the saturation function at each step.
Definition one_pole_filter.h:73
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
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
bool inputMatchesBufferSize(int input=0)
Checks whether the buffer size of a particular input matches the size needed by this Processor.
Definition processor.cpp:42
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
Holds the parameters necessary to configure a SynthFilter at runtime.
Definition synth_filter.h:92
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
poly_float pass_blend
Blend parameter in [0..2], controlling pass type.
Definition synth_filter.h:117
poly_float drive
Drive in linear magnitude.
Definition synth_filter.h:113
int style
Filter style enum (e.g., k12Db, k24Db)
Definition synth_filter.h:116
poly_float resonance_percent
Resonance parameter in [0..1].
Definition synth_filter.h:112
@ kReset
Reset signal.
Definition synth_filter.h:56
@ kAudio
Audio input index.
Definition synth_filter.h:55
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
@ k12Db
Definition synth_filter.h:75
#define VITAL_ASSERT(x)
Definition common.h:11
#define force_inline
Definition common.h:23
Contains faster but less accurate versions of utility math functions, such as exponential,...
const poly_mask kFullMask
A mask covering all lanes of a poly_float vector.
Definition synth_constants.h:257
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 midiOffsetToRatio(poly_float note_offset)
Converts a MIDI note offset to a frequency ratio.
Definition futils.h:184
force_inline poly_float tanh(poly_float value)
Approximates tanh function using a complex polynomial.
Definition futils.h:347
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 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
force_inline poly_float sqrt(poly_float value)
Computes the square root of each element in a poly_float.
Definition poly_utils.h:169
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
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