53 static constexpr float kMaxRatio = 0.499f;
54 return std::tan(std::min(kMaxRatio, frequency_ratio) *
vital::kPi);
155 virtual void process(
int num_samples)
override;
184 void setupFilter(
const FilterState& filter_state)
override;
206 poly_float current_post_multiply, FilterValues& blends);
220 poly_float current_post_multiply, FilterValues& blends);
234 poly_float current_post_multiply, FilterValues& blends);
248 poly_float current_post_multiply, FilterValues& blends);
266 FilterValues& blends1, FilterValues& blends2);
333 FilterValues& blends1, FilterValues& blends2);
423 FilterValues blends1_;
428 FilterValues blends2_;
483 bool drive_compensation_;
A state-variable filter (SVF) implementation, supporting multiple filter types (12/24 dB,...
Definition digital_svf.h:17
void processDual(const poly_float *audio_in, int num_samples, poly_float current_resonance, poly_float current_drive, poly_float current_post_multiply, FilterValues &blends1, FilterValues &blends2)
Processes a dual filter mode, e.g., dual notch + band pass.
Definition digital_svf.cpp:198
virtual ~DigitalSvf()
Default destructor.
Definition digital_svf.h:140
force_inline poly_float tick(poly_float audio_in, poly_float coefficient, poly_float resonance, poly_float drive, FilterValues &blends)
Applies advanced distortion to the input while performing a single SVF tick (12 dB).
Definition digital_svf.cpp:347
static constexpr mono_float kMinCutoff
Minimum allowed cutoff frequency in Hz for the filter.
Definition digital_svf.h:32
static const SvfCoefficientLookup svf_coefficient_lookup_
A static global lookup table instance for SVF coefficients.
Definition digital_svf.h:66
virtual Processor * clone() const override
Creates a clone of this filter by invoking the copy constructor.
Definition digital_svf.h:147
void processBasic24(const poly_float *audio_in, int num_samples, poly_float current_resonance, poly_float current_drive, poly_float current_post_multiply, FilterValues &blends)
Processes a simpler 24 dB filter style, skipping advanced processing.
Definition digital_svf.cpp:167
void setDriveCompensation(bool drive_compensation)
Enables or disables drive compensation (reducing drive as resonance increases).
Definition digital_svf.h:407
force_inline poly_float tickBasic24(poly_float audio_in, poly_float coefficient, poly_float resonance, poly_float drive, FilterValues &blends)
A simpler 24 dB tick function without advanced distortion or color.
Definition digital_svf.cpp:421
static constexpr mono_float kMaxGain
Maximum gain in dB for shelf or gain-based operations.
Definition digital_svf.h:37
DigitalSvf()
Constructor that initializes the filter’s internal states.
Definition digital_svf.cpp:17
static const SvfCoefficientLookup * getSvfCoefficientLookup()
Retrieves a pointer to the global SVF coefficient lookup table.
Definition digital_svf.h:73
poly_float getMidiCutoff() const
Retrieves the current MIDI-based cutoff frequency.
Definition digital_svf.h:345
poly_float getResonance() const
Retrieves the current resonance value (inverted if needed).
Definition digital_svf.h:351
virtual void process(int num_samples) override
Processes a block of samples by pulling from the primary audio input and computing the SVF output....
Definition digital_svf.cpp:29
void setupFilter(const FilterState &filter_state) override
Configures this SVF based on a FilterState (cutoff, resonance, style, etc.).
Definition digital_svf.cpp:237
poly_float getBandAmount() const
Retrieves the current band-frequency mix portion.
Definition digital_svf.h:363
poly_float getHighAmount24(int style) const
Helper for a 24 dB filter style that may swap low/high in a dual notch band.
Definition digital_svf.h:389
static constexpr mono_float kMinGain
Minimum gain in dB for shelf or gain-based operations.
Definition digital_svf.h:42
void processWithInput(const poly_float *audio_in, int num_samples) override
Processes a block of samples using a provided input buffer.
Definition digital_svf.cpp:41
poly_float getLowAmount24(int style) const
Helper for a 24 dB filter style that may swap low/high in a dual notch band.
Definition digital_svf.h:377
static force_inline mono_float computeSvfOnePoleFilterCoefficient(mono_float frequency_ratio)
Computes a one-pole SVF coefficient from a normalized frequency ratio.
Definition digital_svf.h:52
void processBasic12(const poly_float *audio_in, int num_samples, poly_float current_resonance, poly_float current_drive, poly_float current_post_multiply, FilterValues &blends)
Processes a simpler 12 dB filter style, skipping extra color or overshoot logic.
Definition digital_svf.cpp:106
OneDimLookup< computeSvfOnePoleFilterCoefficient, 2048 > SvfCoefficientLookup
A lookup table type for quickly converting frequency ratios into filter coefficients.
Definition digital_svf.h:61
poly_float getHighAmount() const
Retrieves the current high-frequency mix portion.
Definition digital_svf.h:369
void reset(poly_mask reset_masks) override
Resets internal filter states for voices specified by the reset_masks.
Definition digital_svf.cpp:487
force_inline poly_float tickBasic(poly_float audio_in, poly_float coefficient, poly_float resonance, poly_float drive, FilterValues &blends)
A basic (non-distorting) single SVF tick for a 12 dB filter style.
Definition digital_svf.cpp:362
poly_float getLowAmount() const
Retrieves the current low-frequency mix portion.
Definition digital_svf.h:357
void process24(const poly_float *audio_in, int num_samples, poly_float current_resonance, poly_float current_drive, poly_float current_post_multiply, FilterValues &blends)
Processes a 24 dB filter style, adding additional stages.
Definition digital_svf.cpp:136
void setBasic(bool basic)
Sets whether this filter should use a simpler, “basic” processing path.
Definition digital_svf.h:400
void hardReset() override
Performs a complete reset of the filter states for all voices.
Definition digital_svf.cpp:497
void setResonanceBounds(mono_float min, mono_float max)
Sets the minimum and maximum resonance for the filter (used in resonance interpolation).
Definition digital_svf.cpp:332
void process12(const poly_float *audio_in, int num_samples, poly_float current_resonance, poly_float current_drive, poly_float current_post_multiply, FilterValues &blends)
Processes a 12 dB filter style, iterating through the block.
Definition digital_svf.cpp:76
poly_float getDrive() const
Retrieves the final drive (post drive compensation) used in the filter.
Definition digital_svf.h:339
static constexpr mono_float kDefaultMinResonance
Default minimum resonance used when filtering (if not overridden).
Definition digital_svf.h:22
force_inline poly_float tick24(poly_float audio_in, poly_float coefficient, poly_float resonance, poly_float drive, FilterValues &blends)
Tick function for a 24 dB multi-stage filter, adding an additional pre-stage.
Definition digital_svf.cpp:389
static constexpr mono_float kDefaultMaxResonance
Default maximum resonance used when filtering (if not overridden).
Definition digital_svf.h:27
force_inline poly_float tickDual(poly_float audio_in, poly_float coefficient, poly_float resonance, poly_float drive, FilterValues &blends1, FilterValues &blends2)
Tick function for a dual filter approach, e.g. notch + band, etc.
Definition digital_svf.cpp:450
A one-dimensional lookup table for a given function with a specified resolution.
Definition lookup_table.h:31
Base class for all signal-processing units in Vital.
Definition processor.h:212
Abstract base class for Vital’s synthesizer filters.
Definition synth_filter.h:19
@ kDualNotchBand
Definition synth_filter.h:78
#define force_inline
Definition common.h:23
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
Contains classes and functions used within the Vital synthesizer framework.
constexpr mono_float kPi
Pi constant.
Definition common.h:36
float mono_float
Definition common.h:33
Declares the Processor class and related structures for handling audio processing in a polyphonic con...
Stores three filter state variables (v0, v1, v2) used for multi-mode mixing.
Definition digital_svf.h:79
FilterValues getDelta(const FilterValues &target, mono_float increment)
Computes the per-sample increments needed to move from this FilterValues state to target over a certa...
Definition digital_svf.h:114
poly_float v1
Typically the band or mid portion.
Definition digital_svf.h:81
poly_float v0
Additional mixing or amplitude value.
Definition digital_svf.h:80
poly_float v2
Typically the low or high portion.
Definition digital_svf.h:82
void reset(poly_mask reset_mask, const FilterValues &other)
Selectively resets values for voices specified by reset_mask, otherwise keeps the current values.
Definition digital_svf.h:100
void hardReset()
Resets all filter values to zero (for all voices).
Definition digital_svf.h:87
force_inline void increment(const FilterValues &delta)
Increments the filter values by the amounts specified in delta.
Definition digital_svf.h:127
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