diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index ea82138..25deab4 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -89,7 +89,7 @@ body: attributes: label: Version description: The release you flashed (e.g. from its file name), or the commit if you built it yourself. - placeholder: v0.7.1 + placeholder: v0.7.2 validations: required: true diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index 1e91e01..ec96ebe 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -76,6 +76,6 @@ body: attributes: label: Version description: The release you are using, if the request is about something you've seen on hardware. - placeholder: v0.7.1 + placeholder: v0.7.2 validations: required: false diff --git a/README.md b/README.md index 5dcc88b..2da3582 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ REMEMBER: There is no way to go back to the base firmware once you've flashed it ## Status -**v0.7.1, pre-release for beta testing.** Report problems with the bug form under [Issues](https://github.com/Worldwave/Wakes/issues). +**v0.7.2, pre-release for beta testing.** Report problems with the bug form under [Issues](https://github.com/Worldwave/Wakes/issues). ## Flashing diff --git a/config/midi.ini b/config/midi.ini index 5ef507a..5998845 100644 --- a/config/midi.ini +++ b/config/midi.ini @@ -202,6 +202,7 @@ t_bias = cc 16 jitter = cc 85 deja_vu = cc 31 ; t SHIFT page +gtlt = cc 89 ; t gate tilt gate_length = cc 17 gate_length_random = cc 86 length = cc 103 ; stepped diff --git a/docs/DEFAULTS.md b/docs/DEFAULTS.md index 760a93b..4a0c5cb 100644 --- a/docs/DEFAULTS.md +++ b/docs/DEFAULTS.md @@ -133,7 +133,7 @@ A ROTC on MARBLES now leaves the drive alone, deliberately. | F2 | t BIAS `[D]` | 0…1, detent | centre | centre | | | F3 | JITTER `[C]` | 0…1 | 0 | 0 | | | F4 | DEJA VU `[H]` | 0…1, detent | centre = locked loop | centre | one value, shared with the X page | -| t SHIFT F1 | (free) | — | — | — | | +| t SHIFT F1 | GTLT (#20) | −1…+1, detent | centre = off | centre | t1 / t3 gate height; TRIG ignores it | | t SHIFT F2 | gate length | 0…1 | 0.5 | 0.5 | | | t SHIFT F3 | gate-length randomness | 0…1 | 0 | 0 | | | t SHIFT F4 | LENGTH `[I]` | 1…16 steps | 8 | 8 | one value, shared with the X page | diff --git a/docs/MIDI.md b/docs/MIDI.md index 4d739b1..5ebed7e 100644 --- a/docs/MIDI.md +++ b/docs/MIDI.md @@ -56,7 +56,7 @@ Each CC reads the way its parameter works -- the same rule Marbles' INTELLIGENT uses for its outputs: - **centred** parameters, whose middle is "nothing happening" (FREQUENCY, the attenuverters, - RATE, BIAS, DEJA VU, STEPS): **64 = no change**, 0 and 127 = half a fader's travel down and + RATE, BIAS, DEJA VU, GTLT, STEPS): **64 = no change**, 0 and 127 = half a fader's travel down and up -- so with the fader on its centre, the CC sweeps the whole range, end to end. - **one-sided** parameters (LPG colour and decay, LEVEL, JITTER, gate length, SPREAD, and the stepped ones): **0 = no change**, 127 = a whole travel up -- so with the fader at 0, the CC @@ -173,6 +173,7 @@ half still works. | 16 | 48 | t BIAS | | 85 | | JITTER | | 31 | 63 | DEJA VU | +| 89 | | GTLT, the t gate tilt (MARBLES t SHIFT F1) | | 17 | 49 | gate length | | 86 | | gate length randomness | | 103 | | LENGTH | diff --git a/docs/UI-PAGES.md b/docs/UI-PAGES.md index f097d3a..89e9c48 100644 --- a/docs/UI-PAGES.md +++ b/docs/UI-PAGES.md @@ -239,7 +239,7 @@ and one SETTINGS page (Y) reached the same way as on PLAITS and identical from e | layer | how you get there | F1 | F2 | F3 | F4 | |---|---|---|---|---|---| | **t BASE** | T2 | **RATE** `[A]` (±5 oct) | **t BIAS** `[D]` * | **JITTER** `[C]` | **DEJA VU** `[H]` * | -| **t SHIFT** | T2, then `••` held | *(free)* | **gate length** | **gate length randomness** | **LENGTH** `[I]` | +| **t SHIFT** | T2, then `••` held | **GTLT** † * | **gate length** | **gate length randomness** | **LENGTH** `[I]` | | **X BASE** | T3 | **SPREAD** `[K]` | **X BIAS** `[L]` * | **STEPS** `[M]` * | **DEJA VU** `[H]` * | | **X SHIFT** | T3, then `••` held | *(free)* | *(free)* | *(free)* | **LENGTH** `[I]` | | **SETTINGS (Y)** | `••` double-tap | **Y SPREAD** | **Y BIAS** * | **Y STEPS** * | **Y divider** (12 steps) | @@ -247,6 +247,12 @@ and one SETTINGS page (Y) reached the same way as on PLAITS and identical from e \* 10 % centre detent. **DEJA VU's centre is LOCK**, not its bottom: below the centre the loop is recorded, above it the loop is replayed, at it the loop is frozen. +† **GTLT** (#20), Wakes' own: tilts the HEIGHT of t1's and t3's gates around t2, which it never +touches. At its detent it is off. Just past the detent both drop steeply to 50 %; towards + t1 +falls to 0 % and t3 returns to 100 %, towards − the reverse. **TRIG ignores it** — a t output on +TRIG fires on every gate whatever GTLT says — so it only shapes t outputs routed to LEVEL, FM, +TIMBRE, MORPH or HARMONICS. + - **F4 is ONE control on both pages, not two that are kept in step.** Marbles has one DEJA VU knob and one LENGTH knob, so the X page's F4 addresses the t page's value rather than mirroring it. Mirroring made the two pages keep separate pickup state, which could put F4 @@ -401,7 +407,7 @@ is the most predictable starting point, and t1 / t3 are then yours to route. | | | |---|---| -| **model row, BASE** | **Marbles' own output LEDs**: on the t page T1–T3 are the t1–t3 gates; on the X page they are \|X1\|…\|X3\| against the selected range. **T4 is always \|Y\|.** Moving a fader shows that page's four values instead, for 1.2 s. | +| **model row, BASE** | **Marbles' own output LEDs**: on the t page T1–T3 are the t1–t3 gates, each lit at its GTLT height (0 % shows as 8 %); on the X page they are \|X1\|…\|X3\| against the selected range. **T4 is always \|Y\|.** Moving a fader shows that page's four values instead, for 1.2 s. | | **model row, SHIFT / SETTINGS** | that layer's four values; free faders read dark. SETTINGS breathes. | | **play row** | **Marbles' clock** in front, stepping once per t2 tick from the `••` end, with the dB meter behind it at ~10 %. (On PLAITS it is the other way round.) | @@ -420,7 +426,6 @@ that has nothing on it. This is the supply side for M5 and M6. | where | what | |---|---| | PLAITS | a short `••` + T1, T2, T3 or T4 (held, each is UNPATCH) | -| MARBLES | t SHIFT F1 | | MARBLES | X SHIFT F1, F2, F3 | | MARBLES | t SHIFT T4 | | MARBLES | `••` + FFWD / RWD on the t page and on SETTINGS | diff --git a/docs/UI-SPEC.md b/docs/UI-SPEC.md index f2b0e8d..a41190a 100644 --- a/docs/UI-SPEC.md +++ b/docs/UI-SPEC.md @@ -1,10 +1,23 @@ -# wakes-sp1 — UI specification v0.16 +# wakes-sp1 — UI specification v0.17 > **For the flat control map — every control on every page, with nothing else in the way — > read `docs/UI-PAGES.md`.** This file is the design record: why each decision went the way it > did, what was rejected, and what is still open. `docs/MARBLES-SETTINGS.md` is the same split > for Marbles' models, ranges and scales. +v0.17 — 2026-10-06: **GTLT, the t gate tilt, on MARBLES t SHIFT F1** (#20, Adara). Wakes' own +parameter: bipolar with a 10 % centre detent, where it does nothing. Just past the detent t1's and +t3's gates drop steeply to half height; towards + t1 falls to 0 and t3 returns to full, towards − +the reverse. t2 is never touched. A gate stays 0 V / +5 V — +5 V is the positive maximum of every +destination a t output can reach — and GTLT scales the +5 V; the attenuverters and fader / CC +positions do the rest. **TRIG ignores GTLT**, so rhythm stays predictable. Unsmoothed. MIDI: CC 89, +7-bit, centred. Costs nothing per sample: the gain is folded into the routing once per audio block. +**Pickup gets a 3 % lock on every layer change, on both modules** (Adara: a GTLT edit was carrying +into CLOK). After `••` goes down or comes up, a fader's new parameter takes nothing until the fader +has moved 3 % from where the finger is — Plaits' own `POT_STATE_LOCKING` threshold — so the fader's +smoothing tail and a finger still resting on it no longer reach the other layer. Whether the fader +then tracks or catches up is unchanged. + v0.16 — 2026-10-06: **OCTV loses Plaits' LFO range** (#18, Adara). The bottom 1/11 of SETTINGS F1 is now the **full range with no centre detent**: F1 sweeps through C4 without the flat spot and can be set finely around it. The scale quantizer applies there exactly as in the full range. Routing @@ -314,7 +327,8 @@ free-form full-brightness glyph per model, tabulated in `docs/MARBLES-SETTINGS.m half-brightness "other bank" glyphs of v0.9 are gone: Adara found dimmed glyphs hard to tell apart in room light, which is the same finding that took the engine flash's `◐` to 33 %. -**Track row, default: Marbles' own output LEDs.** t page: T1–T3 = t1–t3 gates; X page: +**Track row, default: Marbles' own output LEDs.** t page: T1–T3 = t1–t3 gates, a high gate lit +at its GTLT height (v0.17, #20) with 0 % shown at 8 % so a gate firing TRIG never goes dark; X page: T1–T3 = |X1|–|X3| over the selected range; **T4 = |Y| on both pages.** Stopped, X and Y hold their last voltage (as the module does). Moving a fader shows the page's four values for 1.2 s (bipolar ones as magnitude, as on PLAITS). The page pattern flashes on a page change and @@ -326,7 +340,7 @@ on arriving from PLAITS. |---|---|---| | T1 / T2 / T3 | **t1 / t2 / t3 destination**: none `○○○○` → TRIG `○●●●` → LEVEL `○○●●` → FM `●○○○` → TIMBRE `○●○○` → MORPH `○○●○` → HARMONICS `○○○●`. v0.11: the same glyphs as the X side (Adara) — the counting bar v0.10 used on t is gone, and TRIG deliberately shares `○●●●` with the X page's V/Oct | X1 / X2 / X3 destination: FM `●○○○` → TIMBRE `○●○○` → MORPH `○○●○` → HARMONICS `○○○●` → V/Oct `○●●●` → LEVEL `○○●●` (v0.10) → none `○○○○`. One LED under the Plaits fader of that parameter | | T4 | **Y destination** (v0.14) · held 2 s: **UNPATCH Y** | **Y destination** (v0.14) · held 2 s: **UNPATCH Y**. [J] moved to SETTINGS T4 and now covers X **and** Y | -| F1 | reserved | **free** (v0.10) — was SCALE, now `••` + FFWD / RWD | +| F1 | **GTLT** (v0.17, #20): tilts t1's and t3's gate height around t2; 10 % centre detent = off; not on TRIG | **free** (v0.10) — was SCALE, now `••` + FFWD / RWD | | F2 | gate length (Marbles' [E]-hold) | **free** (v0.10) — was X CLOCK; X keeps Marbles' own clocking and there is no control for it | | F3 | gate-length randomness | reserved | | F4 | LENGTH [I] (5 … 16 steps) | LENGTH [I] — the same value | diff --git a/docs/Wakes - Manual.pdf b/docs/Wakes - Manual.pdf index 920283c..fd44f61 100644 Binary files a/docs/Wakes - Manual.pdf and b/docs/Wakes - Manual.pdf differ diff --git a/firmware/VERSION b/firmware/VERSION index 168e269..4cfaf44 100644 --- a/firmware/VERSION +++ b/firmware/VERSION @@ -1,5 +1,5 @@ VERSION_MAJOR = 0 VERSION_MINOR = 7 -PATCHLEVEL = 1 +PATCHLEVEL = 2 VERSION_TWEAK = 0 EXTRAVERSION = diff --git a/firmware/src/main.c b/firmware/src/main.c index 3c60142..c653411 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -1767,6 +1767,7 @@ int main(void) for (int k = 0; k < 4; k++) { sp.mrb_dest[k] = rt.dest[k]; } + sp.mrb_gtlt = rt.gtlt; sp1_synth_set_params(&sp); struct sp1_marbles_params mp; diff --git a/firmware/src/sp1_gtlt.h b/firmware/src/sp1_gtlt.h new file mode 100644 index 0000000..5156a66 --- /dev/null +++ b/firmware/src/sp1_gtlt.h @@ -0,0 +1,58 @@ +/* + * wakes-sp1 — GTLT, the t gate tilt (issue #20). MARBLES t SHIFT F1. + * + * Wakes' own parameter, not Marbles': it scales the HEIGHT of t1's and t3's gates around + * t2, which is never touched. Pure C, no Zephyr; sp1_synth.cc applies it and the host + * suites check it. + * + * tilt 0 (the 10 % centre detent) t1 100 % t3 100 % GTLT disengaged + * just past the detent t1 50 % t3 50 % a steep ramp, SP1_GTLT_RAMP + * towards +1 t1 -> 0 % t3 -> 100 % + * towards -1 t1 -> 100 % t3 -> 0 % + * + * Decided with Adara on the issue (2026-10-06): + * - A gate stays unipolar: 0 V low, +5 V high scaled by this gain. +5 V is already the + * positive maximum of every destination a t output can reach, so no INTELLIGENT range + * is involved; Plaits' attenuverters and the fader / CC positions do the rest. + * - ⚠️ TRIG IGNORES GTLT. A t output routed to TRIG fires on every gate whatever GTLT is + * set to, so rhythm stays predictable. Only the CV destinations (LEVEL, FM, TIMBRE, + * MORPH, HARMONICS) see the gain -- sp1_synth.cc reads TRIG from the raw gate bits. + * - Unsmoothed: it changes once per DMA block, like every other routed parameter. + * + * Cost: none per sample. The gain folds into each route's scale, which sp1_synth.cc + * already resolves once per DMA block; at the detent the gain is exactly 1.0f, so the + * output is bit-identical to a firmware without GTLT. + */ +#ifndef SP1_GTLT_H +#define SP1_GTLT_H + +#include + +/* How much of each half of the (post-detent) travel the drop to 50 % takes. 0.1 of a + * half is ~4.5 % of the whole fader: steep, but a ramp rather than a step, so leaving + * the detent never jumps a routed CV by half its height (Adara: "steep ramp"). */ +#define SP1_GTLT_RAMP 0.1f + +/* The t page's track row draws a high gate at its GTLT height, 0 % shown as this + * brightness (perceptual, before the LED gamma table) rather than dark. 8 % (Adara: 5 % was + * too dim to see at GTLT's extremes). */ +#define SP1_GTLT_LED_FLOOR 0.08f + +/* tilt: -1..+1, 0 = centre (the UI applies the detent). t: 0..2 = t1..t3. */ +static inline float sp1_gtlt_gain(float tilt, int t) +{ + if (t == 1 || tilt == 0.0f) { + return 1.0f; /* t2, or GTLT disengaged: exact */ + } + const float a = tilt < 0.0f ? -tilt : tilt; + if (a < SP1_GTLT_RAMP) { + return 1.0f - 0.5f * (a / SP1_GTLT_RAMP); /* both: 100 % -> 50 % */ + } + float s = (a - SP1_GTLT_RAMP) / (1.0f - SP1_GTLT_RAMP); /* 0..1 past the ramp */ + s = s > 1.0f ? 1.0f : s; + /* + attenuates t1 and pushes t3; - the reverse. */ + const bool falls = (tilt > 0.0f) == (t == 0); + return falls ? 0.5f * (1.0f - s) : 0.5f * (1.0f + s); +} + +#endif /* SP1_GTLT_H */ diff --git a/firmware/src/sp1_marbles_ui.c b/firmware/src/sp1_marbles_ui.c index 1ed343d..9e19039 100644 --- a/firmware/src/sp1_marbles_ui.c +++ b/firmware/src/sp1_marbles_ui.c @@ -8,6 +8,7 @@ #include "sp1_ui_timing.h" #include "sp1_midi.h" /* MIDI CC offsets (M5a) */ +#include "sp1_gtlt.h" /* GTLT's gain curve, for the t LEDs (#20) */ #include #include @@ -21,6 +22,11 @@ * and the bug it is the second half of the fix for, is in sp1_plaits_ui.c -- kept there * because that is where the symptom was, and it is the same number for the same reason. */ #define CATCH_JUMP 0.25f +/* After a layer change a fader must move this far from where the finger is before its new + * parameter takes anything (pot_controller.h, POT_STATE_LOCKING's 0.03). Without it the + * low-pass tail of the last move, and a finger still resting on the fader, carried a GTLT + * edit into CLOK as the "••" came up (#20). Same rule in sp1_plaits_ui.c. */ +#define CATCH_LOCK 0.03f #define DETENT_BIPOLAR 0.10f #define TAP_MAX_MS 300u #define DOUBLE_TAP_MS 400u @@ -104,6 +110,9 @@ static float stored[SP1_MUI_LAYERS][4]; static bool catching[SP1_MUI_LAYERS][4]; static float pos[4]; static float prev[4]; +static float now01[4]; /* this tick's UNFILTERED positions */ +static float lock_ref[4]; /* where each finger was at the change */ +static bool locked[4]; /* inside CATCH_LOCK since that change */ static float shown[4]; /* fader positions last reflected */ static uint32_t show_ms; /* value overlay on BASE, counts down */ @@ -139,7 +148,7 @@ static enum sp1_mui_layer canon(enum sp1_mui_layer l, int i) static const int8_t midi_dest[SP1_MUI_LAYERS][4] = { [SP1_MUI_T_BASE] = { SP1_MIDI_D_RATE, SP1_MIDI_D_T_BIAS, SP1_MIDI_D_JITTER, SP1_MIDI_D_DEJA_VU }, - [SP1_MUI_T_SHIFT] = { -1, SP1_MIDI_D_GATE_LENGTH, SP1_MIDI_D_GATE_LENGTH_RANDOM, + [SP1_MUI_T_SHIFT] = { SP1_MIDI_D_GTLT, SP1_MIDI_D_GATE_LENGTH, SP1_MIDI_D_GATE_LENGTH_RANDOM, SP1_MIDI_D_LENGTH }, [SP1_MUI_X_BASE] = { SP1_MIDI_D_SPREAD, SP1_MIDI_D_X_BIAS, SP1_MIDI_D_STEPS, -1 }, [SP1_MUI_X_SHIFT] = { -1, -1, -1, -1 }, @@ -208,6 +217,7 @@ static bool is_bipolar(enum sp1_mui_layer l, int i) { switch (l) { case SP1_MUI_T_BASE: return i == 1 || i == 3; + case SP1_MUI_T_SHIFT: return i == 0; /* GTLT (issue #20) */ case SP1_MUI_X_BASE: return i >= 1; case SP1_MUI_Y: return i == 1 || i == 2; default: return false; @@ -215,10 +225,11 @@ static bool is_bipolar(enum sp1_mui_layer l, int i) } /* Faders with nothing bound to them. They read dark and are ignored. X SHIFT F1 (was - * SCALE) and F2 (was X CLOCK) joined the list in M4a -- see the header. */ + * SCALE) and F2 (was X CLOCK) joined the list in M4a -- see the header. t SHIFT F1 left + * it when it became GTLT (issue #20). */ static bool is_reserved(enum sp1_mui_layer l, int i) { - return (l == SP1_MUI_T_SHIFT && i == 0) || (l == SP1_MUI_X_SHIFT && i <= 2); + return l == SP1_MUI_X_SHIFT && i <= 2; } static enum sp1_mui_layer base_of(enum sp1_mui_page p) @@ -233,12 +244,14 @@ static void activate(enum sp1_mui_layer l) prev[i] = pos[i]; CAT(l, i) = fabsf(VAL(l, i) - pos[i]) >= CATCH_MATCH; shown[i] = pos[i]; + lock_ref[i] = now01[i]; + locked[i] = true; } } static void defaults_pages(void) { - stored[SP1_MUI_T_SHIFT][0] = 0.0f; + stored[SP1_MUI_T_SHIFT][0] = 0.5f; /* GTLT on its detent: disengaged */ stored[SP1_MUI_T_SHIFT][1] = 0.5f; /* gate length 128/256 (Marbles) */ stored[SP1_MUI_T_SHIFT][2] = 0.0f; /* no randomness */ stored[SP1_MUI_T_SHIFT][3] = DEF_LENGTH; @@ -333,6 +346,7 @@ void sp1_mui_enter(const uint16_t raw[4], bool fnc) { for (int i = 0; i < 4; i++) { pos[i] = to01(raw[i]); + now01[i] = pos[i]; } fnc_was = fnc; press_dirty = true; /* a "••" already down is not a tap */ @@ -350,7 +364,8 @@ uint32_t sp1_mui_tick(uint32_t elapsed_ms, const uint16_t raw[4], bool valid, if (valid) { for (int i = 0; i < 4; i++) { - pos[i] += (to01(raw[i]) - pos[i]) * FADER_LP; + now01[i] = to01(raw[i]); + pos[i] += (now01[i] - pos[i]) * FADER_LP; } } @@ -402,6 +417,16 @@ uint32_t sp1_mui_tick(uint32_t elapsed_ms, const uint16_t raw[4], bool valid, * rests, and catches up after the port goes (sp1_plaits_ui.c). */ prev[i] = pos[i]; CAT(active, i) = fabsf(*s - pos[i]) >= CATCH_MATCH; + } else if (locked[i]) { + /* Since the layer change: the filter's tail and a resting finger + * are not movement (CATCH_LOCK). Tracking or catching up was decided + * at the change and is NOT re-decided here: re-checking against a + * fader that has already moved would put a tracking fader into + * catch-up and leave its value short of the fader. */ + prev[i] = pos[i]; + if (fabsf(now01[i] - lock_ref[i]) > CATCH_LOCK) { + locked[i] = false; + } } else if (!CAT(active, i)) { *s = pos[i]; prev[i] = pos[i]; @@ -678,9 +703,19 @@ void sp1_mui_params(struct sp1_marbles_params *p) p->y_range = range; /* one [J] (M4e) */ } +/* GTLT (issue #20): -1..+1 past the 10 % detent, exactly 0 inside it. The curve and + * the TRIG exemption are in sp1_gtlt.h / sp1_synth.cc. Its CC is centred, like t BIAS: + * in `sum` it offsets the post-detent value, so a CC alone can engage it. */ +static float gtlt_tilt(void) +{ + return 2.0f * (clamp01(detent(stored[SP1_MUI_T_SHIFT][0], DETENT_BIPOLAR) + + mo(SP1_MIDI_D_GTLT)) - 0.5f); +} + void sp1_mui_routing(struct sp1_mui_routing *out) { *out = route; + out->gtlt = gtlt_tilt(); } float sp1_mui_bpm(void) @@ -703,9 +738,17 @@ static void leds_of(enum sp1_mui_layer l, uint8_t out[4]) if (base && show_ms == 0u) { /* Marbles' own output LEDs; T4 = Y on both pages. */ if (page == SP1_MUI_PAGE_T) { + /* A high gate shows its HEIGHT under GTLT (#20), on every output whatever + * it is routed to, from 8 % for a 0 % gate up to full (Adara: the floor is + * "signal strength 0", so a gate still firing TRIG never goes dark). Low + * gates are off. On the detent every gain is 1, so this is the old + * on/off display exactly. */ const uint8_t g = sp1_marbles_last_gates(); + const float tilt = gtlt_tilt(); for (int i = 0; i < 3; i++) { - out[i] = (g & (1u << i)) ? 255u : 0u; + const float x = SP1_GTLT_LED_FLOOR + + (1.0f - SP1_GTLT_LED_FLOOR) * sp1_gtlt_gain(tilt, i); + out[i] = (g & (1u << i)) ? (uint8_t)(x * 255.0f + 0.5f) : 0u; } } else { for (int i = 0; i < 3; i++) { diff --git a/firmware/src/sp1_marbles_ui.h b/firmware/src/sp1_marbles_ui.h index 6b0cd1b..6748d90 100644 --- a/firmware/src/sp1_marbles_ui.h +++ b/firmware/src/sp1_marbles_ui.h @@ -7,7 +7,7 @@ * * ---- pages and layers (F1 / F2 / F3 / F4) ---- * t page BASE RATE [A] t BIAS [D]* JITTER [C] DEJA VU [H]* - * t page SHIFT (reserved) gate length gate length rand LENGTH [I] + * t page SHIFT GTLT* gate length gate length rand LENGTH [I] * X page BASE SPREAD [K] X BIAS [L]* STEPS [M]* DEJA VU [H]* * X page SHIFT (reserved) (reserved) (reserved) LENGTH [I] * SETTINGS (Y) Y SPREAD Y BIAS* Y STEPS* Y RATE (12) @@ -24,7 +24,9 @@ * * ---- routing into Plaits (applied only while the clock runs; sp1_synth) ---- * t1-t3 one destination each (t page SHIFT T1-T3), the gate read as 0 / +5 V: - * TRIG, LEVEL, FM, TIMBRE, MORPH, HARMONICS or none + * TRIG, LEVEL, FM, TIMBRE, MORPH, HARMONICS or none. GTLT (t SHIFT F1, + * issue #20) scales t1's and t3's +5 V around t2 on every destination + * except TRIG -- see sp1_gtlt.h * X1-X3, Y one destination each (X page SHIFT T1-T3, SETTINGS T1): FM, TIMBRE, * MORPH, HARMONICS, V/Oct, LEVEL or none * Scaling is Plaits' own CV calibration (plaits/settings.cc, per 5 V): V/Oct and FM @@ -35,7 +37,8 @@ * * ---- track row ---- * BASE: Marbles' output LEDs -- T1-T3 = t1-t3 gates (t page) or |X1-X3| (X page), - * T4 = |Y| always. Moving a fader shows the page's four values for 1.2 s instead. + * T4 = |Y| always. A high gate shows its GTLT height, 0 % as 8 % (sp1_gtlt.h). + * Moving a fader shows the page's four values for 1.2 s instead. * SHIFT: the SHIFT layer's values. SETTINGS: the Y values, breathing. */ #ifndef SP1_MARBLES_UI_H @@ -74,6 +77,7 @@ enum sp1_mui_dest { struct sp1_mui_routing { uint8_t t_dest[3]; /* t1, t2, t3: enum sp1_mui_dest (TRIG by default) */ uint8_t dest[4]; /* X1, X2, X3, Y: enum sp1_mui_dest */ + float gtlt; /* GTLT, t SHIFT F1: -1..+1, 0 = detent (sp1_gtlt.h) */ }; /* Once, at boot: everything to the defaults (see sp1_mui_rip). */ diff --git a/firmware/src/sp1_plaits_ui.c b/firmware/src/sp1_plaits_ui.c index 5057a1b..51ad850 100644 --- a/firmware/src/sp1_plaits_ui.c +++ b/firmware/src/sp1_plaits_ui.c @@ -35,6 +35,11 @@ * been chased twice (M4a, M4e). */ #define CATCH_JUMP 0.25f /* of travel, in one tick: a sampling artefact */ #define CATCH_MATCH 0.005f /* pot_controller.h: close enough to track */ +/* After a layer change a fader must move this far from where the finger is before its new + * parameter takes anything (pot_controller.h, POT_STATE_LOCKING's 0.03). Without it the + * low-pass tail of the last move, and a finger still resting on the fader, carried a SHIFT + * edit into BASE as the "••" came up (found on MARBLES, GTLT -> CLOK, #20). */ +#define CATCH_LOCK 0.03f #define DETENT_BIPOLAR 0.10f /* Adara: 10 % of travel */ #define DETENT_FREQ 0.05f /* Adara: 5 % for FREQUENCY */ /* ...and 10 % while MIDI is active (Adara, M5a test notes): with a keyboard playing through @@ -63,6 +68,9 @@ static float stored[SP1_PUI_LAYERS][4]; /* pot-space 0..1, before detents static bool catching[SP1_PUI_LAYERS][4]; static float pos[4]; /* smoothed physical fader, 0..1 */ static float prev[4]; /* catch-up reference, per fader */ +static float now01[4]; /* this tick's UNFILTERED positions */ +static float lock_ref[4]; /* where each finger was at the change */ +static bool locked[4]; /* inside CATCH_LOCK since that change */ static enum sp1_pui_layer page = SP1_PUI_BASE; static enum sp1_pui_layer active = SP1_PUI_BASE; @@ -170,6 +178,8 @@ static void activate(enum sp1_pui_layer l) for (int i = 0; i < 4; i++) { prev[i] = pos[i]; catching[l][i] = fabsf(stored[l][i] - pos[i]) >= CATCH_MATCH; + lock_ref[i] = now01[i]; + locked[i] = true; } } @@ -223,6 +233,7 @@ void sp1_pui_enter(const uint16_t raw[4]) { for (int i = 0; i < 4; i++) { pos[i] = to01(raw[i]); + now01[i] = pos[i]; } if (!base_seeded) { base_seeded = true; @@ -243,6 +254,7 @@ void sp1_pui_resume(const uint16_t raw[4], bool fnc) { for (int i = 0; i < 4; i++) { pos[i] = to01(raw[i]); + now01[i] = pos[i]; } pickup_all(); fnc_was = fnc; @@ -259,7 +271,8 @@ uint32_t sp1_pui_tick(uint32_t elapsed_ms, const uint16_t raw[4], bool valid, if (valid) { for (int i = 0; i < 4; i++) { - pos[i] += (to01(raw[i]) - pos[i]) * FADER_LP; + now01[i] = to01(raw[i]); + pos[i] += (now01[i] - pos[i]) * FADER_LP; } } @@ -315,6 +328,18 @@ uint32_t sp1_pui_tick(uint32_t elapsed_ms, const uint16_t raw[4], bool valid, catching[active][i] = fabsf(*s - pos[i]) >= CATCH_MATCH; continue; } + if (locked[i]) { + /* Since the layer change: the filter's tail and a resting finger + * are not movement (CATCH_LOCK). Tracking or catching up was decided + * at the change and is NOT re-decided here: re-checking against a + * fader that has already moved would put a tracking fader into + * catch-up and leave its value short of the fader. */ + prev[i] = pos[i]; + if (fabsf(now01[i] - lock_ref[i]) > CATCH_LOCK) { + locked[i] = false; + } + continue; + } if (!catching[active][i]) { *s = pos[i]; prev[i] = pos[i]; diff --git a/firmware/src/sp1_synth.cc b/firmware/src/sp1_synth.cc index bffc6db..7bf00fe 100644 --- a/firmware/src/sp1_synth.cc +++ b/firmware/src/sp1_synth.cc @@ -9,6 +9,7 @@ #include "sp1_synth.h" #include "sp1_marbles.h" #include "sp1_marbles_ui.h" +#include "sp1_gtlt.h" #if defined(CONFIG_SP1_MIDI) #include "sp1_midi.h" #endif @@ -309,13 +310,19 @@ inline void StageBlockAny(bool limit, bool drive, const float* in, int16_t* out, // list keeps the old summation order (t1..t3, then X1..X3, Y) and the same products, so // the sums are bit-identical to the per-block switches this replaces; the cost grows // with the number of routed outputs (a patch setting), never with modulation. +// +// GTLT (issue #20) is a gain on t1's and t3's scale, taken here, so it costs nothing per +// sample. At its detent the gain is exactly 1.0f and the products are unchanged. +// ⚠️ TRIG ignores it by design (Adara): TRIG reads the raw gate bits through trig_mask, +// and AddRoute never sees a TRIG route. enum RouteDest { kRouteNote, kRouteFm, kRouteTimbre, kRouteMorph, kRouteHarm, kRouteLevel, kRouteCount }; struct Route { uint8_t source; // 0..2 = t1..t3 (a gate, 0 or +5 V), 3..6 = X1..X3, Y uint8_t dest; // RouteDest - float scale; // per volt, as Plaits' own CV calibration (see kVoltPerOct) + float scale; // per volt, as Plaits' own CV calibration (see kVoltPerOct), + // x GTLT's gain on t1 / t3 }; struct Routing { @@ -324,7 +331,11 @@ struct Routing { bool fm_patched, timbre_patched, morph_patched, harm_patched, level_routed; }; -void AddRoute(Routing* r, int source, int dest) { +// `tilt` is GTLT for t1..t3 and 0 for X / Y (gain exactly 1). The gain is worked out +// in here, not in the caller: noinline, because this runs a few times per DMA block and +// GTLT's extra code, inlined, grew sp1_synth_render by ~1 KB and reshuffled its +// per-Plaits-block loop. Out of line, the render only passes one more float (issue #20). +__attribute__((noinline)) void AddRoute(Routing* r, int source, int dest, float tilt) { float scale; RouteDest d; switch (dest) { @@ -338,7 +349,7 @@ void AddRoute(Routing* r, int source, int dest) { } r->route[r->count].source = static_cast(source); r->route[r->count].dest = static_cast(d); - r->route[r->count].scale = scale; + r->route[r->count].scale = scale * sp1_gtlt_gain(tilt, source); ++r->count; } @@ -347,11 +358,11 @@ Routing ResolveRouting(const sp1_synth_params& c) { for (int t = 0; t < 3; ++t) { // A t output is a gate: V/Oct is not one of its destinations (as before). if (c.mrb_t_dest[t] != SP1_DEST_VOCT) { - AddRoute(&r, t, c.mrb_t_dest[t]); + AddRoute(&r, t, c.mrb_t_dest[t], c.mrb_gtlt); } } for (int k = 0; k < 4; ++k) { - AddRoute(&r, 3 + k, c.mrb_dest[k]); + AddRoute(&r, 3 + k, c.mrb_dest[k], 0.0f); } return r; } diff --git a/firmware/src/sp1_synth.h b/firmware/src/sp1_synth.h index 0acf7af..89379d2 100644 --- a/firmware/src/sp1_synth.h +++ b/firmware/src/sp1_synth.h @@ -85,6 +85,10 @@ struct sp1_synth_params { * (sp1_marbles_running); stopped, every one of these inputs is unpatched. */ uint8_t mrb_t_dest[3]; /* t1, t2, t3: enum sp1_mui_dest values */ uint8_t mrb_dest[4]; /* X1, X2, X3, Y: enum sp1_mui_dest values */ + /* GTLT (issue #20, sp1_gtlt.h): -1..+1, 0 = centre = disengaged, so a zeroed + * params struct keeps every gate at full height. Scales t1 / t3 on CV + * destinations only; TRIG ignores it. */ + float mrb_gtlt; /* ---- hold the note between TRIGs (M4e, Adara) ---- * Set while a FREQUENCY scale is selected. `note` above is already quantized by * sp1_pui_params in the main thread; this asks the AUDIO thread to LATCH it at each diff --git a/tools/gen_midi.py b/tools/gen_midi.py index 1888a3d..709c9a6 100644 --- a/tools/gen_midi.py +++ b/tools/gen_midi.py @@ -54,6 +54,7 @@ ('marbles', 't_bias', 't BIAS', 'main', 'MARBLES t F2'), ('marbles', 'jitter', 'JITTER', 'main', 'MARBLES t F3'), ('marbles', 'deja_vu', 'DEJA VU', 'main', 'MARBLES t/X F4'), + ('marbles', 'gtlt', 'GTLT (t gate tilt)', 'main', 'MARBLES t SHIFT F1'), ('marbles', 'gate_length', 'gate length', 'main', 'MARBLES t SHIFT F2'), ('marbles', 'gate_length_random', 'gate length randomness', 'main', 'MARBLES t SHIFT F3'), ('marbles', 'length', 'LENGTH', 'step', 'MARBLES t SHIFT F4'), @@ -85,7 +86,7 @@ 'fm_attenuverter': 'bi', 'timbre_attenuverter': 'bi', 'morph_attenuverter': 'bi', 'harmonics_attenuverter': 'bi', 'lpg_colour': 'uni', 'lpg_decay': 'uni', 'level': 'uni', 'octave_range': 'uni', 'model': 'uni', - 'rate': 'bi', 't_bias': 'bi', 'jitter': 'uni', 'deja_vu': 'bi', 'gate_length': 'uni', + 'rate': 'bi', 't_bias': 'bi', 'jitter': 'uni', 'deja_vu': 'bi', 'gtlt': 'bi', 'gate_length': 'uni', 'gate_length_random': 'uni', 'length': 'uni', 'spread': 'uni', 'x_bias': 'bi', 'steps': 'bi', 'y_spread': 'uni', 'y_bias': 'bi', 'y_steps': 'bi', 'y_divider': 'uni', } diff --git a/tools/host-tests/README.md b/tools/host-tests/README.md index c1885fa..dfcdf3b 100644 --- a/tools/host-tests/README.md +++ b/tools/host-tests/README.md @@ -6,8 +6,8 @@ proved on a laptop, and because there is exactly one SP-1 (`docs/SAFETY.md`). | | what it links | what it checks | |---|---|---| -| `uitest.c` | `sp1_plaits_ui.c` + `sp1_marbles_ui.c`, with stubs | pages, layers, pickup, detents, rings, glyph uniqueness, scale stepping, the DEJA VU toggles, the V/Oct interlock, both rip wipes, `[J]`, Unpatch eating its own release (`sp1_release_guard.h`) | -| `routetest.cc` | all of Plaits and Marbles (with the overrides applied) + `sp1_synth.cc` + `sp1_marbles.cc` + both UI objects | routing, TRIG edges, the summing clamp, the HARMONICS attenuverter, the FREQUENCY quantizer's note sets, the soft-clip drive, the deferred re-seed, INTELLIGENT's per-channel ranges | +| `uitest.c` | `sp1_plaits_ui.c` + `sp1_marbles_ui.c`, with stubs | pages, layers, pickup, detents, rings, glyph uniqueness, scale stepping, the DEJA VU toggles, the V/Oct interlock, both rip wipes, `[J]`, GTLT on t SHIFT F1, Unpatch eating its own release (`sp1_release_guard.h`) | +| `routetest.cc` | all of Plaits and Marbles (with the overrides applied) + `sp1_synth.cc` + `sp1_marbles.cc` + both UI objects | routing, TRIG edges, the summing clamp, the HARMONICS attenuverter, the FREQUENCY quantizer's note sets, the soft-clip drive, the deferred re-seed, INTELLIGENT's per-channel ranges, GTLT's curve and TRIG exemption | | `miditest.cc` | the same + `sp1_midi.cc`, against the shipped `config/midi.ini` with its `pickup` set to `sum` | MIDI in (M5a): note priority and legato off, the LEVEL hand-back through a real LPG, sustain, 7- and 14-bit CCs read by polarity, the catch-up across an engine change, smoothing, pitch bend and RPN 0, channel filter, placement inside the audio block, queue overflow, disconnect to neutral, the quantizer bypass, stepped targets, Marbles offsets | | `miditest_pickup.cc` | the same, against the shipped script with `pickup` set to `shared`, then `takeover`: two binaries, `miditest_pickup_shared` and `miditest_pickup_takeover` | a CC as a second hand on the fader's value: its first value only a reference, Plaits' catch-up both ways between CC and fader, a rip under a CC, a page not on show, Marbles not on show, MODEL still an offset, a disconnect leaving the values; takeover's resting faders and their catch-up after unplugging | | `miditest_clock.cc` | the same as `miditest.cc`, with real cycle-counter stamps on every tick | MIDI clock and transport into Marbles (M5b): tempo and position from ticks, ±1 ms of USB jitter, a stopped clock waiting, Start arming beat 1 on its own Plaits block, Marbles' beats at the host's tempo, RATE as Marbles' ratio table (×4, ×1/4), Stop / Continue, a stalled clock, PLAY on the host's clock, and the cable pulled (Marbles stops, own clock again) | diff --git a/tools/host-tests/miditest.cc b/tools/host-tests/miditest.cc index 694f711..879ed2f 100644 --- a/tools/host-tests/miditest.cc +++ b/tools/host-tests/miditest.cc @@ -641,6 +641,36 @@ int main() { cc(27, 64); cc(103, 0); render_rms(1); + // ---- §16 GTLT (issue #20): CC 89, centred, 7-bit ---- + printf("§16 GTLT on CC 89 (centred, 7-bit)\n"); + { + struct sp1_mui_routing rt; + const auto settle = [&rt]() { + render_rms(1); + for (int i = 0; i < 50; ++i) sp1_midi_main_tick(8); + sp1_mui_routing(&rt); + }; + sp1_mui_routing(&rt); + CHECK(rt.gtlt == 0.0f, "GTLT should start on its detent, got %.3f", rt.gtlt); + cc(89, 127); // from the detent: the + end + settle(); + CHECK(rt.gtlt > 0.98f, "GTLT CC 127 from centre -> +1, got %.3f", rt.gtlt); + cc(89, 0); + settle(); + CHECK(rt.gtlt < -0.99f, "GTLT CC 0 from centre -> -1, got %.3f", rt.gtlt); + cc(89, 80); + settle(); + const float at80 = rt.gtlt; + // CC 12 and its fine half CC 44 -- GTLT's first assignment -- are free again + cc(12, 127); cc(44, 64); + settle(); + CHECK(rt.gtlt == at80, "CC 12 / 44 still move GTLT: %.5f vs %.5f", rt.gtlt, at80); + printf(" CC 89 = 80: %+.5f, unmoved by CC 12 / 44\n", at80); + cc(12, 0); cc(44, 0); cc(89, 64); + settle(); + CHECK(rt.gtlt == 0.0f, "GTLT CC 64 should be back on the detent, got %.4f", rt.gtlt); + } + printf("\n%s (%d failure%s)\n", fails ? "FAILED" : "all checks passed", fails, fails == 1 ? "" : "s"); return fails ? 1 : 0; diff --git a/tools/host-tests/routetest.cc b/tools/host-tests/routetest.cc index 6fa1f37..1086e0c 100644 --- a/tools/host-tests/routetest.cc +++ b/tools/host-tests/routetest.cc @@ -11,6 +11,7 @@ extern "C" { #include "sp1_marbles_ui.h" #include "sp1_plaits_ui.h" } +#include "sp1_gtlt.h" // M4c: the per-channel range hook the generated x_y_generator.cc override calls. Declared // here for the same reason the override declares it -- C++ linkage in namespace marbles. @@ -827,6 +828,97 @@ int main() { sp1_marbles_run(false); } + // ---------- 12. GTLT, the t gate tilt (issue #20) ---------- + printf("12. GTLT\n"); + { + // (a) the curve, as published in sp1_gtlt.h and docs/UI-PAGES.md + CHECK(sp1_gtlt_gain(0.0f, 0) == 1.0f && sp1_gtlt_gain(0.0f, 2) == 1.0f, + "GTLT at its detent is not EXACTLY 1.0 -- the output would not be bit-identical"); + for (int k = -10; k <= 10; ++k) { + CHECK(sp1_gtlt_gain(0.1f * k, 1) == 1.0f, "GTLT touched t2 at tilt %.1f", 0.1f * k); + } + CHECK(fabsf(sp1_gtlt_gain(SP1_GTLT_RAMP, 0) - 0.5f) < 1e-6f && + fabsf(sp1_gtlt_gain(-SP1_GTLT_RAMP, 2) - 0.5f) < 1e-6f, + "both gates should be at 50 %% at the end of the ramp"); + CHECK(sp1_gtlt_gain(1.0f, 0) == 0.0f && sp1_gtlt_gain(1.0f, 2) == 1.0f, + "tilt +1 should be t1 0 %%, t3 100 %%"); + CHECK(sp1_gtlt_gain(-1.0f, 0) == 1.0f && sp1_gtlt_gain(-1.0f, 2) == 0.0f, + "tilt -1 should be t1 100 %%, t3 0 %%"); + // continuous: no step anywhere along the travel bigger than the ramp's own slope + float worst = 0.0f; + for (int t = 0; t < 3; t += 2) { + float prev = sp1_gtlt_gain(-1.0f, t); + for (int k = -2000; k <= 2000; ++k) { + const float g = sp1_gtlt_gain(k / 2000.0f, t); + worst = fmaxf(worst, fabsf(g - prev)); + prev = g; + } + } + printf(" largest step over 4001 points of travel: %.4f\n", worst); + CHECK(worst <= 0.5f / (SP1_GTLT_RAMP * 2000.0f) + 1e-4f, "the curve steps: %.4f", worst); + + // (b) LEVEL sees the gain: t1 -> LEVEL is silenced at tilt +1, t3 -> LEVEL is not. + // Shortest decay, so the LPG tail of an earlier open gate cannot ring into the + // next measurement (at base_params' 0.8 it lasts seconds). + sp1_marbles_init(); + sp1_marbles_seed(12345u); + sp1_marbles_set_params(&mp); + sp1_marbles_run(true); + sp1_synth_params p; + base_params(&p); + p.decay = 0.0f; + p.mrb_t_dest[0] = SP1_DEST_LEVEL; + p.mrb_gtlt = 1.0f; + sp1_synth_set_params(&p); + render_rms(40); // earlier sections' tails + const double t1_off = render_rms(60); + p.mrb_gtlt = -1.0f; + sp1_synth_set_params(&p); + const double t1_full = render_rms(60); + base_params(&p); + p.decay = 0.0f; + p.mrb_t_dest[2] = SP1_DEST_LEVEL; + p.mrb_gtlt = 1.0f; + sp1_synth_set_params(&p); + const double t3_full = render_rms(60); + printf(" t1 -> LEVEL: rms %.1f at tilt -1, %.1f at +1; t3 -> LEVEL at +1: %.1f\n", + t1_full, t1_off, t3_full); + CHECK(t1_full > 100.0 && t3_full > 100.0, "a full-height gate did not open LEVEL"); + // Relative, not zero: with LEVEL patched at 0 V Plaits' LPG still leaks a few LSB + // (~-65 dB here). A gate getting through would be within a few dB of t1_full. + CHECK(t1_off < t1_full / 1000.0, "t1 at 0 %% still opened LEVEL: rms %.1f vs %.1f", + t1_off, t1_full); + + // (c) TRIG IGNORES GTLT (Adara): the same seeded sequence fires exactly the same + // TRIGs with GTLT off and at the extreme that takes t1 to 0 %. + uint32_t edges[2]; + const float tilt[2] = { 0.0f, 1.0f }; + for (int i = 0; i < 2; ++i) { + // The same starting state both times: stopped, nothing routed, the previous + // block's gates and TRIG level cleared. + sp1_marbles_run(false); + base_params(&p); + sp1_synth_set_params(&p); + render_rms(10); + sp1_marbles_init(); + sp1_marbles_seed(12345u); + sp1_marbles_set_params(&mp); + sp1_marbles_run(true); + base_params(&p); + p.mrb_t_dest[0] = SP1_DEST_TRIG; + p.mrb_gtlt = tilt[i]; + sp1_synth_set_params(&p); + const uint32_t e0 = sp1_synth_trig_edges(); + render_rms(200); + edges[i] = sp1_synth_trig_edges() - e0; + } + printf(" t1 -> TRIG over 1 s: %u edges with GTLT off, %u at +1 (t1 at 0 %%)\n", + edges[0], edges[1]); + CHECK(edges[0] > 0u && edges[0] == edges[1], "GTLT changed TRIG: %u vs %u edges", + edges[0], edges[1]); + sp1_marbles_run(false); + } + printf("\n%s (%d failure%s)\n", fails ? "FAILED" : "all checks passed", fails, fails == 1 ? "" : "s"); return fails != 0; diff --git a/tools/host-tests/uitest.c b/tools/host-tests/uitest.c index 56b98f1..c81d050 100644 --- a/tools/host-tests/uitest.c +++ b/tools/host-tests/uitest.c @@ -8,7 +8,8 @@ #include "sp1_release_guard.h" /* ---- stubs for the parts that live in the audio thread ---- */ -uint8_t sp1_marbles_last_gates(void) { return 0u; } +static uint8_t stub_gates; /* t1..t3 as Marbles last rendered them (section 19) */ +uint8_t sp1_marbles_last_gates(void) { return stub_gates; } float sp1_marbles_last_volts(int k) { (void)k; return 0.0f; } float sp1_marbles_bpm(float rate, int r) { (void)r; return 120.0f * powf(2.0f, rate / 12.0f); } const char *sp1_marbles_model_name(int m) @@ -843,6 +844,161 @@ int main(void) "MARBLES page view differs from the ordinary view off SHIFT"); } + /* ---------- 18. GTLT on t SHIFT F1 (issue #20) ---------- */ + printf("18. GTLT\n"); + { + uint16_t f[4]; + sp1_mui_init(); + sp1_mui_routing(&r); + CHECK(r.gtlt == 0.0f, "GTLT does not boot disengaged: %.3f", r.gtlt); + + /* "••" held on the t page = t SHIFT; F1 at mid is inside the detent */ + sp1_mui_enter(raw_mid, true); + for (int i = 0; i < 100; i++) { + sp1_mui_tick(8u, raw_mid, true, true, false); + } + sp1_mui_routing(&r); + CHECK(r.gtlt == 0.0f, "F1 at mid is not on the detent: %.3f", r.gtlt); + + memcpy(f, raw_mid, sizeof(f)); + f[0] = 3701; /* F1 to the top */ + for (int i = 0; i < 400; i++) { + sp1_mui_tick(8u, f, true, true, false); + } + sp1_mui_routing(&r); + sp1_mui_leds(lv); + printf(" F1 top: gtlt %+.3f, track row %s\n", r.gtlt, glyph(lv)); + CHECK(r.gtlt > 0.99f, "F1 at the top should be tilt +1, got %.3f", r.gtlt); + CHECK(lv[0] >= 200u, "GTLT is not shown on T1 (still reserved?)"); + + f[0] = 0; /* and to the bottom */ + for (int i = 0; i < 400; i++) { + sp1_mui_tick(8u, f, true, true, false); + } + sp1_mui_routing(&r); + CHECK(r.gtlt < -0.99f, "F1 at the bottom should be tilt -1, got %.3f", r.gtlt); + + /* the X page's SHIFT F1 is still unbound: GTLT must not move from there */ + sp1_mui_set_page(SP1_MUI_PAGE_X); + for (int i = 0; i < 400; i++) { + sp1_mui_tick(8u, raw_top, true, true, false); + } + sp1_mui_routing(&r); + CHECK(r.gtlt < -0.99f, "X SHIFT F1 moved GTLT: %.3f", r.gtlt); + + sp1_mui_rip(); + sp1_mui_routing(&r); + CHECK(r.gtlt == 0.0f, "a rip did not return GTLT to its detent: %.3f", r.gtlt); + } + + /* ---------- 19. the t page's gate LEDs show GTLT's height (issue #20) ---------- */ + printf("19. GTLT on the t LEDs\n"); + { + uint16_t f[4]; + const uint8_t floor8 = (uint8_t)(0.08f * 255.0f + 0.5f); + sp1_mui_init(); + sp1_mui_enter(raw_mid, false); + for (int i = 0; i < 200; i++) { /* > 1.2 s: no value overlay */ + sp1_mui_tick(8u, raw_mid, true, false, false); + } + stub_gates = 0x7u; + sp1_mui_leds(lv); + CHECK(lv[0] == 255u && lv[1] == 255u && lv[2] == 255u, + "GTLT on its detent should leave high gates full: %u %u %u", + lv[0], lv[1], lv[2]); + stub_gates = 0x0u; + sp1_mui_leds(lv); + CHECK((lv[0] | lv[1] | lv[2]) == 0u, "low gates should be dark"); + + /* t SHIFT F1 to the top = tilt +1: t1 0 %, t2 untouched, t3 100 %. "••" goes + * down first, then the fader moves, as a hand does (CATCH_LOCK takes the + * finger's position at the layer change as its reference). */ + for (int i = 0; i < 10; i++) { + sp1_mui_tick(8u, raw_mid, true, true, false); + } + memcpy(f, raw_mid, sizeof(f)); + f[0] = 3701; + for (int i = 0; i < 400; i++) { + sp1_mui_tick(8u, f, true, true, false); + } + for (int i = 0; i < 200; i++) { /* back to BASE, faders still */ + sp1_mui_tick(8u, f, true, false, false); + } + stub_gates = 0x7u; + sp1_mui_leds(lv); + printf(" tilt +1, all gates high: %u %u %u (8 %% = %u)\n", + lv[0], lv[1], lv[2], floor8); + CHECK(lv[0] == floor8, "t1 at 0 %% should show the 8 %% floor, got %u", lv[0]); + CHECK(lv[1] == 255u && lv[2] == 255u, "t2 / t3 should be full: %u %u", + lv[1], lv[2]); + /* the same whether t1 goes to TRIG or nowhere (every output dims) */ + sp1_mui_t_dest_step(0); + sp1_mui_leds(lv); + CHECK(lv[0] == floor8, "t1's LED should not depend on its routing: %u", lv[0]); + stub_gates = 0x0u; + } + + /* ---------- 20. no bleed from SHIFT into BASE as "••" comes up (#20) ---------- + * Adara: a GTLT edit carried over into CLOK. The fader moves on SHIFT, "••" is released + * with the finger still on it, before the low-pass has settled; then the finger rests + * with a little jitter. The BASE value must not move. A real move afterwards must. */ + printf("20. CATCH_LOCK: SHIFT edits stay on SHIFT\n"); + { + uint16_t f[4]; + struct sp1_marbles_params a, b; + sp1_mui_init(); + sp1_mui_enter(raw_mid, false); + for (int i = 0; i < 100; i++) { + sp1_mui_tick(8u, raw_mid, true, false, false); + } + sp1_mui_params(&a); + memcpy(f, raw_mid, sizeof(f)); + f[0] = 2961; /* GTLT up, quickly: 3 ticks */ + for (int i = 0; i < 3; i++) { + sp1_mui_tick(8u, f, true, true, false); + } + for (int i = 0; i < 100; i++) { /* "••" up, finger resting */ + f[0] = (uint16_t)(2961 + ((i & 1) ? 15 : -15)); + sp1_mui_tick(8u, f, true, false, false); + } + sp1_mui_params(&b); + printf(" MARBLES CLOK after a GTLT flick + release: %.4f -> %.4f st\n", + a.rate, b.rate); + CHECK(b.rate == a.rate, "GTLT bled into CLOK: %.4f -> %.4f", a.rate, b.rate); + for (int i = 0; i < 100; i++) { /* a real move on BASE */ + sp1_mui_tick(8u, raw_top, true, false, false); + } + sp1_mui_params(&b); + CHECK(b.rate > a.rate + 1.0f, "a real CLOK move after the lock did nothing"); + + struct sp1_synth_params pa, pb; + sp1_pui_init(); + sp1_pui_enter(raw_mid); + for (int i = 0; i < 100; i++) { + sp1_pui_tick(8u, raw_mid, true, false, false); + } + sp1_pui_params(&pa); + memcpy(f, raw_mid, sizeof(f)); + f[1] = 3300; /* TIMBRE attenuverter, flicked */ + for (int i = 0; i < 3; i++) { + sp1_pui_tick(8u, f, true, true, false); + } + for (int i = 0; i < 100; i++) { + f[1] = (uint16_t)(3300 + ((i & 1) ? 15 : -15)); + sp1_pui_tick(8u, f, true, false, false); + } + sp1_pui_params(&pb); + printf(" PLAITS TIMBRE after a SHIFT flick + release: %.4f -> %.4f\n", + pa.timbre, pb.timbre); + CHECK(pb.timbre == pa.timbre, "SHIFT F2 bled into TIMBRE: %.4f -> %.4f", + pa.timbre, pb.timbre); + for (int i = 0; i < 100; i++) { + sp1_pui_tick(8u, raw_top, true, false, false); + } + sp1_pui_params(&pb); + CHECK(pb.timbre > pa.timbre + 0.1f, "a real TIMBRE move after the lock did nothing"); + } + printf("\n%s (%d failure%s)\n", fails ? "FAILED" : "all checks passed", fails, fails == 1 ? "" : "s"); return fails != 0;