47 switch (destination) {
101 switch (destination) {
103 return Limits{0x7F00, 0xFFFF};
105 return Limits{0x1800, 0x8000};
109 return Limits{6000, 0x8000};
127 [[nodiscard]]
int waveform(
int phase,
int waveform_index)
const noexcept;
134 [[nodiscard]] std::pair<LfoConfig, LfoConfig>
143 [[nodiscard]] std::pair<LfoRunner, LfoRunner>
149 [[nodiscard]] std::vector<double>
157 [[nodiscard]] std::vector<double>
modulation(
int tone_number,
166 [[nodiscard]] std::vector<double>
170 std::span<const double> mod_depth_per_tick)
const;
176 [[nodiscard]]
static int
180 [[nodiscard]] std::vector<
double> run_pitch_with_wheel(
181 const
LfoConfig& config,
int tick_count, std::span<const
double> mod_depth_per_tick) const;
183 std::span<const std::uint8_t> half_sine_;
184 std::span<const std::uint16_t> rate_table_;
185 std::span<const std::uint16_t> cents_table_;
186 std::span<const std::uint16_t> delay_table_;
187 std::span<const std::uint8_t> wave_map_;
188 std::span<const std::int16_t> wave_bank_;
189 std::span<const std::uint8_t> tone_;
208 : engine_(&engine), config_(
config), phase_(
config.initial_phase & 0xFFFF)
220 [[nodiscard]]
bool is_applied() const noexcept {
return applied_; }
232 void tick(
int rate_offset = 0) noexcept;
248 [[nodiscard]]
double pitch_value(
double wheel_depth) const noexcept;
252 void advance_waveform(
bool wrapped) noexcept;
254 [[nodiscard]]
int faded(
int depth) const noexcept;
255 [[nodiscard]]
double apply(
int effective,
int rounding) const noexcept;
263 bool applied_ = false;
The engine's shared pseudo-random generator.
Definition engine_noise.hpp:18
The two LFO engines that modulate every partial.
Definition lfo_engine.hpp:76
static constexpr double waveform_scale
Scale that maps a raw waveform value to [-1, 1].
Definition lfo_engine.hpp:79
std::pair< LfoConfig, LfoConfig > configure(int tone_number, const PartialParameters &partial, const PartModifiers &modifiers={}) const
Reads both LFO configurations for one partial: the tone-common LFO1 and the per-partial LFO2.
LfoEngine(const TableSet &tables, EngineNoise *noise=nullptr)
Creates the engine over a loaded table set, which must outlive it.
EngineNoise & noise() const noexcept
The generator the random shapes draw from.
Definition lfo_engine.hpp:121
static int mod_wheel_depth(int controller, int depth=0x0A, int offset=0) noexcept
The mod wheel's contribution to LFO1 pitch depth, in milli-semitones.
int waveform(int phase, int waveform_index) const noexcept
Evaluates a waveform at a 16-bit phase.
LfoRunner create_runner(const LfoConfig &config) const
Creates a runner that steps one LFO a control tick at a time.
static constexpr bool is_random(int waveform) noexcept
Whether a waveform is one of the three random shapes, which the runner drives.
Definition lfo_engine.hpp:82
std::vector< double > run(const LfoConfig &config, int tick_count, LfoDestination destination) const
Runs one LFO for a number of control ticks.
std::vector< double > pitch_modulation_with_wheel(int tone_number, const PartialParameters &partial, int tick_count, std::span< const double > mod_depth_per_tick) const
Combined pitch modulation with a per-tick mod-wheel depth folded into LFO1.
static constexpr int slew_step
How far a slewed random shape moves toward its target in one control tick.
Definition lfo_engine.hpp:88
std::vector< double > modulation(int tone_number, const PartialParameters &partial, int tick_count, LfoDestination destination) const
The combined LFO1 and LFO2 modulation for a partial, per control tick.
std::pair< LfoRunner, LfoRunner > create_runners(int tone_number, const PartialParameters &partial, const PartModifiers &modifiers={}) const
Creates runners for both of a partial's LFOs.
static constexpr Limits destination_limits(LfoDestination destination) noexcept
Definition lfo_engine.hpp:99
One LFO's running state: phase, delay and fade-in accumulators, stepped a control tick at a time.
Definition lfo_engine.hpp:205
const LfoConfig & config() const noexcept
The configuration this runner steps.
Definition lfo_engine.hpp:213
double pitch_value(double wheel_depth) const noexcept
The pitch modulation with a mod-wheel depth folded in, in milli-semitones.
void tick(int rate_offset=0) noexcept
Advances one control tick.
double value(LfoDestination destination, int matrix_depth=0) const noexcept
The modulation for one destination, after the last tick.
LfoRunner(const LfoEngine &engine, const LfoConfig &config)
Definition lfo_engine.hpp:207
bool is_applied() const noexcept
Whether the last tick ran an update at all, so the LFO has an output to give.
Definition lfo_engine.hpp:220
A zero-copy typed view over one 0x6e-byte partial parameter block inside a tone record.
Definition partial_parameters.hpp:20
The static tables the engine needs, loaded from SCCore.dll or from a directory of extracted ....
Definition table_set.hpp:30
Definition control_decode.hpp:7
LfoDestination
Which parameter an LFO's depth applies to.
Definition lfo_engine.hpp:16
@ tvf
Filter cutoff, in the same units as the runtime cutoff.
Definition lfo_engine.hpp:20
@ pitch
Pitch, in milli-semitones.
Definition lfo_engine.hpp:18
@ tva
Amplitude, as a fraction of 0x7f00 applied multiplicatively.
Definition lfo_engine.hpp:22
One LFO's static configuration.
Definition lfo_engine.hpp:26
constexpr int depth(LfoDestination destination) const noexcept
The depth for one destination.
Definition lfo_engine.hpp:45
int fade_rate
Per-tick increment of the fade-in accumulator.
Definition lfo_engine.hpp:36
int tva_depth
Depth applied to amplitude.
Definition lfo_engine.hpp:42
int pitch_depth
Depth applied to pitch, in milli-semitones.
Definition lfo_engine.hpp:38
int initial_phase
Starting phase, from the top two bits of the waveform byte.
Definition lfo_engine.hpp:30
int tvf_depth
Depth applied to the filter cutoff.
Definition lfo_engine.hpp:40
int waveform
Waveform index, after the selector nibble is mapped.
Definition lfo_engine.hpp:28
int delay_rate
Per-tick increment of the delay accumulator; zero means never start.
Definition lfo_engine.hpp:34
int increment
Phase increment per control tick.
Definition lfo_engine.hpp:32
Depth clamp and rounding constant for a destination.
Definition lfo_engine.hpp:94
int rounding
Definition lfo_engine.hpp:96
int clamp
Definition lfo_engine.hpp:95
The GS part modify offsets, as the synthesis chains consume them.
Definition part_modifiers.hpp:21