// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown // SPDX-License-Identifier: GPL-3.0-or-later #pragma once // Port of audio/SynthPatch.kt: every parameter of the subtractive synth voice, // parsed once from a slot. A fixed-size copyable value (no heap). Kotlin's nullable // `pad` / `wave` fields become [kind] plus the patch value. #include #include "frasil/FrasilVoice.hpp" #include "synth/SynthDefs.hpp" #include "wavetable/WaveVoice.hpp" namespace sizzle { class Params; } namespace sizzle::synth { struct SynthPatch { static constexpr int OSC_COUNT = defs::OSC_COUNT; static constexpr int MOD_SLOTS = defs::MOD_SLOTS; /** Which engine plays the note: Kotlin's pad != null / wave != null. */ enum class Kind : uint8_t { SYNTH, PAD, WAVE }; // ---- oscillators (index 0..2) ---- int oscWave[OSC_COUNT] = {}; // index into WAVES int oscOct[OSC_COUNT] = {}; // octave transpose, -2..+2 int oscSemi[OSC_COUNT] = {}; // semitone detune, -12..+12 float oscFine[OSC_COUNT] = {}; // fine detune in cents, -50..+50 float oscLevel[OSC_COUNT] = {}; // mixer level, 0..1 float noiseLevel = 0.f; // ---- filter ---- float cutoff = 0.f, resonance = 0.f, keytrack = 0.f, filterEnvAmt = 0.f; float fA = 0.f, fD = 0.f, fS = 0.f, fR = 0.f; // ---- amplifier ---- float aA = 0.f, aD = 0.f, aS = 0.f, aR = 0.f; // ---- LFO ---- int lfoWave = 0; float lfoHz = 0.f; // tempo-synced rate float lfoPhase = 0.f; // start-phase offset, 0..1 // ---- modulation matrix ---- int modSrc[MOD_SLOTS] = {}; // index into MOD_SRC (0 == Off) int modDst[MOD_SLOTS] = {}; // index into MOD_DST float modAmt[MOD_SLOTS] = {}; // -1..1 Kind kind = Kind::SYNTH; /** Valid when kind == PAD (the subtractive fields above are then unused). */ frasil::FrasilPatch pad{}; /** Valid when kind == WAVE. */ wavetable::WavePatch wave{}; /** Stands in for Kotlin's object identity (SynthVoice.setPatch's `p === patch`): * stamped by each factory below, kept by copies. */ uint32_t id = 0; /** SynthPatch.from(slot, tempoBpm); [slot] may be null (init patch). */ static SynthPatch from(const Params *slot, float tempoBpm); /** SynthPatch.DEFAULT: from(null, 120). */ static const SynthPatch &defaults(); /** A Morph Pad patch: the default synth fields, carrying [pad]. */ static SynthPatch forPad(const frasil::FrasilPatch &pad); /** A Wavetable patch: the default synth fields, carrying [wave]. */ static SynthPatch forWave(const wavetable::WavePatch &wave); }; } // namespace sizzle::synth