FMini: a turned SLOT loads after 50 ms still

fmini_poll no longer loads a slot at each step of the knob: the slot
the knob points to loads once it has been still for FMINI_LOAD_MS (50).
Each turn restarts the count. OWN changes stay immediate. A note played
in that window sounds the previous patch (accepted). fmini_bank_test
checks the count (not at once; 30 ms still no; 50 ms still loads).

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUF6pQ1NkTwmBC8SR8AK94
This commit is contained in:
Claude committed 2026-10-29 17:09:51 -03:00
1 parent 84b16e9caa
commit 253ff329db
2 files changed
+38 -1

No files matched your search

+16 -1
View File
@@ -78,6 +78,9 @@ static int32_t fmini_det(const uint8_t *g, uint32_t i) /* the cents of DET byt
static uint8_t fmini_patch[NTRK][FG_SIZE]; /* the tracks' patches (main loop writes, then fmini_pgen) */
static volatile uint8_t fmini_pgen[NTRK]; /* +1 after each write of fmini_patch[t] */
static uint16_t fmini_slot[NTRK]; /* the SLOT value last loaded (main loop); 0xFFFF = none (1.14.0: 256 = OWN) */
#define FMINI_LOAD_MS 50u /* a SLOT that keeps turning loads when it stops for this long (1.14.0) */
static uint16_t fmini_want[NTRK]; /* the slot the knob points to, not loaded yet (0xFFFF: none) */
static uint32_t fmini_want_ms[NTRK]; /* when fmini_want last changed */
static uint8_t fmini_own[NTRK][FG_SIZE]; /* the own patch while SLOT shows a factory one (fmini_poll) */
static uint8_t fmini_own_ok; /* bit tr: fmini_own[tr] holds it */
static struct { /* the patch as the audio ISR sees it (taken at a block's start) */
@@ -190,6 +193,7 @@ static void fmini_init(void) /* power-on: every track F1 */
for (tr = 0; tr < NTRK; tr++) {
fmini_set_patch(tr, FMINI_FACTORY[0]);
fmini_slot[tr] = 0xFFFFu;
fmini_want[tr] = 0xFFFFu;
}
}
@@ -200,9 +204,20 @@ static void fmini_poll(void)
uint32_t tr, bit;
for (tr = 0; tr < NTRK; tr++) {
int32_t s = trk[tr].p[P_E7];
if (trk[tr].eng_req != ENGI_FMINI || s == fmini_slot[tr])
if (trk[tr].eng_req != ENGI_FMINI || s == fmini_slot[tr]) {
fmini_want[tr] = 0xFFFFu;
continue;
}
bit = 1u << tr;
if (s >= 0 && s < (int32_t)FMINI_NSLOT) { /* a slot: loads once the knob has been still for FMINI_LOAD_MS */
if (fmini_want[tr] != (uint16_t)s) {
fmini_want[tr] = (uint16_t)s;
fmini_want_ms[tr] = fm1_ms;
continue;
}
if (fm1_ms - fmini_want_ms[tr] < FMINI_LOAD_MS)
continue;
}
if (s < 0 || s >= (int32_t)FMINI_NSLOT) { /* OWN */
if (fmini_own_ok & bit)
fmini_set_patch(tr, fmini_own[tr]);
+22
View File
@@ -67,6 +67,28 @@ int main(void)
fbchk(!strcmp(fb_name[0], "MINI LEAD") && !strcmp(fb_name[FMINI_NFACTORY], "INIT") && !strcmp(fb_name[FB_NSLOT - 1], "INIT"),
"the RAM name list: slot 0 and the INIT slots");
/* the load waits: a SLOT loads once it has been still for 50 ms; each turn starts the count again */
{
uint32_t t0 = 1000u;
uint8_t want[FB_SLOT];
(void)want;
trk[0].eng_req = ENGI_FMINI;
fmini_slot[0] = 0xFFFFu;
fm1_ms = t0;
trk[0].p[P_E7] = 5;
fmini_poll();
fbchk(fmini_slot[0] != 5u, "a turned slot is not loaded at once");
fm1_ms = t0 + 30u;
trk[0].p[P_E7] = 6; /* turned again: the count restarts */
fmini_poll();
fm1_ms = t0 + 60u; /* 30 ms since the last turn */
fmini_poll();
fbchk(fmini_slot[0] != 6u, "still turning (30 ms since the last change): not loaded");
fm1_ms = t0 + 80u; /* 50 ms since the last turn */
fmini_poll();
fbchk(fmini_slot[0] == 6u, "still for 50 ms: the slot loads");
}
printf(bad ? "FMINI BANK TEST FAILED\n" : "fmini_bank test passed\n");
return bad != 0;
}