Files
JIANT/tests/cpu_lines_test.c
T
Claude d03b4046e2 V10.8.71: FX > OTT, JIANT BYTE's two-band compressor on each track
Juan approved the port. BYTE 43923fd4 (Juan's GPL code), on FM's tracks,
FX chain, UI, project and preset formats and editor protocol:
- fx.c ott_block, after DIST in mix_part: a one-pole split at X-OVER,
  each band's block peak followed in log2 at TIME, the gains computed
  once a block and ramped across the next. DEPTH 0: not called, the
  track bit for bit. Under the overload guard (voice.c) half the depth;
  past 90 % average load none. The sound is never cut.
- The gain law is BYTE v1.1b4's, from the spec (Juan: "at 100 it barely
  changes the sound"): up to +28 dB upward below -12 dBFS, about 10:1
  downward above -15 dBFS, DEPTH squared, TIME 72 by default (attack
  ~1.5 ms, release ~40 ms), an 8:1 limiter over -3 dBFS. A -40 dBFS
  sine comes out at -13.5 dBFS, a -6 dBFS one at -10.1.
- FX > TRACK's fourth page OTT: DEPTH TIME UP/DN X-OVER (page ids
  0xB0..0xB3: BYTE's 0xD0 is DRONE CLAY's here). Its name large
  (page_big), LOW and HIGH: the level in dim grey cells (gx_col), the
  gain on the thermal ramp by its amount, with its dB. HOME's ECO tags
  a track with OTT on, in the same thermal colour.
- Kept with a project ('O' 'T' after 'G' 'T') and a user preset (byte
  138 'O', the four before it). Each value is stored less its default,
  so TIME, UP/DN and X-OVER are kept at DEPTH 0 too (BYTE's pending
  fix). Older files load with OTT off.
- Editor protocol 1.4: special ids P_COUNT + 0..3 (123..126) for OTT
  through TRACK_PARAM (31) and DESC; UI caps bit 4. BYTE's 0xD0..0xD3
  are not 7-bit bytes, and 0x50..0x53 are FM parameters. GET / SET,
  DUMP and the pushes are unchanged.
- GLO's map names A4 RESOUND, as G4 UNDO.

Flash (V10.8.70: 228 B free; OTT costs ~1.9 KB):
- str_cat and fmt_cat: one helper for the UI's 143 appends and 32
  number appends (-680 B image, -64 B BT);
- project.c: one writer and one reader for the array blocks
  (proj_blk, proj_at, proj_get: -500 B);
- more name tables packed with str_nth; the three note-name tables
  are one list;
- fam_on, home_is, ui_timers: one helper each;
- DRONE CLAY's main-loop side built for size; a note's start, a
  FILL, a CLAY strike and other once-an-event sound functions
  built for size (size_fns.py event_size).
Image 176 B free, BT 88 B free, RAM .data+.bss 1072 B free, pool spare
8224 B, RAM code 40200 of 42496 B. audio.c is V23's; the V23 renders
are present. REPIN=keep; a plain build passes.

CPU (tests/cpu_lines_test.py), each scene's worst block on core 0 and
core 1, V10.8.70 -> V10.8.71 OTT off -> every track at DEPTH 100:
  101 78/44 -> 79/44 -> 83/47    102 61/28 -> 62/28 -> 66/31
  103 80/14 -> 81/14 -> 84/14    104 46/14 -> 46/14 -> 49/14
  105 65/41 -> 66/41 -> 69/44    106 52/35 -> 53/36 -> 56/39
  107 58/11 -> 58/11 -> 62/11    108 51/29 -> 51/29 -> 55/32
  0c  70/58 -> 70/58 -> 74/62
With OTT off the sound's code sits up to 28 B off its old 32-byte
lines (the layout moved). The same build without the per-event minsize
measures the same.

tests/ott_test.c (in CI), cpu_lines_test.c CL_OTT, app_contract (the
special ids), ui_test (the FX chain of 20, GLO's RESOUND).

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

103 lines
5.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;
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();
}
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"));
}
if (live.mode) chain_play_ui(); else transport_req = 1;
ui_input();
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; }
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;
}