0.37.0 (71): one engine, one version for Android and iOS

- 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>
This commit is contained in:
Reactorcoremeltdown
2026-11-16 14:49:46 +01:00
co-authored by Claude Opus 5.5
parent 64e21e0bcc
commit 2bc5cb1cbb
107 changed files with 2921 additions and 1880 deletions
+159
View File
@@ -0,0 +1,159 @@
// SPDX-FileCopyrightText: 2026 Styves Goupil (FRASIL)
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown (Kotlin port for Sizzle, C++ port)
// SPDX-License-Identifier: MPL-2.0
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// https://mozilla.org/MPL/2.0/ (also in LICENSES/MPL-2.0.txt of this repository).
//
// Port of FrasilDefs.kt (engineFrom, the 36 drone presets) and FrasilPatch.from.
#include <cstring>
#include "frasil/FrasilVoice.hpp"
#include "sizzle/Params.hpp"
#include "KotlinMath.hpp"
namespace sizzle::frasil {
namespace {
using namespace defs;
const char *const INTERVALS[] = {"Unison", "-12", "+7", "+12"};
constexpr float INTERVAL_RATIO[] = {1.f, 0.5f, 1.4983071f, 2.f};
const char *const FILTER_TYPES[] = {"Low", "Band", "High"};
const char *const BREATH_PITCHES[] = {"-12", "Unison", "+12", "+19", "+24"};
constexpr float BREATH_RATIO[] = {0.5f, 1.f, 2.f, 2.9966142f, 4.f};
template <int K> int indexOf(const char *const (&list)[K], const char *s) {
for (int i = 0; i < K; ++i) if (!std::strcmp(list[i], s)) return i;
return -1;
}
float r(int v) { return (float)v / 127.f; }
/** engineFrom: [num](key, def) reads a slider, [choice](key, def) a choice. */
template <class Num, class Choice> int engineFrom(float *e, Num num, Choice choice) {
auto u = [&](const char *key, float def) { return kt::coerceIn(num(key, def), 0.f, 1.f); };
e[CHOIR] = u("choir", r(76)); e[PARTIALS] = u("partials", r(89)); e[BREATH] = u("breath", r(32));
e[WARMTH] = u("warmth", r(19)); e[DETUNE] = u("detune", r(51)); e[CUTOFF] = u("cfilter", r(44));
e[TILT] = u("tilt", r(57)); e[ODD] = u("odd", r(25)); e[STRETCH] = u("stretch", 0.f);
e[RESONANCE] = u("bres", r(70)); e[COLOR] = u("color", 0.f);
e[ATTACK] = u("attack", r(89)); e[RELEASE] = u("release", r(83));
e[MOTION] = u("motion", r(44)); e[MOTION_RATE] = u("mrate", r(51));
e[TIDE] = u("tide", r(25)); e[TIDE_RATE] = u("tperiod", r(38)); e[TIMBRE] = u("timbre", r(64));
e[SHAPE] = u("shape", 0.f); e[CH_RESO] = u("creso", 0.f);
e[EVOLVE] = u("evolve", 0.f); e[BEAT] = u("beat", 0.f);
e[FORMANT] = 3.f * u("formant", r(85)); e[PEAK] = u("peak", 0.f);
e[GRAIN] = u("grain", 0.f);
float tn = u("btone", r(64)) * 127.f;
e[TONE] = tn >= 126.5f ? 1.f : (tn - 64.f) / 63.f;
e[AIR] = u("air", 0.f); e[SOFT] = u("soft", 0.f);
e[VELOCITY] = u("velsens", r(38)); e[BODY] = u("body", 1.f);
e[INTERVAL] = INTERVAL_RATIO[kt::coerceAtLeast(indexOf(INTERVALS, choice("interval", INTERVALS[0])), 0)];
int bp = indexOf(BREATH_PITCHES, choice("bpitch", BREATH_PITCHES[1]));
e[BR_PITCH] = BREATH_RATIO[bp < 0 ? 1 : bp];
return kt::coerceAtLeast(indexOf(FILTER_TYPES, choice("ctype", FILTER_TYPES[0])), 0);
}
// CHO PAR SOU WAR DET FIL TIL ODD STR BRES COL SPR ATT REL MOT RAT TID PER TIM SPA SHP INT CRES TYP EVO BEAT
// FORM PEAK GRN PIT TONE AIR SOFT. SPREAD and SPACE (null) are FRASIL's stereo field and reverb.
constexpr int NCOL = 33;
const char *const COLS[NCOL] = {
"choir", "partials", "breath", "warmth", "detune", "cfilter", "tilt", "odd", "stretch", "bres", "color",
nullptr, "attack", "release", "motion", "mrate", "tide", "tperiod", "timbre", nullptr, "shape", "interval",
"creso", "ctype", "evolve", "beat", "formant", "peak", "grain", "bpitch", "btone", "air", "soft",
};
struct Raw { const char *name; int row[NCOL]; };
const Raw RAW[] = {
{"Mist", {76, 89, 32, 19, 51, 44, 57, 25, 0, 70, 0, 89, 89, 83, 44, 51, 25, 38, 64, 57, 0, 0, 0, 0, 0, 0, 85, 0, 0, 1, 64, 0, 0}},
{"Cathedral", {110, 50, 20, 25, 85, 55, 60, 30, 0, 60, 0, 110, 100, 100, 60, 40, 20, 50, 60, 95, 0, 1, 20, 0, 10, 0, 85, 0, 0, 1, 64, 0, 0}},
{"Glacier", {20, 100, 70, 5, 30, 60, 35, 50, 60, 115, 127, 100, 80, 110, 40, 30, 30, 40, 80, 90, 0, 0, 0, 0, 40, 15, 100, 30, 20, 2, 80, 0, 0}},
{"Abyss", {90, 70, 25, 50, 70, 20, 90, 40, 0, 50, 0, 70, 100, 105, 50, 25, 50, 25, 40, 70, 30, 1, 40, 0, 20, 0, 60, 0, 0, 0, 30, 0, 0}},
{"Aurora", {60, 105, 40, 15, 45, 65, 40, 15, 10, 85, 60, 115, 90, 105, 55, 45, 45, 50, 75, 95, 0, 0, 0, 0, 70, 25, 90, 35, 0, 2, 75, 10, 0}},
{"Ember", {100, 55, 20, 80, 40, 40, 70, 60, 0, 50, 30, 80, 70, 80, 35, 40, 20, 40, 55, 50, 64, 0, 50, 0, 10, 0, 70, 0, 0, 1, 50, 0, 0}},
{"Tide", {80, 80, 45, 25, 60, 45, 55, 30, 10, 75, 40, 100, 95, 100, 70, 30, 110, 60, 60, 70, 0, 0, 30, 0, 30, 0, 85, 0, 0, 1, 64, 0, 0}},
{"Dust", {25, 40, 85, 20, 40, 50, 60, 30, 20, 100, 60, 120, 60, 90, 50, 50, 30, 40, 60, 75, 0, 0, 0, 0, 30, 0, 85, 0, 90, 2, 85, 40, 0}},
{"Wind", {0, 20, 85, 0, 40, 50, 60, 30, 0, 20, 30, 127, 80, 95, 90, 80, 50, 70, 64, 80, 0, 0, 0, 0, 0, 0, 85, 0, 0, 1, 75, 50, 0}},
{"Organ", {40, 115, 10, 30, 10, 50, 45, 0, 0, 60, 0, 60, 40, 60, 15, 40, 10, 40, 64, 50, 0, 2, 0, 0, 0, 0, 85, 0, 0, 1, 64, 0, 0}},
{"Hollow", {105, 80, 25, 20, 35, 50, 50, 110, 0, 70, 64, 90, 80, 90, 40, 45, 25, 40, 60, 65, 64, 0, 40, 1, 15, 0, 85, 0, 0, 1, 60, 0, 0}},
{"Vowel", {65, 125, 15, 10, 30, 55, 30, 20, 0, 70, 0, 85, 90, 95, 45, 35, 60, 45, 64, 70, 0, 0, 60, 1, 20, 0, 95, 105, 0, 1, 64, 0, 0}},
{"Shimmer", {45, 100, 50, 10, 55, 75, 25, 20, 15, 100, 90, 120, 85, 110, 50, 55, 30, 40, 85, 100, 0, 3, 0, 0, 40, 50, 100, 20, 10, 3, 90, 20, 0}},
{"Chanter", {105, 45, 15, 40, 30, 55, 60, 70, 0, 60, 30, 70, 50, 70, 30, 45, 15, 40, 60, 45, 110, 0, 35, 1, 0, 0, 85, 0, 0, 1, 64, 0, 0}},
{"Ensemble", {115, 40, 20, 30, 75, 60, 55, 25, 0, 60, 0, 115, 95, 90, 55, 55, 20, 40, 65, 75, 90, 0, 15, 0, 0, 0, 85, 0, 0, 1, 64, 0, 0}},
{"Bells", {15, 115, 45, 5, 25, 50, 30, 20, 95, 110, 127, 95, 40, 110, 30, 40, 20, 40, 75, 85, 0, 0, 0, 0, 30, 30, 85, 0, 0, 2, 80, 0, 0}},
{"Nocturne", {90, 60, 30, 35, 55, 25, 85, 30, 0, 55, 0, 90, 110, 115, 45, 20, 40, 20, 45, 85, 20, 1, 70, 0, 25, 0, 70, 0, 0, 0, 35, 0, 0}},
{"Haze", {85, 50, 60, 10, 60, 70, 50, 25, 0, 40, 30, 120, 100, 105, 60, 50, 30, 50, 70, 90, 0, 3, 20, 2, 20, 0, 85, 0, 0, 2, 80, 30, 0}},
{"Pulse", {50, 95, 25, 20, 30, 50, 45, 30, 0, 70, 20, 100, 60, 80, 30, 50, 20, 40, 64, 65, 0, 0, 0, 0, 15, 100, 85, 0, 0, 1, 64, 0, 0}},
{"Rime", {30, 110, 70, 0, 20, 80, 20, 40, 30, 120, 100, 110, 70, 100, 35, 60, 20, 40, 90, 90, 0, 3, 0, 2, 30, 20, 110, 40, 40, 4, 100, 15, 0}},
{"Deep", {100, 100, 0, 40, 25, 25, 100, 20, 0, 50, 0, 60, 90, 95, 25, 30, 20, 30, 40, 45, 0, 1, 10, 0, 0, 0, 40, 0, 0, 0, 30, 0, 0}},
{"Spectral", {20, 120, 15, 5, 20, 50, 20, 10, 0, 70, 0, 90, 90, 100, 50, 40, 80, 50, 64, 80, 0, 0, 0, 0, 50, 10, 85, 127, 0, 1, 64, 0, 0}},
{"Rust", {80, 50, 40, 100, 50, 45, 65, 60, 20, 80, 40, 80, 60, 80, 40, 55, 25, 40, 55, 55, 70, 0, 80, 1, 20, 15, 75, 0, 60, 1, 45, 20, 0}},
{"Still", {0, 125, 0, 0, 0, 50, 127, 0, 0, 50, 0, 60, 100, 100, 5, 20, 0, 40, 50, 70, 0, 0, 0, 0, 0, 0, 85, 0, 0, 1, 64, 0, 0}},
{"Velvet", {95, 45, 10, 15, 35, 40, 85, 20, 0, 50, 0, 100, 105, 110, 35, 30, 20, 45, 52, 70, 0, 0, 10, 0, 0, 0, 85, 0, 0, 1, 50, 0, 120}},
{"Chrome", {35, 115, 15, 35, 15, 75, 15, 120, 45, 90, 80, 85, 60, 90, 35, 55, 15, 40, 85, 60, 64, 3, 85, 2, 20, 35, 110, 70, 0, 3, 95, 0, 0}},
{"Swarm", {120, 75, 30, 30, 120, 60, 40, 30, 0, 60, 20, 127, 70, 85, 110, 100, 40, 15, 70, 60, 120, 0, 40, 1, 40, 70, 85, 0, 30, 2, 70, 20, 0}},
{"Foghorn", {127, 60, 15, 70, 20, 22, 95, 90, 0, 40, 0, 50, 120, 120, 20, 20, 60, 70, 35, 65, 64, 1, 60, 0, 0, 0, 40, 30, 0, 0, 30, 0, 30}},
{"Solar", {70, 105, 45, 20, 55, 90, 15, 15, 5, 80, 30, 120, 100, 110, 60, 50, 70, 35, 100, 90, 10, 3, 15, 2, 60, 25, 120, 40, 0, 3, 110, 30, 0}},
{"Cave", {55, 40, 95, 30, 30, 18, 110, 30, 0, 100, 60, 70, 110, 120, 30, 20, 45, 60, 30, 100, 0, 1, 50, 0, 10, 0, 40, 0, 50, 0, 18, 5, 60}},
{"Glass Harp", {10, 120, 20, 0, 12, 60, 30, 10, 25, 100, 90, 110, 50, 120, 25, 30, 15, 55, 90, 95, 0, 3, 0, 0, 45, 40, 120, 110, 0, 4, 100, 0, 127}},
{"Monk", {110, 85, 10, 25, 30, 38, 70, 40, 0, 60, 0, 70, 100, 100, 30, 25, 30, 65, 50, 80, 0, 1, 55, 1, 15, 0, 62, 90, 0, 1, 50, 0, 90}},
{"Static", {35, 40, 127, 15, 40, 70, 40, 50, 0, 110, 90, 127, 40, 70, 80, 110, 20, 20, 80, 55, 30, 0, 30, 2, 0, 0, 85, 0, 85, 3, 100, 40, 0}},
{"Lullaby", {85, 70, 8, 10, 22, 45, 100, 10, 0, 60, 0, 80, 110, 120, 20, 15, 35, 80, 55, 85, 0, 2, 0, 0, 10, 8, 85, 20, 0, 1, 64, 0, 110}},
{"Storm", {80, 40, 110, 90, 70, 28, 90, 40, 0, 70, 40, 127, 90, 110, 100, 85, 120, 25, 40, 75, 30, 1, 70, 0, 50, 20, 60, 0, 70, 0, 35, 60, 20}},
{"Prism", {50, 120, 25, 10, 40, 65, 25, 60, 15, 90, 50, 120, 85, 105, 60, 45, 50, 40, 80, 90, 0, 3, 20, 1, 100, 30, 105, 80, 0, 2, 85, 10, 40}},
};
constexpr int NRAW = (int)(sizeof(RAW) / sizeof(RAW[0]));
int colOf(const char *key) {
for (int c = 0; c < NCOL; ++c) if (COLS[c] && !std::strcmp(COLS[c], key)) return c;
return -1;
}
/** factoryEngine(name): a preset's values as FACTORY stores them (row / 127f as text,
* which round-trips exactly, the choices by name), through engineFrom. */
bool factoryEngine(const char *name, float *e, int &type) {
for (const Raw &p : RAW) {
if (std::strcmp(p.name, name)) continue;
auto num = [&](const char *k, float d) -> float {
if (!std::strcmp(k, "velsens")) return r(38);
if (!std::strcmp(k, "body")) return 1.f;
int c = colOf(k);
return c < 0 ? d : (float)p.row[c] / 127.f;
};
auto choice = [&](const char *k, const char *d) -> const char * {
int c = colOf(k);
if (c < 0) return d;
if (!std::strcmp(k, "interval")) return INTERVALS[p.row[c] % 4];
if (!std::strcmp(k, "ctype")) return FILTER_TYPES[p.row[c] % 3];
if (!std::strcmp(k, "bpitch")) return BREATH_PITCHES[p.row[c] % 5];
return d;
};
type = engineFrom(e, num, choice);
return true;
}
return false;
}
} // namespace
int defs::factoryCount() { return NRAW; }
const char *defs::factoryName(int i) { return i >= 0 && i < NRAW ? RAW[i].name : ""; }
FrasilPatch FrasilPatch::from(const Params *slot) {
FrasilPatch p;
p.aType = engineFrom(
p.a,
[&](const char *k, float d) { return slot ? slot->f(k, d) : d; },
[&](const char *k, const char *d) { return slot ? slot->s(k, d) : d; });
const char *target = slot ? slot->s(MORPH_TO, "Off") : "Off";
int bt = 0;
p.hasB = std::strcmp(target, "Off") != 0 && factoryEngine(target, p.b, bt);
p.bType = p.hasB ? bt : p.aType;
p.morph = kt::coerceIn(slot ? slot->f(MORPH, 0.f) : 0.f, 0.f, 1.f);
p.morphTime = kt::coerceIn(slot ? slot->f(MORPH_TIME, 0.f) : 0.f, 0.f, 120.f);
return p;
}
} // namespace sizzle::frasil