Files
JIANT/tests/cpu_lines_test.c
Claude 161b8cae5f WAVE: a wavetable engine on engine 9 (PHYS's retired slot), JIANT BYTE's 16 tables
WAVE (engine 9, after ADD in ENGINE_ORDER, last in the PROGRAM CHANGE order): two tables A and B
of JIANT BYTE's 16 wave formulas (tools/gen_wave_tables.c/.py; firmware/src/wave_tables.h, 8186 B
Rice-coded int8, BYTE main 94f8ac9), POS over eight frames, WARP OFF SYNC BEND MIRROR QUANT FM with
AMT, MIX, DETUNE, SUB; U1..U8 named for user tables (empty: SINE). The frames decode into the part's
comb line (no new RAM; wv state in .pool), checked each block by a content signature (STRING / the
COMB's clear: decoded again, the part faded in). 26 presets.

Old data: a user preset of before (version < 4) or a project of phys < 4 with engine 9 is PHYS's and
plays as ANALOG / is refused as before; projects with a WAVE track are written phys 4. Favourites:
WAVE's in TRIO's retired row (bytes 0..3, cleared once: prefs revision 7).

No sound of another engine changes (golden: 26 added, 0 changed); the pinned audio layout unchanged
(eng_wave.c's tables and literals late, build.py); flash 19492 B free, RAM, RAM code and seg2 as
before, pool spare 8288 B. Tests: tests/wave_test.c (in voice-user-check), NRPN map regenerated,
ui_test's engine lists, ui_test's settings round trip zeroes its records (the stack's bold field).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
2026-12-05 00:29:17 +00:00

166 lines
9.0 KiB
C

/* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
/* (V10.8.60, technique from JIANT BYTE byte-cpu-light) the scenes of the lines model (tests/cpu_lines_test.py): the
* FM-1's time follows the 32-byte lines of the flash the sound reads each block (code and constants), core by core, more
* than its instructions. Run under valgrind's lackey: each block of the scene between two stores to cl_mark, core 1's
* work (mc_job) between two to cl_c1, each part (fx.c mix_part_t) between two to cl_part[k].
* cpu_lines_test SCENE NBLK (SCENE hex: 101 GEN EXPLORE s123 ENERGY 85 with CLOUD, the delay and the chorus;
* 102 .. 108 other GEN songs; 0c SAVE > TOOLS 6 CPU TEST's song (TRACKS 4))
* CL_COST="c0,..,c5,fx" (us): each part's cost as the FM-1 measures it (mc_tk, mc_fx_tk), for the device's split */
#include <stdint.h>
#define UI_TEST_NO_MAIN 1
#define MC_HOST_ASYNC
static int cl_mc_run(void (*f)(uint32_t), uint32_t a);
#define mc_run(f, a) cl_mc_run(f, a)
#define mc_wait() 0
#define HOST_LIFE 0
volatile int cl_mark, cl_c1, cl_ex, cl_part[8];
#define CPU_LINES_PART(i, v) (cl_part[(i) & 7u] = (v))
#include "ui_test.c"
static __attribute__((noinline)) void core1_run(void (*f)(uint32_t), uint32_t a) { f(a); __asm__ volatile(""); }
static int cl_mc_run(void (*f)(uint32_t), uint32_t a)
{
if (!mc_host) return 0;
mc_host_cpu = 1;
cl_c1 = 1;
core1_run(f, a);
cl_c1 = 2;
mc_host_cpu = 0;
return 1;
}
static int32_t vo[2 * CTL];
static uint32_t blk;
static void move(void) /* the matrix's sources moving: the macros, AT, MODW */
{
uint32_t k, ph = blk++;
for (k = 0; k < NTRK; k++) { trk[k].at = (uint8_t)((ph * 5u + k * 17u) % 128u); trk[k].mw = (uint8_t)((ph * 2u) % 128u); }
}
static uint32_t cl_cost[NTRK + 1u], cl_cost_on;
static void cost_in(void) /* (the device's split: what each part took, as it measures it) */
{
uint32_t k;
if (!cl_cost_on) return;
for (k = 0; k < NTRK; k++) mc_tk[k] = cl_cost[k];
mc_fx_tk = cl_cost[NTRK];
}
static uint32_t scene(uint32_t mask, uint32_t nblk)
{
uint32_t b, q, f = 0, h = 2166136261u;
int dty;
blk = 0;
ui_power_on(); go_home(); frames(4);
if (mask >= 0x100u) { /* GEN songs, TRACKS 6 */
static const struct { uint8_t g; uint16_t s; uint8_t e; int8_t m; } GS[9] = {
{0, 123, 85, 0}, {0, 123, 85, 0}, {0, 7, 90, 50}, {7, 42, 85, 0}, {12, 2024, 85, 50}, {0, 999, 100, 0},
{0, 321, 80, -50}, {3, 77, 95, 60}, {19, 5, 60, -40}}; /* (V10.8.68) 106 EXPLORE CALM, 107 DANCE, 108 NEO CLASSIC CALM */
uint32_t k, gi = (mask & 0xFFu) < 9u ? mask & 0xFFu : 0u;
ui_rec_prefs |= PREF_SIX >> 8; rp_apply();
gp.genre = GS[gi].g ? GS[gi].g : GEN_EXPLORE; gp.seed = GS[gi].s; gp.energy = GS[gi].e; gp.form = 1;
grd.mood = GS[gi].m;
gp.complex = 70; gp.swing = GA_AUTO; gp.human = 30;
for (k = 0; k < GP_N; k++) gp.amt[k] = GA_AUTO;
gen_go();
if (mask == 0x101u) { song.g[G_RTYPE] = 4; song.g[G_DFDBK] = 70;
for (k = 0; k < NTRK; k++) { trk[k].p[P_DLY] = 70; trk[k].p[P_REV] = 80; trk[k].p[P_CHOR] = 70; } }
} else { /* SAVE > TOOLS 6 CPU TEST's song, TRACKS 4 (the device's measure) */
ui_rec_prefs &= (uint8_t)~(PREF_SIX >> 8); rp_apply();
cpu_test_song();
if (mask == 0x0du || mask == 0x0eu) { /* (V10.8.75) its three synths MATH, their chords and steps
* kept: 0d BYTEBEAT (B02), MATH KEYS (F28), MATH PAD (F12);
* 0e the first two MATH USER (B03 as BYTE's bytecode, 37 B;
* F20 in FIX, 63 B: FLOAT), four voices of them at most */
static const uint8_t PRE[3] = {0, 3, 5};
uint32_t k;
for (k = 0; k < 3u; k++) {
static step_t keep[NSTEP];
memcpy(keep, trk[k].step, sizeof keep);
set_engine_of(&trk[k], ENGI_LOFI);
apply_preset_to(&trk[k], PRE[k]);
memcpy(trk[k].step, keep, sizeof keep);
trk[k].p[P_VOICE] = V_POLY; trk[k].p[P_SLEN] = 32; trk[k].p[P_SGATE] = 120;
}
#ifdef MU_MAX
if (mask == 0x0eu) {
static const uint8_t B03[] = {0,244,33,69,255,31,244,73,13,197,194,69,255,1,2,73,12,244,73,8,69,234,1,244,
73,3,5,194,244,73,14,69,3,9,69,127,0};
static const uint8_t F20[] = {1,116,3,180,129,41,244,73,11,69,3,76,0,116,3,155,129,41,93,3,116,0,53,0,244,
73,11,69,3,76,1,116,5,155,129,41,93,5,116,0,53,0,244,73,11,69,3,76,2,116,7,
155,129,41,93,7,116,0,53,0,27,93,4};
if (mu_set(0, B03, sizeof B03) || mu_set(1, F20, sizeof F20)) { printf("cpu_lines: a formula refused\n"); exit(1); }
trk[0].p[P_E2] = MU_ALGO; trk[1].p[P_E2] = MU_ALGO;
}
#endif
}
if (mask == 0x0fu) { /* (WAVE) its three synths WAVE, their chords and steps kept: its
* heaviest (FORMANT: B mixed, three voices a note), SUPERSAW,
* FM GROWL (WARP FM) */
static const char *const PRE[3] = {"FORMANT", "SUPERSAW", "FM GROWL"};
uint32_t k, j;
for (k = 0; k < 3u; k++) {
static step_t keep[NSTEP];
for (j = 0; j < ENG_WAVE.npresets && strcmp(ENG_WAVE.presets[j].name, PRE[k]); j++)
;
memcpy(keep, trk[k].step, sizeof keep);
set_engine_of(&trk[k], ENGI_WAVE);
apply_preset_to(&trk[k], j);
memcpy(trk[k].step, keep, sizeof keep);
trk[k].p[P_VOICE] = V_POLY; trk[k].p[P_SLEN] = 32; trk[k].p[P_SGATE] = 120;
}
}
}
song.master_q12 = 4096;
if (getenv("CL_OTT")) { /* (V10.8.71, as JIANT BYTE's) every track's OTT at this DEPTH (the
* worst case: 100) */
uint32_t k;
for (k = 0; k < NTRK; k++) ott_v[k][OT_DEPTH] = (int16_t)atoi(getenv("CL_OTT"));
}
#ifdef P_MMRPH
if (getenv("CL_BMORPH") && (mask == 0x0du || mask == 0x0eu)) { /* (byte-morph) 0d / 0e's BYTE (T1) at this MORPH,
* ALGO B B08: its cost between the ends (0: as before) */
trk[0].p[P_MMRPH] = (int16_t)atoi(getenv("CL_BMORPH"));
trk[0].p[P_MALGB] = 19;
}
#endif
if (getenv("CL_OTTB")) { /* (V10.8.73) one track's OTT alone at this DEPTH (100: the extreme
* zone): GEN's bass tracks; the CPU TEST's song its FM6 (T2: its
* chords sounding in the measured blocks) */
uint32_t k;
for (k = 0; k < NTRK; k++)
if (mask >= 0x100u ? gs.role[k] == RL_BASS : k == 1u) ott_v[k][OT_DEPTH] = (int16_t)atoi(getenv("CL_OTTB"));
}
if (live.mode) chain_play_ui(); else transport_req = 1;
ui_input();
dty = getenv("CL_DTYPE") ? atoi(getenv("CL_DTYPE")) : -1;
for (b = 0; b < 400u + nblk; b++) { /* (its first 400 blocks to warm: the song under way) */
if (b % 23u == 0u) { f++; ui_input(); song_poll(); host_ticks += 1000000u / 30u; fm1_ms += 1000u / 30u; }
if (dty >= 0) { /* (V10.8.72) every track's DIST at 100 on this TYPE (BYTE's formulas:
* 6 .. 11; a type's worst case), each block (the sections load theirs) */
uint32_t k;
for (k = 0; k < NTRK; k++) { trk[k].p[P_DIST] = 127; trk[k].p[P_DTYPE] = (int16_t)dty; }
}
move();
cost_in();
if (b >= 400u) cl_mark = 1;
mix_block(vo, CTL);
if (b >= 400u) cl_mark = 2;
for (q = 0; q < 2u * CTL; q++) h = (h ^ (uint32_t)vo[q]) * 16777619u;
}
(void)f;
return h;
}
int main(int argc, char **argv)
{
uint32_t m = argc > 1 ? strtoul(argv[1], 0, 16) : 0x101u, nblk = argc > 2 ? strtoul(argv[2], 0, 10) : 16u, h, k;
mc_host = 1; /* (two cores: core 1's job at once, between cl_c1's stores) */
if (getenv("CL_COST")) {
char *p = getenv("CL_COST");
cl_cost_on = 1;
for (k = 0; k <= NTRK && *p; k++) { cl_cost[k] = strtoul(p, &p, 10); if (*p == ',') p++; }
}
h = scene(m, nblk);
printf("cpu_lines: scene %03x hash %08x voices", m, h);
for (k = 0; k < NTRK; k++) { uint32_t i, n = 0; for (i = 0; i < NVOICE; i++) n += trk[k].v[i].active != 0; printf(" %u", n); }
printf("\n");
return 0;
}