Tabula Sonora 0.1.0
A native C++20 implementation of the Roland Sound Canvas VA synth voice
Loading...
Searching...
No Matches
state_variable_filter.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace ts {
4
18
44public:
46 [[nodiscard]] double low() const noexcept { return low_; }
47
49 [[nodiscard]] double band() const noexcept { return band_; }
50
52 void reset() noexcept
53 {
54 low_ = 0.0;
55 band_ = 0.0;
56 }
57
61 [[nodiscard]] double process(double input, double f, double q, FilterTap tap) noexcept
62 {
63 low_ += f * band_;
64 const double high = input - ((q * band_) + low_);
65 band_ += f * high;
66
67 switch (tap) {
69 return low_;
71 return high;
73 return band_;
75 return low_ - high;
77 break;
78 }
79 return input;
80 }
81
82private:
83 double low_ = 0.0;
84 double band_ = 0.0;
85};
86
87} // namespace ts
The engine's filter: a Chamberlin state-variable filter, with all four responses taken as different t...
Definition state_variable_filter.hpp:43
double process(double input, double f, double q, FilterTap tap) noexcept
Advances the filter by one sample and returns the selected tap.
Definition state_variable_filter.hpp:61
double low() const noexcept
The lowpass integrator's current value.
Definition state_variable_filter.hpp:46
double band() const noexcept
The bandpass integrator's current value.
Definition state_variable_filter.hpp:49
void reset() noexcept
Clears the filter state.
Definition state_variable_filter.hpp:52
Definition control_decode.hpp:7
FilterTap
Which output of the state-variable filter a partial takes.
Definition state_variable_filter.hpp:6
@ band_pass
Bandpass — the band integrator.
Definition state_variable_filter.hpp:12
@ high_pass
Highpass — in - q*band - low.
Definition state_variable_filter.hpp:14
@ notch
Notch — low - high.
Definition state_variable_filter.hpp:16
@ low_pass
Lowpass — the low integrator.
Definition state_variable_filter.hpp:10
@ bypass
The partial bypasses the filter entirely.
Definition state_variable_filter.hpp:8