mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 12:54:29 +01:00
Juan: "una cola extremadamente bitcrasheada pero tenue hasta el silencio". Después de V10.8.87 (el DAC recibe el Q17 del master), con MASTER al máximo el error de la cola venía de la mezcla misma, antes del master: - fx.c mix_part: x = ((b >> 2) * (lq >> 8)) >> 10. El pre-shift tiraba los dos bits bajos de la pista y redondeaba para abajo: con LEVEL a 1 la cola salía en escalones de 4 LSB, y el sesgo (siempre hacia abajo) quedaba como una continua que el DC block soltaba despacio después del sonido: la cola "hasta el silencio". Ahora x = (b * (lq >> 10) + 512) >> 10: el LEVEL en Q10 sobre la pista entera, redondeado. El mismo margen (8 voces fuertes, GAIN +12 dB) y las mismas instrucciones en el loop (mix_part_m0, RAM). - dsp.c voice_amp: mulq15(mulq15(s, amp), VOICE_FS) truncaba dos veces. Ahora ((s * amp) >> 9) * 375 >> 15 (VOICE_FS / 64): un solo truncado, las mismas instrucciones; ningún motor cambia de tamaño. - DRUM: voice_amp(...) << 1 dejaba el bit bajo en cero y drum_bus hacía (out >> 1) << 1 siempre. voice_amp2 (x2 en el último shift, una instrucción menos por voz y muestra) y drum_bus escribe sólo si la curva (DRV, GAIN, la rodilla) cambió algo. drum_side_ramp, drum_render y drum_bus del tamaño grabado con un DSP_PAD2 cada uno (fm1_pad2 fuera del loop, nada en el host): nada fijado se mueve. Medido en el host contra la referencia de alta precisión (las palabras de 24 bits del DAC; error en la cola, dBFS del codec), antes -> después: - MASTER 0 dB: kick -98.1 -> -107.0, tom -98.0 -> -106.7, tineEP -95.7 -> -109.5, seno -98.1 -> -110.8. En la parte tenue (referencia entre -70 y -110 dBFS) +10..+12 dB. Antes, con la referencia ya bajo -100 dBFS, la salida seguía con 8-9 bits que eran casi todo error (tom a 789 ms: referencia -100, error -93); ahora sigue a la señal y llega a cero 80..170 ms antes. - MASTER -12 dB: +1.7..+4.5 dB; -24 dB: +0.4..+1. Ahí lo que queda está en master_out (sus truncados en Q17), no en la mezcla. WAVs antes / después (24 bits como los recibe el DAC, y +48 dB) y el resumen en el scratchpad de la sesión (noise3/wav). Costo: target_budget drum_render 33 -> 32, drum_side_ramp 45 -> 44 (por voz), drum_bus 63 -> 66 (por pista DRUM: la escritura condicional), mix_part_m0 igual. cpu_lines (101, 0c, 103), contra V10.8.87: líneas igual (+-3), instrucciones un poco menos (0c core 0 162.5 -> 156.2 k, 101 88.7 -> 87.0 k), los mismos % (0c 76 -> 75 % el peor bloque). Imagen 8820 B libres (antes 8828), RAM .data+.bss igual (97940), RAM code 39300 de 42496 (+4), pool spare 8192, c2 igual. Ninguna función fijada se mueve. tests/golden.txt: 236 de 245 renders cambian (los bits bajos de la mezcla; los 9 iguales son EXT en silencio). micro_test: el hash nuevo. math_morph_test: los hashes de MATH (el render del motor, su último bit por voice_amp); MORPH 0 sigue siendo ALGO A solo, cualquiera sea ALGO B. loopq_test: sus hashes de WAVE (iguales entre sí como antes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
93 lines
4.5 KiB
C
93 lines
4.5 KiB
C
// Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant). All rights reserved.
|
|
/* (V10.8.66, JIANT BYTE 68b546c9's loopq) MATH's LOOP with WAVE SYNC: 1 .. 8 a division of the song (4 BAR .. 1/32),
|
|
* the window aligned to the transport, the note's t from 0 at each window's start. LOOP 0 and every other WAVE as
|
|
* before (the hashes taken from V10.8.65's code); at 125 BPM a bar is a whole number of blocks (1440 x 64), so a
|
|
* 1 BAR loop repeats sample for sample, and two notes started at different times play the same loop on the same bars.
|
|
* Built and run by CI (voice-user-check.yml) */
|
|
#define UI_TEST_NO_MAIN 1
|
|
#include "ui_test.c"
|
|
|
|
/* WAVE w, LOOP lp, note n, BPM bpm: the note starts at block st; nb blocks rendered into out (or hashed if out == 0) */
|
|
static uint32_t run(int16_t w, int16_t lp, uint32_t n, int bpm, uint32_t st, uint32_t nb, int32_t *out)
|
|
{
|
|
static track_t t;
|
|
static voice_t v;
|
|
static int32_t o[CTL];
|
|
vmod_t m;
|
|
tsvf_t flt;
|
|
uint32_t k, i, h = 2166136261u;
|
|
memset(&t, 0, sizeof t); memset(&v, 0, sizeof v); memset(&m, 0, sizeof m);
|
|
t.p[P_E0] = 2; t.p[P_E1] = w; t.p[P_E2] = 4; t.p[P_E7] = lp; t.p[P_FCUT] = 127; t.p[P_FRES] = 50;
|
|
m.amp0 = m.amp1 = 32767; m.shape = 64 << 8;
|
|
m.inc = w == RW_BLOCK ? 0u : pitch_inc((int32_t)n << 4); /* (V10.8.77) the slow time's step, as lofi_render
|
|
* hands it (TIME KEY: the note's; WAVE SYNC: 0, the song's clock) */
|
|
tsvf_coef(&flt, 127 << 8, 50);
|
|
song.g[G_BPM] = bpm;
|
|
bar_n = 0; beat_n = 0; beat_pos = 0;
|
|
for (k = 0; k < nb; k++) {
|
|
memset(o, 0, sizeof o);
|
|
if (k == st)
|
|
lofi_note_on(&t, &v);
|
|
if (k >= st)
|
|
lofi_byte_render(&t, &v, o, CTL, &m, pitch_inc((int32_t)n << 4), 1, 8, &flt);
|
|
for (i = 0; i < CTL; i++) {
|
|
h = (h ^ (uint32_t)o[i]) * 16777619u;
|
|
if (out) out[k * CTL + i] = o[i];
|
|
}
|
|
beat_pos += CTL;
|
|
if (beat_pos >= beat_samples()) {
|
|
beat_pos -= beat_samples();
|
|
beat_n = (beat_n + 1u) & 3u;
|
|
if (!beat_n) bar_n++;
|
|
}
|
|
}
|
|
return h;
|
|
}
|
|
#ifndef LOOPQ_H0 /* (V10.8.65's own: run with an argument on that code to print them; V10.8.88: dsp.c voice_amp one
|
|
* truncation, the render's last bit: 0306bb47 0306bb47 39bbfc71 57add740 x3 before, the same equal) */
|
|
#define LOOPQ_H0 0xd08f8d2cu
|
|
#define LOOPQ_H1 0xd08f8d2cu
|
|
#define LOOPQ_H2 0xd2888d31u
|
|
#define LOOPQ_H3 0xb4a8d9dcu
|
|
#define LOOPQ_H4 0xb4a8d9dcu
|
|
#define LOOPQ_H5 0xb4a8d9dcu
|
|
#endif
|
|
int main(int argc, char **argv)
|
|
{
|
|
static const struct { int16_t w, lp; } C[] = {{7, 0}, {7, 40}, {7, 127}, {5, 0}, {5, 3}, {5, 60}};
|
|
static const uint32_t H[6] = {LOOPQ_H0, LOOPQ_H1, LOOPQ_H2, LOOPQ_H3, LOOPQ_H4, LOOPQ_H5};
|
|
uint32_t bar, k, nb, eq, eq2;
|
|
static int32_t a[8000 * CTL], b[8000 * CTL];
|
|
int bad = 0, i;
|
|
for (i = 0; i < 6; i++) {
|
|
uint32_t h = run(C[i].w, C[i].lp, 60, 120, 0, 1500, 0);
|
|
if (argc > 1) { printf("#define LOOPQ_H%d 0x%08xu\n", i, h); continue; }
|
|
char s[96];
|
|
snprintf(s, sizeof s, "as before: WAVE %s LOOP %d", C[i].w == 7 ? "SYNC" : "BYTE", C[i].lp);
|
|
bad += check(s, h == H[i]);
|
|
}
|
|
if (argc > 1)
|
|
return 0;
|
|
song.g[G_BPM] = 125;
|
|
bar = 4u * beat_samples() / CTL;
|
|
nb = bar * 4u;
|
|
run(7, 3, 60, 125, 0, nb, a); /* (1 BAR) */
|
|
eq = memcmp(&a[bar * CTL], &a[2u * bar * CTL], bar * CTL * sizeof a[0]) == 0
|
|
&& memcmp(&a[bar * CTL], &a[3u * bar * CTL], bar * CTL * sizeof a[0]) == 0;
|
|
bad += check("SYNC LOOP 1 BAR at 125 BPM: bars 2, 3 and 4 the same, sample for sample", eq);
|
|
run(7, 3, 60, 125, 300, nb, b); /* (the same note, started 300 blocks later) */
|
|
eq2 = memcmp(&a[2u * bar * CTL], &b[2u * bar * CTL], 2u * bar * CTL * sizeof a[0]) == 0; /* (bars 3 and 4: the filters' state settled) */
|
|
bad += check("SYNC LOOP 1 BAR: a note started later plays the same loop on the same bars", eq2);
|
|
run(7, 0, 60, 125, 0, nb, b);
|
|
bad += check("SYNC LOOP OFF: bars 2 and 3 differ (no loop)", memcmp(&b[bar * CTL], &b[2u * bar * CTL], bar * CTL * sizeof b[0]) != 0);
|
|
#ifndef LOOPQ_OLD
|
|
{
|
|
int nm = 1;
|
|
for (k = 0; k < 9; k++) { char v[8]; const char *u; param_format(&LOFI_LOOPQ, (int32_t)k, v, &u); nm &= !strcmp(v, str_nth(N_LOOPQ, k)); }
|
|
bad += check("the card names LOOP 0 .. 8: OFF 4 BAR .. 1/32", nm);
|
|
}
|
|
#endif
|
|
printf(bad ? "loopq: %d FAILED\n" : "loopq: all ok\n", bad);
|
|
return bad != 0;
|
|
}
|