Tabula Sonora
0.1.0
A native C++20 implementation of the Roland Sound Canvas VA synth voice
Toggle main menu visibility
Loading...
Searching...
No Matches
state_variable_filter.hpp
Go to the documentation of this file.
1
#pragma once
2
3
namespace
ts
{
4
6
enum class
FilterTap
{
8
bypass
,
10
low_pass
,
12
band_pass
,
14
high_pass
,
16
notch
,
17
};
18
43
class
StateVariableFilter
{
44
public
:
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) {
68
case
FilterTap::low_pass
:
69
return
low_;
70
case
FilterTap::high_pass
:
71
return
high;
72
case
FilterTap::band_pass
:
73
return
band_;
74
case
FilterTap::notch
:
75
return
low_ - high;
76
case
FilterTap::bypass
:
77
break
;
78
}
79
return
input;
80
}
81
82
private
:
83
double
low_ = 0.0;
84
double
band_ = 0.0;
85
};
86
87
}
// namespace ts
ts::StateVariableFilter
The engine's filter: a Chamberlin state-variable filter, with all four responses taken as different t...
Definition
state_variable_filter.hpp:43
ts::StateVariableFilter::process
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
ts::StateVariableFilter::low
double low() const noexcept
The lowpass integrator's current value.
Definition
state_variable_filter.hpp:46
ts::StateVariableFilter::band
double band() const noexcept
The bandpass integrator's current value.
Definition
state_variable_filter.hpp:49
ts::StateVariableFilter::reset
void reset() noexcept
Clears the filter state.
Definition
state_variable_filter.hpp:52
ts
Definition
control_decode.hpp:7
ts::FilterTap
FilterTap
Which output of the state-variable filter a partial takes.
Definition
state_variable_filter.hpp:6
ts::FilterTap::band_pass
@ band_pass
Bandpass — the band integrator.
Definition
state_variable_filter.hpp:12
ts::FilterTap::high_pass
@ high_pass
Highpass — in - q*band - low.
Definition
state_variable_filter.hpp:14
ts::FilterTap::notch
@ notch
Notch — low - high.
Definition
state_variable_filter.hpp:16
ts::FilterTap::low_pass
@ low_pass
Lowpass — the low integrator.
Definition
state_variable_filter.hpp:10
ts::FilterTap::bypass
@ bypass
The partial bypasses the filter entirely.
Definition
state_variable_filter.hpp:8
include
tabulasonora
state_variable_filter.hpp
Generated by
1.17.0