Tabula Sonora 0.1.0
A native C++20 implementation of the Roland Sound Canvas VA synth voice
Loading...
Searching...
No Matches
equalizer.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <span>
6
7namespace ts {
8
19class Equalizer {
20public:
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
62private:
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
The coefficient sets for the three GS send effects.
Definition effect_presets.hpp:167
bool is_flat() const noexcept
Whether the current settings would change the signal.
Definition equalizer.hpp:39
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
void reset() noexcept
Returns the block state to power-on: flat, with both corners at their lower choice.
bool available() const noexcept
Whether this equalizer can actually filter.
Definition equalizer.hpp:33
void set_high_frequency(int value) noexcept
void set_low_frequency(int value) noexcept
Sets one of the four parameters, as 40 02 00–03 names them.
Equalizer(const EffectPresets &presets) noexcept
Creates an equalizer over a preset set, which must outlive it.
void process(std::span< float > left, std::span< float > right) noexcept
Filters a stereo block in place.
void set_low_gain(int value) noexcept
void clear() noexcept
Clears the filter memory without changing the settings.
void set_high_gain(int value) noexcept
Definition control_decode.hpp:7
One shelving band: H(z) = (b0 + b1·z⁻¹) / (1 − a1·z⁻¹).
Definition effect_presets.hpp:127