diff --git a/docs/emu2/felucca.wasm b/docs/emu2/felucca.wasm index 115c0f1..c3eadca 100755 Binary files a/docs/emu2/felucca.wasm and b/docs/emu2/felucca.wasm differ diff --git a/firmware/src/fx.c b/firmware/src/fx.c index 8e529a9..8a7738f 100644 --- a/firmware/src/fx.c +++ b/firmware/src/fx.c @@ -292,7 +292,8 @@ static uint32_t beat_samples(void) static uint32_t div_samples(uint32_t div) { uint32_t quarter = beat_samples(); - return div < 6u ? quarter / DIV_DEN[div] : div < 10u ? quarter << (div - 5u) : quarter / DIV_DEN[div % 6u]; + return div < 6u ? quarter / DIV_DEN[div] : div < 10u ? quarter << (div - 5u) : div == 10u ? quarter * 4u / 3u + : div == 11u ? quarter * 2u / 3u : quarter / DIV_DEN[div % 6u]; /* 10: 1/2T, 11: 1/4T (triplets) */ } #include "perform.c" /* the FX hold layer's effects (the master) */ @@ -314,12 +315,12 @@ static uint32_t dly_div_fits(uint32_t div) /* A-SYNC: this note value } static uint32_t dly_fits(void) { - return song.g[G_DTIME] != 7 || dly_div_fits((uint32_t)clamp(song.g[G_DRREV], 0, 9)); + return song.g[G_DTIME] != 7 || dly_div_fits((uint32_t)clamp(song.g[G_DRREV], 0, 11)); } static uint32_t delay_samples(void) { if (song.g[G_DTIME] == 7) { /* A-SYNC: the time in N_DIV's note values (G_DRREV, 0..9), the tempo's */ - uint32_t s = div_samples((uint32_t)clamp(song.g[G_DRREV], 0, 9)); + uint32_t s = div_samples((uint32_t)clamp(song.g[G_DRREV], 0, 11)); return s < 16u ? 16u : s >= DLY_LEN ? DLY_LEN - 1u : s; } #if FELUCCA_FMINI_ONLY diff --git a/firmware/src/params.c b/firmware/src/params.c index 51ab637..4ba563b 100644 --- a/firmware/src/params.c +++ b/firmware/src/params.c @@ -10,10 +10,10 @@ static const char *const N_LTRIG[] = {"NOTE", "FREE"}; static const char *const N_LPOL[] = {"BI", "UNI"}; static const char *const N_AMODE[] = {"OFF", "UP", "DN", "UPDN", "RND", "ORD", "REPEAT", /* (append-only: seq.c AM_*) */ "DNUP", "UP+8", "CONV", "DIVG", "PINKY", "THUMB", "WALK", "CHORD"}; -static const char *const N_DIV[] = {"1/4", "1/8", "1/16", "1/32", "8T", "16T", "1/2", "1/1", "2BAR", "4BAR"}; +static const char *const N_DIV[] = {"1/4", "1/8", "1/16", "1/32", "1/8T", "1/16T", "1/2", "1/1", "2BAR", "4BAR", "1/2T", "1/4T"}; /* 10, 11: appended (1.x) */ /* the delay's TIME (G_DTIME): N_DIV's ten (their values kept), then 1.5.1's dotted ones appended (stored values: * append-only). A list of its own: ARP RATE, SEQ DIV and LFO SYNC keep N_DIV's ten (fx.c delay_samples) */ -static const char *const N_DTIME[] = {"1/4", "1/8", "1/16", "1/32", "8T", "16T", "1/2", "1/1", "2BAR", "4BAR", +static const char *const N_DTIME[] = {"1/4", "1/8", "1/16", "1/32", "1/8T", "1/16T", "1/2", "1/1", "2BAR", "4BAR", "1/8D", "1/16D", "1/4D"}; static const char *const N_SCALE[] = {"CHR", "MAJ", "MIN", "DOR", "MIX", "PEN", "MPEN", "HARM", "PHRY", "LYD", "LOC", "MEL", "BLUES", "WHOLE", "DIMHW", "DIMWH"}; @@ -321,7 +321,7 @@ static int32_t enum_step(const param_desc_t *d, int32_t from, int32_t v) /* #48: the note divisions in the order of their length, longest first (triplets between their neighbours), on the * knobs and the gauges; the stored values (N_DIV, N_SLDIV indices: projects, presets, the editor protocol) stay. * -> the shown order of d's values (index: position, entry: value), 0 = the values' own order */ -static const uint8_t DIV_ORDER[10] = {9, 8, 7, 6, 0, 1, 4, 2, 5, 3}; /* 4BAR 2BAR 1/1 1/2 1/4 1/8 8T 1/16 16T 1/32 */ +static const uint8_t DIV_ORDER[12] = {9, 8, 7, 6, 10, 0, 11, 1, 4, 2, 5, 3}; /* 4BAR 2BAR 1/1 1/2 1/2T 1/4 1/4T 1/8 1/8T 1/16 1/16T 1/32 */ static const uint8_t SLDIV_ORDER[6] = {0, 3, 1, 4, 2, 5}; /* 1/8 8T 1/16 16T 1/32 32T */ static const uint8_t DTIME_ORDER[13] = {9, 8, 7, 6, 12, 0, 10, 1, 11, 4, 2, 5, 3}; /* 4BAR 2BAR 1/1 1/2 1/4D 1/4 1/8D * 1/8 1/16D 8T 1/16 16T 1/32 */ diff --git a/firmware/src/project.c b/firmware/src/project.c index 3890959..b02a666 100644 --- a/firmware/src/project.c +++ b/firmware/src/project.c @@ -943,7 +943,7 @@ static int project_name(uint32_t slot, char *b) { return project_info(slot, b, 0 static uint32_t len48_of(int32_t len, int32_t div) { uint32_t n = (uint32_t)clamp(len, TP[P_SLEN].min, TP[P_SLEN].max), d = (uint32_t)clamp(div, TP[P_SDIV].min, TP[P_SDIV].max); - return n * (d < 6u ? 48u / DIV_DEN[d] : d < 10u ? 48u << (d - 5u) : 48u / DIV_DEN[d % 6u]); /* (fx.c div_samples) */ + return n * (d < 6u ? 48u / DIV_DEN[d] : d < 10u ? 48u << (d - 5u) : d == 10u ? 64u : d == 11u ? 32u : 48u / DIV_DEN[d % 6u]); /* (fx.c div_samples) */ } /* SONG's picture of a pattern (ui_graph.c graph_song): its LEN steps in n = min(LEN, 16) cells (a cell: steps * c * LEN / n .. (c + 1) * LEN / n - 1), 2 bits a cell, cell c at bits 2c: a step weighs 0 (rest, empty, CHANCE 0), diff --git a/firmware/src/ui_fmini.c b/firmware/src/ui_fmini.c index c7b177c..ecd712d 100644 --- a/firmware/src/ui_fmini.c +++ b/firmware/src/ui_fmini.c @@ -143,13 +143,13 @@ static void dly_time_convert(uint32_t to_async) int32_t bd = 0x7FFFFFFF, d; if (to_async) { uint32_t want = (uint32_t)dly_ms((int32_t)cur) * (uint32_t)FS / 1000u; - for (i = 0; i < 10u; i++) { + for (i = 0; i < 12u; i++) { uint32_t s = div_samples(i); d = (int32_t)(s > want ? s - want : want - s) + (dly_div_fits(i) ? 0 : 1000000); if (d < bd) { bd = d; best = i; } } } else { - int32_t want = (int32_t)(div_samples(cur < 10u ? cur : 0u) * 1000u / (uint32_t)FS); + int32_t want = (int32_t)(div_samples(cur < 12u ? cur : 0u) * 1000u / (uint32_t)FS); for (i = 0; i <= 127u; i++) { d = dly_ms((int32_t)i) - want; if (d < 0) d = -d; diff --git a/tests/fmini_app_test.c b/tests/fmini_app_test.c index 541d2eb..7d486af 100644 --- a/tests/fmini_app_test.c +++ b/tests/fmini_app_test.c @@ -943,19 +943,19 @@ int main(int argc, char **argv) if (dly_fits() != (div_samples(7) < DLY_LEN)) { printf("A-SYNC: the line's fit\n"); return 1; } song.g[G_DRREV] = 0; if (!dly_fits()) { printf("A-SYNC: 1/4 fits\n"); return 1; } - { /* the knob shows only the values that fit: at 60 BPM (quarter 1 s) 1/2 and longer do not fit */ + { /* the knob shows only the values that fit: at 50 BPM 1/2T and 1/2 do not fit */ int16_t b0 = song.g[G_BPM]; uint8_t c0 = song.g[G_CLOCK]; - song.g[G_BPM] = 60; song.g[G_CLOCK] = 0; - if (dly_div_fits(6) || !dly_div_fits(0) || !dly_div_fits(5)) { printf("A-SYNC: the fit at 60 BPM\n"); return 1; } - if (async_turn(0, -1) != 0 || async_turn(0, -3) != 0) { printf("A-SYNC: 1/2 shown at 60 BPM (%d)\n", async_turn(0, -1)); return 1; } - if (async_turn(0, 1) != 1 || async_turn(1, 1) != 4) { printf("A-SYNC: the next fitting value\n"); return 1; } + song.g[G_BPM] = 50; song.g[G_CLOCK] = 0; /* a quarter 1.2 s: 1/2T (1.6 s) and 1/2 do not fit */ + if (dly_div_fits(6) || !dly_div_fits(0) || !dly_div_fits(5)) { printf("A-SYNC: the fit at 50 BPM\n"); return 1; } + if (async_turn(0, -1) != 0 || async_turn(0, -3) != 0) { printf("A-SYNC: 1/2T shown at 50 BPM (%d)\n", async_turn(0, -1)); return 1; } + if (async_turn(0, 1) != 11 || async_turn(11, 1) != 1 || async_turn(1, 1) != 4) { printf("A-SYNC: the next fitting value\n"); return 1; } song.g[G_BPM] = b0; song.g[G_CLOCK] = c0; } { /* the TYPE knob: A-SYNC second in the order (its gauge), and the TIME keeps its length across the change */ int8_t fp = fmg_force_page; uint8_t fx0 = fmg_fx; song.g[G_DTIME] = 0; song.g[G_DRREV] = 65; fmg_force_page = 8; fmg_fx = 2; fmg_turn(8, 1, 1, EN_K1 + 1); - if (song.g[G_DTIME] != 7 || song.g[G_DRREV] < 0 || song.g[G_DRREV] > 9 || fmg_ratio(&GP[G_DTIME], 7) != 142) { + if (song.g[G_DTIME] != 7 || song.g[G_DRREV] < 0 || song.g[G_DRREV] > 11 || fmg_ratio(&GP[G_DTIME], 7) != 142) { printf("A-SYNC: the type knob (%d, time %d)\n", song.g[G_DTIME], song.g[G_DRREV]); return 1; } fmg_turn(8, 1, -1, EN_K1 + 1); diff --git a/tests/perform_test.c b/tests/perform_test.c index 54ad120..e415b69 100644 --- a/tests/perform_test.c +++ b/tests/perform_test.c @@ -1125,7 +1125,9 @@ static int test_throw(void) for (b = 0; b < 4u; b++) { song.g[G_BPM] = (int16_t)BPM[b]; for (v = 0; v < 13u; v++) { - uint32_t q = FS * 60u / BPM[b], want = v < 10u ? (MUL[v][0] * q) / MUL[v][1] : (MUL[v][0] * q) >> (v == 10u ? 2 : v == 11u ? 3 : 1); + uint32_t q = FS * 60u / BPM[b], want; + if (v == 7u) continue; /* 7 is the TYPE A-SYNC here (its TIME: fmini_app_test), not 1/1 */ + want = v < 10u ? (MUL[v][0] * q) / MUL[v][1] : (MUL[v][0] * q) >> (v == 10u ? 2 : v == 11u ? 3 : 1); song.g[G_DTIME] = (int16_t)v; want = want >= DLY_LEN ? DLY_LEN - 1u : want; ok &= delay_samples() == want; @@ -1157,7 +1159,7 @@ static int test_throw(void) static const uint8_t SHOWN[13] = {9, 8, 7, 6, 12, 0, 10, 1, 11, 4, 2, 5, 3}; int32_t x = 9; ok = d->max == 12 && d->names[1][0] == '1' && d->names[1][2] == '8' && !d->names[1][3] && d->names[9][0] == '4' && - TP[P_ARATE].max == 9 && TP[P_SDIV].max == 9 && TP[P_ARATE].names == TP[P_SDIV].names; + TP[P_ARATE].max == 11 && TP[P_SDIV].max == 11 && TP[P_ARATE].names == TP[P_SDIV].names; for (v = 0; v < 13u; v++) { ok &= x == SHOWN[v]; x = param_turn(d, x, 1); diff --git a/tests/ui_test.c b/tests/ui_test.c index 3a53535..87110b6 100644 --- a/tests/ui_test.c +++ b/tests/ui_test.c @@ -7357,7 +7357,7 @@ static int test_div_order(void) uint32_t prev = 0xFFFFFFFFu, len; for (n = 0; n < 40; n++) v = param_turn(d, v, -1); for (n = 0; n <= d->max - d->min; n++) { - len = d->names == N_SLDIV ? 1000000u / SL_DEN[v] : v >= 10 ? (beat_samples() * 3u) >> DIV_DOT[v - 10] : + len = d->names == N_SLDIV ? 1000000u / SL_DEN[v] : d->names == N_DTIME && v >= 10 ? (beat_samples() * 3u) >> DIV_DOT[v - 10] : div_samples((uint32_t)v); /* (TIME's dotted ones, 1.5.1: fx.c delay_samples) */ if (!(len < prev && enum_rank(d, v) == d->min + n && !((seen >> v) & 1))) { printf(" %s: %s (value %d, place %d, length %u) after %u\n", d->label, d->names[v], (int)v, @@ -7370,10 +7370,10 @@ static int test_div_order(void) } ok &= seen == (1 << (d->max - d->min + 1)) - 1; } - ok &= str_eq(N_DIV[2], "1/16") && str_eq(N_DIV[4], "8T") && str_eq(N_DIV[9], "4BAR") && TP[P_SDIV].def == 2; + ok &= str_eq(N_DIV[2], "1/16") && str_eq(N_DIV[4], "1/8T") && str_eq(N_DIV[9], "4BAR") && TP[P_SDIV].def == 2; ok &= param_turn(&TP[P_SDIV], 2, 1) == 5 && param_turn(&TP[P_SDIV], 2, -1) == 4 && /* 1/16: right 16T, left 8T */ param_turn(&TP[P_SDIV], 3, 1) == 3 && param_turn(&TP[P_SDIV], 9, -1) == 9 && /* the ends hold */ - param_turn(&TP[P_SDIV], 2, -6) == 8 && param_turn(&TP[P_SDIV], 2, 40) == 3; /* 6 left: 2BAR; far: clamped */ + param_turn(&TP[P_SDIV], 2, -6) == 6 && param_turn(&TP[P_SDIV], 2, 40) == 3; /* 6 left: 1/2; far: clamped */ bad += check("#48 DIV / RATE / TIME / SLICER RATE step longest -> shortest, every value once, the ends hold", ok); ok = 1; /* the real knob on the pages that show them, the gauge follows */ for (id = 0; id < NPAGES; id++) diff --git a/web/editor.html b/web/editor.html index bf66704..29329ad 100644 --- a/web/editor.html +++ b/web/editor.html @@ -1659,7 +1659,7 @@ function fromPerc(pt, engines, pe0) { const engineLabel = (engines, e) => (e === 1 && (engines || [])[1] === "-" ? "FM6" : (engines || [])[e] ?? String(e)); function makeMockDevice(opt = {}) { - const NONOFF = ["OFF", "ON"], NDIV = ["1/4", "1/8", "1/16", "1/32", "8T", "16T", "1/2", "1/1", "2BAR", "4BAR"], NGO = ["--", "GO"], NDASH = ["--"]; + const NONOFF = ["OFF", "ON"], NDIV = ["1/4", "1/8", "1/16", "1/32", "1/8T", "1/16T", "1/2", "1/1", "2BAR", "4BAR", "1/2T", "1/4T"], NGO = ["--", "GO"], NDASH = ["--"]; const D = (label, fmt, min, max, def, names = null, unit = "") => ({ label, fmt, min, max, def, names, unit }); const E = (label, names, def) => D(label, F.ENUM, 0, names.length - 1, def, names); const MSRC = ["OFF", "LFO", "ENV", "VEL", "KEY", "RAND", "MODW", "AT", "EXPR", "S&H", "SLEW"]; /* (append-only: S&H SLEW, #132) */ @@ -1682,7 +1682,7 @@ function makeMockDevice(opt = {}) { ]; const GP = [ D("BPM", F.BPM, 40, 240, 120), D("SWG", F.PCT, 0, 100, 0), E("CLK", ["INT", "USB", "TRS"], 0), D("TUNE", F.INT, -50, 50, 0), - E("TIME", [...NDIV, "1/8D", "1/16D", "1/4D"], 1), D("FDBK", F.PCT, 0, 120, 60), D("COLR", F.PCT, 0, 127, 70), D("MIX", F.PCT, 0, 127, 90), + E("TIME", [...NDIV.slice(0, 10), "1/8D", "1/16D", "1/4D"], 1), D("FDBK", F.PCT, 0, 120, 60), D("COLR", F.PCT, 0, 127, 70), D("MIX", F.PCT, 0, 127, 90), D("SIZE", F.PCT, 0, 127, 90), D("DAMP", F.PCT, 0, 127, 60), D("CRT", F.LFOHZ, 0, 127, 40), D("CDP", F.PCT, 0, 127, 60), E("MIDI", ["USB", "TRS"], 0), E("SYNC", NDASH, 0), E("ROUT", ["CH1-4", "SEL", "CH5-8", "CH9-12", "CH13-16", "TRACK"], 0), D("CPU", F.INT, 0, 0, 0), D("SLOT", F.INT, 1, 4, 1), E("NAME", NDASH, 0), E("LOAD", NGO, 0), E("SAVE", NGO, 0), @@ -2411,9 +2411,13 @@ function aliasOf(names, i) { /* #48: note divisions (1/4, 8T, 2BAR, 1.5.1's dotted 1/8D ...) are listed by length, longest first, as the device's knobs step them (src/params.c enum_order); the values stay. Any other list: in value order. -> d's values in the order shown */ -function divLength(n) { - const m = /^(\d+)\/(\d+)(D?)$/.exec(n) || /^(\d+)(T|BAR)$/.exec(n); - return !m ? null : m[2] === "BAR" ? +m[1] : m[2] === "T" ? 2 / 3 / +m[1] : (m[3] ? 1.5 : 1) * +m[1] / +m[2]; +function divLength(n) { /* in whole notes: 1/8 = 0.125, 1/8T = 1/12, 1/8D = 3/16, 2BAR = 2 */ + const t = /^(\d+)T$/.exec(n); /* the SLICER's 8T 16T 32T */ + if (t) return 2 / 3 / +t[1]; + const m = /^(\d+)\/(\d+)(D|T)?$/.exec(n) || /^(\d+)(BAR)$/.exec(n); + if (!m) return null; + if (m[2] === "BAR") return +m[1]; + return (m[3] === "T" ? 2 / 3 : m[3] === "D" ? 1.5 : 1) * +m[1] / +m[2]; } function enumShown(d) { const vals = []; diff --git a/web/test_web.mjs b/web/test_web.mjs index d7eb556..80b2cd3 100644 --- a/web/test_web.mjs +++ b/web/test_web.mjs @@ -463,14 +463,14 @@ function mockTables() { sd.slice(0, 5).forEach((x) => console.log(" SHOWN " + JSON.stringify(x) + " editor " + JSON.stringify(shown((x[0] ? T.GP : T.TP)[x[1]])))); ok(fw.SHOWN && fw.SHOWN.length > 20 && !sd.length, `editor: enum lists in the device's knob order (${fw.SHOWN ? fw.SHOWN.length : 0} lists)`); const div = T.TP.find((d) => d.label === "DIV"), slr = T.TP.filter((d) => d.label === "RATE" && d.fmt === E.F.ENUM); - ok(shown(div).join() === "4BAR,2BAR,1/1,1/2,1/4,1/8,8T,1/16,16T,1/32" && + ok(shown(div).join() === "4BAR,2BAR,1/1,1/2,1/2T,1/4,1/4T,1/8,1/8T,1/16,1/16T,1/32" && slr.some((d) => shown(d).join() === "1/8,8T,1/16,16T,1/32,32T") && div.names[2] === "1/16", "editor: #48 DIV / RATE / TIME longest first (values unchanged: 2 is still 1/16)"); const tim = T.GP.filter((d) => d.label === "TIME"); - ok(tim.length === 1 && shown(tim[0]).join() === "4BAR,2BAR,1/1,1/2,1/4D,1/4,1/8D,1/8,1/16D,8T,1/16,16T,1/32" && - tim[0].names.slice(0, 10).join() === "1/4,1/8,1/16,1/32,8T,16T,1/2,1/1,2BAR,4BAR" && tim[0].names[10] === "1/8D" && - shown(div).length === 10, - "editor: 1.5.1 delay TIME: 1/8D 1/16D 1/4D appended (10..12), shown by length; DIV keeps its ten"); + ok(tim.length === 1 && shown(tim[0]).join() === "4BAR,2BAR,1/1,1/2,1/4D,1/4,1/8D,1/8,1/16D,1/8T,1/16,1/16T,1/32" && + tim[0].names.slice(0, 10).join() === "1/4,1/8,1/16,1/32,1/8T,1/16T,1/2,1/1,2BAR,4BAR" && tim[0].names[10] === "1/8D" && + shown(div).length === 12, + "editor: 1.5.1 delay TIME: 1/8D 1/16D 1/4D appended (10..12), shown by length; DIV: twelve (1/2T, 1/4T appended)"); const swg = [T.TP, T.GP].flatMap((tb) => tb.filter((d) => d.label === "SWG")); ok(swg.length === 3 && swg.every((d) => E.fmtValue(d, 100)[0] === "100" && E.fmtValue(d, 50)[0] === "50") && E.fmtValue({ fmt: swg[0].fmt, min: 0, max: 127 }, 127)[0] === "100" && E.fmtValue({ fmt: swg[0].fmt, min: 0, max: 127 }, 64)[0] === "50",