Vital
Loading...
Searching...
No Matches
synth_filter.cpp
Go to the documentation of this file.
1#include "synth_filter.h"
2
3#include "comb_filter.h"
4#include "digital_svf.h"
5#include "diode_filter.h"
6#include "dirty_filter.h"
7#include "formant_filter.h"
8#include "ladder_filter.h"
9#include "phaser_filter.h"
10#include "sallen_key_filter.h"
11
12namespace vital {
13
14 namespace {
19 constexpr mono_float kMaxDriveGain = 36.0f;
20 constexpr mono_float kMinDriveGain = 0.0f;
21 } // namespace
22
23 // Static initialization of the CoefficientLookup
25
31 // MIDI note-based cutoff
32 midi_cutoff = processor->input(kMidiCutoff)->at(0);
34
35 // Resonance (0..1)
36 resonance_percent = processor->input(kResonance)->at(0);
37
38 // Drive gain in dB, clamped between 0 and 36
39 poly_float input_drive = utils::clamp(processor->input(kDriveGain)->at(0), kMinDriveGain, kMaxDriveGain);
40 drive_percent = (input_drive - kMinDriveGain) * (1.0f / (kMaxDriveGain - kMinDriveGain));
41 drive = futils::dbToMagnitude(input_drive);
42
43 // Additional overall gain
44 gain = processor->input(kGain)->at(0);
45
46 // Filter style enumerator (cast to int)
47 style = processor->input(kStyle)->at(0)[0];
48
49 // Pass blend in range [0..2]
50 pass_blend = utils::clamp(processor->input(kPassBlend)->at(0), 0.0f, 2.0f);
51
52 // XY interpolation parameters (for formants, morphing, etc.)
53 interpolate_x = processor->input(kInterpolateX)->at(0);
54 interpolate_y = processor->input(kInterpolateY)->at(0);
55
56 // Transpose parameter in semitones
57 transpose = processor->input(kTranspose)->at(0);
58 }
59
66 switch (model) {
68 return new SallenKeyFilter();
70 return new CombFilter(1);
72 return new DigitalSvf();
74 return new DirtyFilter();
76 return new LadderFilter();
78 return new DiodeFilter();
80 return new FormantFilter(0);
82 return new PhaserFilter(false);
83 default:
84 return nullptr;
85 }
86 }
87
88} // namespace vital
A Processor implementing a comb-based filter with multiple feedback styles.
Definition comb_filter.h:18
A state-variable filter (SVF) implementation, supporting multiple filter types (12/24 dB,...
Definition digital_svf.h:17
A diode ladder filter implementation for the Vital synthesizer.
Definition diode_filter.h:20
A nonlinear filter that produces a "dirty" and saturated sound, ideal for adding character to the sig...
Definition dirty_filter.h:30
A multi-formant filter for vocal/voicing effects in the Vital synthesizer.
Definition formant_filter.h:18
A classic transistor ladder-style filter for the Vital synthesizer.
Definition ladder_filter.h:19
A multi-stage phaser filter for the Vital synthesizer.
Definition phaser_filter.h:19
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
A Sallen-Key style filter capable of multiple modes (12dB, 24dB, dual modes) with nonlinear drive and...
Definition sallen_key_filter.h:28
poly_float transpose
Transpose in semitones (applied to midi_cutoff)
Definition synth_filter.h:120
poly_float interpolate_x
Interpolation X coordinate (e.g., for formant filters)
Definition synth_filter.h:118
poly_float interpolate_y
Interpolation Y coordinate (e.g., for formant filters)
Definition synth_filter.h:119
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 drive_percent
Normalized drive parameter in [0..1].
Definition synth_filter.h:114
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 gain
Additional gain parameter.
Definition synth_filter.h:115
poly_float midi_cutoff
MIDI note-based cutoff value.
Definition synth_filter.h:110
poly_float resonance_percent
Resonance parameter in [0..1].
Definition synth_filter.h:112
Abstract base class for Vital’s synthesizer filters.
Definition synth_filter.h:19
@ kPassBlend
Blending parameter for low-pass, high-pass, band-pass.
Definition synth_filter.h:62
@ kResonance
Resonance parameter.
Definition synth_filter.h:58
@ kTranspose
MIDI transpose in semitones.
Definition synth_filter.h:65
@ kMidiCutoff
MIDI-based cutoff parameter.
Definition synth_filter.h:57
@ kInterpolateY
For formant or XY interpolation.
Definition synth_filter.h:64
@ kInterpolateX
For formant or XY interpolation.
Definition synth_filter.h:63
@ kStyle
Filter style (12 dB, 24 dB, etc.)
Definition synth_filter.h:61
@ kDriveGain
Drive amount in dB.
Definition synth_filter.h:59
@ kGain
Additional gain.
Definition synth_filter.h:60
static const CoefficientLookup coefficient_lookup_
Static instance of the coefficient lookup table, generated at compile time.
Definition synth_filter.h:42
static SynthFilter * createFilter(constants::FilterModel model)
Factory method for creating a specialized filter based on a model enum.
Definition synth_filter.cpp:65
OneDimLookup< computeOnePoleFilterCoefficient, 2048 > CoefficientLookup
A lookup table for quick computation of one-pole filter coefficients.
Definition synth_filter.h:37
FilterModel
Identifiers for different filter models available in Vital’s filters.
Definition synth_constants.h:194
@ kDirty
Definition synth_constants.h:196
@ kDigital
Definition synth_constants.h:198
@ kAnalog
Definition synth_constants.h:195
@ kPhase
Definition synth_constants.h:202
@ kFormant
Definition synth_constants.h:200
@ kDiode
Definition synth_constants.h:199
@ kLadder
Definition synth_constants.h:197
@ kComb
Definition synth_constants.h:201
force_inline mono_float dbToMagnitude(mono_float decibels)
Converts decibels (dB) to magnitude (linear).
Definition futils.h:217
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
Contains classes and functions used within the Vital synthesizer framework.
float mono_float
Definition common.h:33
force_inline poly_float at(int i) const
Returns the sample at index i from the source buffer.
Definition processor.h:141
const Output * source
The output from which this input reads samples.
Definition processor.h:134
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