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
equalizer.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
tabulasonora/effect_presets.hpp
"
4
5
#include <span>
6
7
namespace
ts
{
8
19
class
Equalizer
{
20
public
:
22
static
constexpr
int
flat_gain
= 0x40;
23
30
explicit
Equalizer
(
const
EffectPresets
& presets)
noexcept
;
31
33
[[nodiscard]]
bool
available
() const noexcept {
return
presets_ !=
nullptr
; }
34
39
[[nodiscard]]
bool
is_flat
() const noexcept
40
{
41
return
low_gain_ ==
flat_gain
&& high_gain_ ==
flat_gain
;
42
}
43
48
void
set_low_frequency
(
int
value)
noexcept
;
49
void
set_low_gain
(
int
value)
noexcept
;
50
void
set_high_frequency
(
int
value)
noexcept
;
51
void
set_high_gain
(
int
value)
noexcept
;
52
54
void
reset
() noexcept;
55
57
void
clear
() noexcept;
58
60
void
process
(std::span<
float
> left, std::span<
float
> right) noexcept;
61
62
private:
64
struct State {
65
double
x1 = 0.0;
66
double
y1 = 0.0;
67
};
68
69
static
double
step(
const
EqBand
& band, State& state,
double
input)
noexcept
;
70
71
void
refresh() noexcept;
72
73
const
EffectPresets
* presets_ =
nullptr
;
74
75
int
low_frequency_ = 0;
76
int
low_gain_ =
flat_gain
;
77
int
high_frequency_ = 0;
78
int
high_gain_ =
flat_gain
;
79
80
EqBand
low_{};
81
EqBand high_{};
82
83
State low_left_;
84
State low_right_;
85
State high_left_;
86
State high_right_;
87
};
88
89
}
// namespace ts
ts::EffectPresets
The coefficient sets for the three GS send effects.
Definition
effect_presets.hpp:167
ts::Equalizer::is_flat
bool is_flat() const noexcept
Whether the current settings would change the signal.
Definition
equalizer.hpp:39
ts::Equalizer::flat_gain
static constexpr int flat_gain
The flat setting: 40 02 01 and 40 02 03 centred, both corners at their lower choice.
Definition
equalizer.hpp:22
ts::Equalizer::reset
void reset() noexcept
Returns the block state to power-on: flat, with both corners at their lower choice.
ts::Equalizer::available
bool available() const noexcept
Whether this equalizer can actually filter.
Definition
equalizer.hpp:33
ts::Equalizer::set_high_frequency
void set_high_frequency(int value) noexcept
ts::Equalizer::set_low_frequency
void set_low_frequency(int value) noexcept
Sets one of the four parameters, as 40 02 00–03 names them.
ts::Equalizer::Equalizer
Equalizer(const EffectPresets &presets) noexcept
Creates an equalizer over a preset set, which must outlive it.
ts::Equalizer::process
void process(std::span< float > left, std::span< float > right) noexcept
Filters a stereo block in place.
ts::Equalizer::set_low_gain
void set_low_gain(int value) noexcept
ts::Equalizer::clear
void clear() noexcept
Clears the filter memory without changing the settings.
ts::Equalizer::set_high_gain
void set_high_gain(int value) noexcept
effect_presets.hpp
ts
Definition
control_decode.hpp:7
ts::EqBand
One shelving band: H(z) = (b0 + b1·z⁻¹) / (1 − a1·z⁻¹).
Definition
effect_presets.hpp:127
include
tabulasonora
equalizer.hpp
Generated by
1.17.0