mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 12:54:29 +01:00
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
64 lines
3.0 KiB
C
64 lines
3.0 KiB
C
/* SPDX-License-Identifier: GPL-3.0-only
|
|
* Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
|
|
/* WAVE's factory tables (firmware/src/eng_wave.c): JIANT BYTE's 16 wave formulas evaluated by BYTE's own formula
|
|
* machine, exactly as BYTE's eng_wave.c draws its frames (wf_build: 128 points a frame, the phase w = i x 512, t = 0,
|
|
* no state, POS as FIX = POS (Q8) x 516 >> 8, the result >> 1 as int16), at the eight positions of FM's fixed grid
|
|
* (frame k at POS = k x 127 / 7, Q8 rounded). It prints the frames as text, one frame a line (16 x 8 lines of 128
|
|
* int16); tools/gen_wave_tables.py packs them into firmware/src/wave_tables.h.
|
|
*
|
|
* Built against a JIANT BYTE checkout (GPL, the same owner; only to regenerate the header, CI never needs it):
|
|
* cc -O2 -I$BYTE/build/gen -I$BYTE/tests -I$BYTE/firmware/src -o build/host/gen_wave_tables tools/gen_wave_tables.c -lm
|
|
* (BYTE's build/gen: its generated headers, from BYTE's own build). Reproduces BYTE main 94f8ac9 (v1.2.1); it checks
|
|
* that the formula bank BYTE's device compiles (fvm_bank.c, FVM_WAVE0..) holds the texts of eng_wave.c */
|
|
#include <stdarg.h>
|
|
#define main hostsim_main
|
|
#include "hostsim.c"
|
|
#undef main
|
|
#include "fvm.c"
|
|
#include "fvm_bank.c"
|
|
|
|
static const char *const TEXT[16] = {WAVE_W00_TEXT, WAVE_W01_TEXT, WAVE_W02_TEXT, WAVE_W03_TEXT, WAVE_W04_TEXT,
|
|
WAVE_W05_TEXT, WAVE_W06_TEXT, WAVE_W07_TEXT, WAVE_W08_TEXT, WAVE_W09_TEXT,
|
|
WAVE_W10_TEXT, WAVE_W11_TEXT, WAVE_W12_TEXT, WAVE_W13_TEXT, WAVE_W14_TEXT,
|
|
WAVE_W15_TEXT};
|
|
static fvm_cc_t cc;
|
|
static fvm_scratch_t scr;
|
|
static fvm_ins_t ins[FVM_MAXINS];
|
|
|
|
int main(void)
|
|
{
|
|
uint32_t f, k, i, b;
|
|
for (f = 0; f < 16u; f++) {
|
|
static char tx[512];
|
|
fvm_prog_t p = {0};
|
|
fvm_err_t er;
|
|
fvm_bank_to(FVM_WAVE0 + f, tx);
|
|
if (strcmp(tx, TEXT[f])) {
|
|
fprintf(stderr, "wave %u: the bank's text \"%s\" is not eng_wave.c's \"%s\"\n", f, tx, TEXT[f]);
|
|
return 1;
|
|
}
|
|
fvm_prog_init(&p, ins, FVM_MAXINS);
|
|
if (fvm_compile(&cc, &p, tx, (uint32_t)strlen(tx), &er)) {
|
|
fprintf(stderr, "wave %u: compile error %u at %u\n", f, er.code, er.pos);
|
|
return 1;
|
|
}
|
|
for (k = 0; k < 8u; k++) {
|
|
int32_t pq = (int32_t)((k * 127u * 256u + 3u) / 7u); /* the grid: POS k x 127 / 7, Q8 */
|
|
printf("%u %u", f, k);
|
|
for (b = 0; b < 4u; b++) {
|
|
int32_t st[FVM_MAXSTATE] = {0};
|
|
uint32_t T[FVM_BLK] = {0}, W[FVM_BLK], y[FVM_BLK];
|
|
fvm_env_t e = {{T, W, 0, 0, 0}, {0}, st};
|
|
e.u[FU_AF] = (uint32_t)clamp(pq, 0, 127 << 8) * 516u >> 8;
|
|
for (i = 0; i < FVM_BLK; i++)
|
|
W[i] = (b * FVM_BLK + i) * (65536u / 128u);
|
|
fvm_run(&p, &e, &scr, FVM_BLK, y);
|
|
for (i = 0; i < FVM_BLK; i++)
|
|
printf(" %d", (int)clamp((int32_t)y[i] >> 1, -32768, 32767));
|
|
}
|
|
printf("\n");
|
|
}
|
|
}
|
|
return 0;
|
|
}
|