- Three source trees: core/ (shared C++ engine, moved from ios/core), app/ (Android UI), ios/app/ (iOS UI) - Android plays through core/ via JNI (EngineHost, jni_engine.cpp): the Oboe callback renders natively; the Kotlin model is mirrored as project text and applied as a diff, so playback continues through edits - The Kotlin engine moves to the unit tests as ReferenceEngine (golden reference) - Shared MasterRecorder in core/src/host, used by both apps; host_test - versions.properties: one versionName/versionCode for both platforms, continuing Android's numbering (iOS 0.6.0/11 -> 0.37.0/71) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.6 KiB
C++
69 lines
2.6 KiB
C++
// 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 <cstdint>
|
|
#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
|