mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 21:04:32 +01:00
Juan: "si, todo". - grich from JIANT BYTE 5aebdf56 (Juan's GPL code), on FM's engines. Each section, and A, gets its own automation, locks and step components: - the kit's TONE rises over the build; - DECAY rises toward the turn (only up, so the kit keeps its punch); - a snare roll is muted into the turn; - the hats' offbeats get an 80 % chance; - the delay is thrown on the lead's last note; - the arp's filter ramps over the build; - a stab chord lands in a melodic part; - the break's pads get a slower attack and a longer release. - FM's call and response is back: the arp is silent where the lead speaks. - EXPLORE's cut is back: the cycle's last beat or two are cleared. - Both sit beside BYTE's gen_post. - GTRIM: HOUSE is 0.5 dB lower and METALCORE 1 dB lower, so every piece stays under -1 dBFS (gen_peak). Flash: the long enum lists are packed with str_nth. desc_nm reads them; PNB holds params.c's lists and PNE the engines' (CLAY SHAPE and EUCLID, WEST RATIO, ANIMAL GROUP, WHEEL BARS, ADD MODE). The names, stored ids and NRPN/editor ids are unchanged. tests/descdump's output is byte-identical to V10.8.69's. Image: 228 B free (V10.8.69: 128). BT: 24 B free. RAM code: 40192 B, unchanged. ui_graph: SOUND 3 is now matched by its whole title. The old check read past a short page title (found by ASan). CPU (tests/cpu_lines_test.py), each scene's worst block on core 0 and core 1, V10.8.69 -> V10.8.70: 101 80/44 -> 78/44 102 61/29 -> 61/28 103 79/14 -> 80/14 104 46/14 -> 46/14 105 65/41 -> 65/41 106 53/36 -> 52/35 107 58/11 -> 58/11 108 51/29 -> 51/29 0c 70/58 -> 70/58 Scene 101's worst block is a dense step (seq_step, note-ons). The drums' rendering is not the cost there. Tests: - gen_entry: MID recorded again. - Tests read the packed lists through PN_AT / desc_nm. - Layout recorded again (FELUCCA_REPIN=keep); the plain build passes. - Local workflow: all 19 steps pass. audio.c is V23's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
252 lines
9.7 KiB
C
252 lines
9.7 KiB
C
/* SPDX-License-Identifier: GPL-3.0-only
|
|
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
|
|
* Portions Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
|
|
/* The firmware's parameter and engine tables as JSON, from the same sources (through hostsim.c):
|
|
* TP, GP, every engine's page titles, EDIT descriptors and presets, their display order, the factory patterns, the
|
|
* power-on sounds and the protocol constants. web/test_web.mjs compares the editor's mock device
|
|
* (web/editor.html makeMockDevice) with it, so the mock cannot drift from the firmware.
|
|
* build/host/descdump > build/host/desc.json (run_tests.sh) */
|
|
#define main hostsim_main
|
|
#include "hostsim.c"
|
|
#undef main
|
|
|
|
static void js_str(const char *s)
|
|
{
|
|
putchar('"');
|
|
for (; s && *s; s++) {
|
|
if (*s == '"' || *s == '\\')
|
|
putchar('\\');
|
|
putchar(*s);
|
|
}
|
|
putchar('"');
|
|
}
|
|
|
|
static void js_ints(const int32_t *v, uint32_t n)
|
|
{
|
|
uint32_t i;
|
|
putchar('[');
|
|
for (i = 0; i < n; i++)
|
|
printf("%s%d", i ? "," : "", v[i]);
|
|
putchar(']');
|
|
}
|
|
|
|
/* as the protocol's DESC reply has it: the value names only for F_ENUM */
|
|
static void js_desc(const param_desc_t *d)
|
|
{
|
|
int32_t i;
|
|
printf("{\"label\":");
|
|
js_str(d->label);
|
|
printf(",\"fmt\":%d,\"min\":%d,\"max\":%d,\"def\":%d,\"names\":", (int)desc_fmt(d), d->min, d->max, d->def);
|
|
if (d->fmt == F_ENUM && d->names) {
|
|
putchar('[');
|
|
for (i = 0; i <= d->max - d->min; i++) {
|
|
if (i)
|
|
putchar(',');
|
|
js_str(desc_nm(d, d->min + i)); /* (as editor.c ED_DESC and param_format: names[] by the value itself;
|
|
* names[i] read MATH's WAVE 5..6 as "-", "-") */
|
|
}
|
|
putchar(']');
|
|
} else {
|
|
printf("null");
|
|
}
|
|
printf(",\"unit\":");
|
|
js_str(desc_unit(d) ? desc_unit(d) : "");
|
|
putchar('}');
|
|
}
|
|
|
|
static void js_descs(const param_desc_t *d, uint32_t n)
|
|
{
|
|
uint32_t i;
|
|
putchar('[');
|
|
for (i = 0; i < n; i++) {
|
|
if (i)
|
|
printf(",\n ");
|
|
js_desc(&d[i]);
|
|
}
|
|
putchar(']');
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
uint32_t e, i, k;
|
|
int32_t v[16];
|
|
printf("{\"P_COUNT\":%d,\"G_COUNT\":%d,\"NSTEP\":%d,\"P_E0\":%d,\"G_ENGSEL\":%d,\"P_SLCR\":%d,\"NTRK\":%d,\n",
|
|
P_COUNT, G_COUNT, NSTEP, P_E0, G_ENGSEL, P_SLCR, NTRK);
|
|
printf("\"TP\":");
|
|
js_descs(TP, P_E0); /* P_E0.. are the engine's */
|
|
printf(",\n\"GP\":");
|
|
js_descs(GP, G_COUNT);
|
|
printf(",\n\"ENG\":[");
|
|
for (e = 0; e < NENGINES; e++) {
|
|
const engine_t *en = ENGINES[e];
|
|
printf("%s\n {\"name\":", e ? "," : "");
|
|
js_str(en->name);
|
|
printf(",\"titles\":[");
|
|
js_str(en->page_title[0]);
|
|
putchar(',');
|
|
js_str(en->page_title[1]);
|
|
printf("],\"edit\":");
|
|
js_descs(en->edit, 8);
|
|
printf(",\"presets\":[");
|
|
for (k = 0; k < en->npresets; k++) {
|
|
const preset_t *p = &en->presets[k];
|
|
printf("%s\n {\"name\":", k ? "," : "");
|
|
js_str(p->name);
|
|
for (i = 0; i < 8u; i++)
|
|
v[i] = p->e[i];
|
|
printf(",\"e\":");
|
|
js_ints(v, 8);
|
|
for (i = 0; i < 4u; i++)
|
|
v[i] = p->env[i];
|
|
printf(",\"env\":");
|
|
js_ints(v, 4);
|
|
printf(",\"xp\":%u", (unsigned)p->xp); /* (0.8.5) VOICE: LANG | LYRIC << 2 */
|
|
printf(",\"mono\":%d,\"pat\":%d}", p->mono & 1, p->pat);
|
|
}
|
|
printf("]}");
|
|
}
|
|
printf("],\n\"ORDER\":["); /* the engines as shown (engines.c ENGINE_ORDER), by name */
|
|
for (k = 0; k < NENG_SHOWN; k++) {
|
|
if (k)
|
|
putchar(',');
|
|
js_str(ENGINES[eng_vis(k)]->name);
|
|
}
|
|
printf("],\n\"PATTERNS\":[");
|
|
for (k = 0; k < NPATTERNS; k++) {
|
|
printf("%s\n [", k ? "," : "");
|
|
for (i = 0; i < 16u; i++)
|
|
v[i] = PATTERNS[k].note[i];
|
|
js_ints(v, 16);
|
|
putchar(',');
|
|
for (i = 0; i < 16u; i++)
|
|
v[i] = PATTERNS[k].flags[i];
|
|
js_ints(v, 16);
|
|
putchar(']');
|
|
}
|
|
printf("],\n\"TRK_DEF\":[");
|
|
for (k = 0; k < NPART; k++)
|
|
printf("%s[%d,%d,%d]", k ? "," : "", TRK_DEF[k][0], TRK_DEF[k][1], TRK_DEF[k][2]);
|
|
printf("],\n\"FM6\":{\"bank\":0,\"own\":%u,\"init\":", (unsigned)FM6_OWN); /* FM6: the packed patches (no bank since 1.0.3) */
|
|
for (i = 0; i < FM6_PACKED; i++)
|
|
printf("%s%d", i ? "," : "[", FM6_INIT[i]);
|
|
printf("],\"factory\":[");
|
|
for (k = 0; k < FM6_NFACTORY; k++)
|
|
for (i = 0; i < FM6_PACKED; i++)
|
|
printf("%s%d%s", i ? "," : k ? ",[" : "[", FM6_FACTORY[k][i], i == FM6_PACKED - 1u ? "]" : "");
|
|
printf("]}");
|
|
printf(",\n\"LANE_NOTE\":["); /* the DRUM grid: each lane's GM note, the lane of GM 35..81 */
|
|
for (k = 0; k < NLANE; k++)
|
|
printf("%s%d", k ? "," : "", DRUM_LANE_NOTE[k]);
|
|
printf("],\n\"FM4\":{\"presets\":["); /* DIGITAL (retired): its presets and conversions (fm4_convert.c) */
|
|
for (k = 0; k < FM4_NPRESETS; k++) {
|
|
const preset_t *p = &DIGITAL_PRESETS[k];
|
|
printf("%s\n {\"name\":", k ? "," : "");
|
|
js_str(p->name);
|
|
for (i = 0; i < 8u; i++)
|
|
v[i] = p->e[i];
|
|
printf(",\"e\":");
|
|
js_ints(v, 8);
|
|
for (i = 0; i < 4u; i++)
|
|
v[i] = p->env[i];
|
|
printf(",\"env\":");
|
|
js_ints(v, 4);
|
|
for (i = 0; i < 4u; i++)
|
|
v[i] = p->fx[i];
|
|
printf(",\"fenv\":%d,\"mono\":%d,\"fx\":", p->fenv, p->mono & 1);
|
|
js_ints(v, 4);
|
|
printf(",\"pat\":%d}", p->pat);
|
|
}
|
|
printf("],\"to_fm6\":");
|
|
for (k = 0; k < FM4_NPRESETS; k++)
|
|
v[k] = FM4_TO_FM6[k];
|
|
js_ints(v, FM4_NPRESETS);
|
|
printf(",\"cases\":[");
|
|
{ /* the presets, every algorithm with and without feedback, then pseudo-random values (OP ENV ones too) */
|
|
uint32_t c, seed = 12345u;
|
|
for (c = 0; c < 48u; c++) {
|
|
int16_t p[P_COUNT];
|
|
int32_t w[FP_SIZE + P_COUNT];
|
|
uint8_t fv[FP_SIZE + 1u];
|
|
uint32_t pr;
|
|
for (i = 0; i < P_COUNT; i++)
|
|
p[i] = param_desc_of(ENGI_DIGITAL, i)->def;
|
|
if (c < FM4_NPRESETS) {
|
|
fm4_preset_values(p, c);
|
|
} else if (c < 24u) {
|
|
p[P_E0] = (int16_t)((c - 8u) & 7u);
|
|
p[P_E1] = 1; p[P_E2] = 3; p[P_E3] = (int16_t)(c & 1 ? 5 : 1);
|
|
p[P_E4] = 64; p[P_E5] = 70; p[P_E6] = (int16_t)(c < 16u ? 12 : 30);
|
|
} else {
|
|
for (i = 0; i < P_COUNT; i++) {
|
|
const param_desc_t *d = param_desc_of(ENGI_DIGITAL, i);
|
|
if (i == P_ATK || i == P_DEC || i == P_SUS || i == P_REL || i == P_ED_FLT ||
|
|
(i >= P_FM1_ATK && i <= P_FM4_LEVEL && (c & 1u)) || (i >= P_E0 && i < P_E7)) {
|
|
seed = seed * 1103515245u + 12345u;
|
|
p[i] = (int16_t)(d->min + (int32_t)((seed >> 8) % (uint32_t)(d->max - d->min + 1)));
|
|
}
|
|
}
|
|
}
|
|
for (i = 0; i < P_COUNT; i++)
|
|
w[i] = p[i];
|
|
printf("%s\n {\"p\":", c ? "," : "");
|
|
js_ints(w, P_COUNT);
|
|
pr = fm4_convert(p, fv);
|
|
for (i = 0; i < P_COUNT; i++)
|
|
w[i] = p[i];
|
|
printf(",\"preset\":%u,\"out\":", pr);
|
|
js_ints(w, P_COUNT);
|
|
for (i = 0; i < FP_SIZE; i++)
|
|
w[i] = fv[i];
|
|
printf(",\"voice\":");
|
|
js_ints(w, FP_SIZE);
|
|
putchar('}');
|
|
}
|
|
}
|
|
printf("]}");
|
|
printf(",\n\"LANE_OF\":\"");
|
|
for (k = 35; k <= 81; k++)
|
|
printf("%u", (unsigned)drum_lane(k));
|
|
printf("\",\n\"PCT\":["); /* F_PCT as the firmware shows it (#31: SWG 0..100) */
|
|
for (k = 0, e = 0; k < (uint32_t)P_E0 + G_COUNT; k++) {
|
|
const param_desc_t *d = k < (uint32_t)P_E0 ? &TP[k] : &GP[k - P_E0];
|
|
int32_t x[3] = {d->min, (d->min + d->max) / 2, d->max};
|
|
if (d->fmt != F_PCT)
|
|
continue;
|
|
for (i = 0; i < 3u; i++) {
|
|
char val[12];
|
|
const char *unit;
|
|
param_format(d, x[i], val, &unit);
|
|
printf("%s[%d,%d,%d,%d,", e++ ? "," : "", k < (uint32_t)P_E0 ? 0 : 1, k < (uint32_t)P_E0 ? (int)k : (int)(k - P_E0),
|
|
x[i], d->max);
|
|
js_str(val);
|
|
putchar(']');
|
|
}
|
|
}
|
|
printf("],\n\"SHOWN\":["); /* #48: the values as a knob steps them (params.c param_turn), */
|
|
{ /* every F_ENUM: [scope, index, the names from the left end] */
|
|
for (k = 0, e = 0; k < (uint32_t)P_E0 + G_COUNT; k++) {
|
|
const param_desc_t *d = k < (uint32_t)P_E0 ? &TP[k] : &GP[k - P_E0];
|
|
int32_t v = d->def, n;
|
|
if (d->fmt != F_ENUM || !d->names || d->max <= d->min)
|
|
continue;
|
|
/* (G_DTIME's names grew past 64 (the ms times): a cap of 64 left a trailing comma, desc.json no JSON, and
|
|
* test_web.mjs stopped there; the whole range now, a comma between names) */
|
|
for (n = 0; n < d->max - d->min + 1; n++)
|
|
v = param_turn(d, v, -1);
|
|
printf("%s[%d,%d,[", e++ ? "," : "", k < (uint32_t)P_E0 ? 0 : 1, k < (uint32_t)P_E0 ? (int)k : (int)(k - P_E0));
|
|
for (n = 0; n < d->max - d->min + 1; n++) {
|
|
int32_t w = param_turn(d, v, 1);
|
|
if (n)
|
|
putchar(',');
|
|
js_str(desc_nm(d, v));
|
|
if (w == v)
|
|
break;
|
|
v = w;
|
|
}
|
|
printf("]]");
|
|
}
|
|
}
|
|
printf("]}\n");
|
|
return 0;
|
|
}
|