mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-05 12:24:42 +01:00
CLOUD at SIZE max: a cleared line no longer freezes silent; the grains' overlap cap without its 12 dB drop
The tester (0.9.15): "CLOUD does not work at SIZE 100 %, it seems disabled". - SIZE 127 is FREEZE (the line stops being written). Since 0.9.14's fx_rest the line is cleared in any pause, so turning SIZE to max and then playing froze an empty line: silence at any RATE (also true in 0.9.13 from a fresh start). Now a cleared line first takes a line's worth of sound (~0.74 s, fx.cl_fill), then holds; a line already filled freezes at once, as before. - 0.9.14's overlap cap scaled the grains by (gl >> 2) x CL_WMAX / ws: past 2 grains (RATE ~90 up) they fell 12 dB at once. Now gl x CL_WMAX / ws with the cap at 1.25 grains, so ROOM's allpasses under it still do not clamp at ROOM_CLEAN's send: RATE 127 within ~5 dB of RATE 0 (was ~14 dB under), no runaway. cloud_hot_test: SIZE 127 from a cleared line at RATE 0..127 sounds (within 6 dB of 126) and holds after the send; RATE 127 within 8 dB of RATE 0 (fails on main). Golden renders unchanged; flash +48 B. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
This commit is contained in:
2 files changed
+40
-5
No files matched your search
+10
-5
@@ -70,6 +70,7 @@ static struct {
|
||||
uint16_t rs_w; /* .. their write index (each its own line, 1024) */
|
||||
uint32_t cl_w, cl_rng; /* .. CLOUD: its line's write count (half rate), its random numbers */
|
||||
int32_t cl_dc; /* .. (0.9.14) its loop's DC (Q8 samples) */
|
||||
uint16_t cl_fill; /* .. (0.9.16) sound written into its line since it was cleared (full-rate samples, to 32768) */
|
||||
int32_t cl_next, cl_lp, cl_half, cl_gl, cl_gr; /* .. the samples to the next grain, the output's low-pass, the odd sample */
|
||||
uint16_t sp_w; /* SPRING: the loop's write index (SP_MASK) */
|
||||
uint8_t sp_ns; /* (0.6.70) SPRING's allpass stages last block (SP_N, LOAD ECO SP_N_ECO) */
|
||||
@@ -1014,7 +1015,7 @@ static __attribute__((noinline)) void rev_reso(const int32_t *rev_in, int32_t *o
|
||||
}
|
||||
}
|
||||
#define CL_N 12u /* (its line, CL_LEN: rev_x, at the top) */
|
||||
#define CL_WMAX 512 /* (0.9.14) the grains' windows summed: 2 grains' worth at most */
|
||||
#define CL_WMAX 320 /* (0.9.14) the grains' windows summed: 1.25 grains' worth at most (0.9.16) */
|
||||
#define CL_BACK (CL_LEN - 6000u - 1024u) /* .. the farthest back a grain may start (rev_cloud) */
|
||||
static struct { uint32_t pos, inc; uint16_t len, age; int16_t pl, pr; } cl_g[CL_N];
|
||||
static uint32_t cl_rand(void) { fx.cl_rng = fx.cl_rng * 1664525u + 1013904223u; return fx.cl_rng >> 8; }
|
||||
@@ -1028,7 +1029,9 @@ static uint32_t cl_rand(void) { fx.cl_rng = fx.cl_rng * 1664525u + 1013904223u;
|
||||
static __attribute__((noinline)) void rev_cloud(const int32_t *rev_in, int32_t *out, uint32_t n)
|
||||
{
|
||||
static const uint32_t PITCH[4] = {65536u, 131072u, 32768u, 98184u}; /* x1, an octave up, down, a fifth up (Q16) */
|
||||
uint32_t i, k, freeze = GFX(GF_RSIZE) >= 127;
|
||||
uint32_t i, k, freeze = GFX(GF_RSIZE) >= 127 && fx.cl_fill >= 32768u; /* (0.9.16: a FREEZE of a cleared
|
||||
* line held silence: "CLOUD off at SIZE 100 %"; now the line
|
||||
* first takes a line's worth of sound, ~0.74 s, then holds) */
|
||||
int32_t gap = 1700 - song.g[G_RRATE] * 11, dk = 32767 - GFX(GF_RDAMP) * 220, wd = song.g[G_RWIDE], air = rev_air();
|
||||
uint32_t ar = semi_q16(air); /* (0.6.12) AIR: the grains up / down, the tone with them */
|
||||
if (air < 0) dk = clamp(dk + air * 1100, 1500, 32767);
|
||||
@@ -1048,6 +1051,7 @@ static __attribute__((noinline)) void rev_cloud(const int32_t *rev_in, int32_t *
|
||||
else
|
||||
fx.cl_half = x;
|
||||
fx.cl_w++;
|
||||
if (fx.cl_fill < 32768u && (fx.cl_fill || x)) fx.cl_fill++;
|
||||
}
|
||||
if (--fx.cl_next <= 0) { /* a grain is born, in the first one free */
|
||||
fx.cl_next = gap / 2 + (int32_t)(cl_rand() % (uint32_t)gap);
|
||||
@@ -1093,9 +1097,9 @@ static __attribute__((noinline)) void rev_cloud(const int32_t *rev_in, int32_t *
|
||||
}
|
||||
}
|
||||
if (ws > CL_WMAX) { /* (0.9.14) the overlap at most CL_WMAX / 256 grains' worth: */
|
||||
int32_t q = (CL_WMAX << 13) / ws; /* the windows' sum grows with RATE (up to 12 grains), and */
|
||||
gl = ((gl >> 2) * q) >> 13; /* x SIZE's feedback (0.43) it passed 1 from RATE ~90 (any */
|
||||
gr = ((gr >> 2) * q) >> 13; /* SIZE at 127): the line ran away into its clamps, the */
|
||||
int32_t q = (CL_WMAX << 11) / ws; /* the windows' sum grows with RATE (up to 12 grains), and */
|
||||
gl = (gl * q) >> 11; /* x SIZE's feedback (0.43) it passed 1 from RATE ~90 (any */
|
||||
gr = (gr * q) >> 11; /* SIZE at 127): the line ran away into its clamps, the */
|
||||
} /* crackle. Now the loop's gain <= 0.43 x 2: it always dies */
|
||||
l = (gl + fx.cl_gl) >> 1;
|
||||
r = (gr + fx.cl_gr) >> 1;
|
||||
@@ -1160,6 +1164,7 @@ static void rev_state_clear(void)
|
||||
cl_g[i].len = 0;
|
||||
fx.cl_gl = fx.cl_gr = 0;
|
||||
fx.cl_dc = 0;
|
||||
fx.cl_fill = 0;
|
||||
fx.cl_lp = fx.cl_half = 0; /* (0.8.4: CLOUD's tone and odd sample too; its tone's state
|
||||
* was kept, a residue back into the next CLOUD's line) */
|
||||
}
|
||||
|
||||
@@ -260,6 +260,36 @@ int main(int argc, char **argv)
|
||||
check("CLOUD's line never clamps (any send), nor ROOM's combs / allpasses under it up to ROOM_CLEAN's send", !any_clamp);
|
||||
check("CLOUD never trips the buses' range check (FX_SANE) up to a 200000 send", !worst_trip);
|
||||
check("CLOUD AIR +24: no grain reads across the write head", cross_air == 0);
|
||||
{ /* (0.9.16) the tester: "CLOUD at SIZE 100 % seems off". SIZE 127 (FREEZE) from a cleared line held silence
|
||||
* (fx_rest clears it in any pause); and past 2 grains' overlap the grains fell 12 dB (high RATE). Now a
|
||||
* cleared line first takes a line's worth of sound, then holds; the level about even across RATE. */
|
||||
static const int RT[5] = {0, 30, 60, 90, 127};
|
||||
double e[3][5];
|
||||
uint32_t b, k, i;
|
||||
int ok = 1;
|
||||
stats_t st;
|
||||
for (k = 0; k < 3u; k++)
|
||||
for (b = 0; b < 5u; b++) {
|
||||
double s0 = 0, s1 = 0;
|
||||
cl_reset();
|
||||
song.g[G_RSIZE] = (int16_t)(k == 0 ? 127 : k == 1 ? 126 : 100); song.g[G_RRATE] = (int16_t)RT[b];
|
||||
song.g[G_RMOD] = 0; song.g[G_RWIDE] = 0; song.g[G_RPRE] = 0;
|
||||
render(16000, 1.0, wl, wr, &st);
|
||||
for (i = FS * 3u / 4u; i < 2u * FS; i++) s0 += (double)wl[i] * wl[i] + (double)wr[i] * wr[i];
|
||||
for (i = 3u * FS; i < 4u * FS; i++) s1 += (double)wl[i] * wl[i] + (double)wr[i] * wr[i];
|
||||
e[k][b] = 10.0 * log10(s0 / (2.5 * FS) + 1.0);
|
||||
if (k == 0) {
|
||||
double held = 10.0 * log10(s1 / (2.0 * FS) + 1.0);
|
||||
printf("cloud: SIZE 127 RATE %3d: %5.1f dB with the send, %5.1f dB held 1-2 s after it\n", RT[b], e[0][b], held);
|
||||
ok &= held > e[0][b] - 6.0;
|
||||
}
|
||||
}
|
||||
for (b = 0; b < 5u; b++) {
|
||||
printf("cloud: RATE %3d: SIZE 127 %5.1f dB, 126 %5.1f dB, 100 %5.1f dB\n", RT[b], e[0][b], e[1][b], e[2][b]);
|
||||
ok &= e[0][b] > e[1][b] - 6.0 && e[2][b] > e[2][0] - 8.0;
|
||||
}
|
||||
check("CLOUD SIZE 127 from a cleared line, any RATE: sounds (within 6 dB of 126) and holds; RATE 127 within 8 dB of 0", ok);
|
||||
}
|
||||
printf(bad ? "cloud hot test FAILED\n" : "cloud hot test passed\n");
|
||||
return bad != 0;
|
||||
}
|
||||
Reference in new issue
Block a user