From 4c30f053832fe7299ab0a3245f6870fb69d83ea6 Mon Sep 17 00:00:00 2001 From: Filip Tomaszewski Date: Fri, 23 Oct 2026 12:45:24 +0200 Subject: [PATCH] 303: long notes from SEQ: hold a step and press a later one, or turn GATE through LEN 2, 3, ... and SLIDE Co-Authored-By: Claude Opus 5.5 --- docs/MANUAL.md | 6 +++ firmware/src/app/ui.c | 118 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 123 insertions(+), 1 deletion(-) diff --git a/docs/MANUAL.md b/docs/MANUAL.md index 49cd262..9bddf1b 100644 --- a/docs/MANUAL.md +++ b/docs/MANUAL.md @@ -280,6 +280,12 @@ A **tie** holds the note before it through the step, so it doesn't play again. O tied note joins the note it holds in one long bar. Turning KNOB 1 on a tie makes it a note of its own. +**Long notes.** On SEQ, hold a note's step key and press a later step key: the note lasts up to +and including that step (the steps between become ties), and the screen shows LEN and the number +of steps. Press its last step again for a one-step note. It works forward within the pattern's +length. KNOB 2 does the same one step at a time: after NOTE it offers LEN 2, LEN 3 and so on, up +to the next note, and then SLIDE, which holds the note until the next one and glides into it. + **Keyboard.** Press REC and all 27 keys become a keyboard (KEYS shows on the top line). The notes you play are written: step by step while the pattern is stopped, live while it plays. OCT- and OCT+ change the octave. Play a key while still holding another and the 303 slides diff --git a/firmware/src/app/ui.c b/firmware/src/app/ui.c index fd2168c..d20fee7 100644 --- a/firmware/src/app/ui.c +++ b/firmware/src/app/ui.c @@ -2006,6 +2006,112 @@ static void bass_kbd(int key, int down) } } +/* how many steps the note at step s lasts: itself and the TIEs after it */ +static int bass_note_len(const bpart_t *bp, int s) +{ + int len = bp->len ? bp->len : 16, n = 1; + while (n < len && bstep_gate(&bp->step[(s + n) % len]) == G_TIE) + n++; + return n; +} + +/* a step held, another pressed after it: the note lasts up to and including that one (TIEs in + * between, the TIEs after it rests). Pressing its current last step again: back to one step. Only + * forward, within the pattern. */ +static void bass_tie_to(bpart_t *bp, int from, int to) +{ + int len = bp->len ? bp->len : 16, s, n; + if (to <= from || to >= len || bstep_gate(&bp->step[from]) == G_REST) + return; + n = bass_note_len(bp, from); + if (from + n - 1 == to) /* already ends there: one step */ + to = from; + for (s = from + 1; s <= to; s++) + bp->step[s].flags = G_TIE; + for (; s < len && bstep_gate(&bp->step[s]) == G_TIE; s++) + bp->step[s].flags = G_REST; + ui.step_edited = 1; /* (releasing the held step keeps it) */ + mark_dirty(); + { + char t[16]; + put_i(put_s(t, "LENGTH "), bass_note_len(bp, from)); + say(t, 0); + } +} + +/* the held step's GATE knob walks REST, NOTE, a note 2, 3, ... steps long, TIE, and wraps. + * State k: 0 REST, 1 NOTE, 2 and up a note k steps long, BASS_GS_TIE a tie. A length that would reach the + * next note instead ties up to the step before it and sets SLIDE there, so it glides into that note + * (the last length offered; a lower one clears that slide). Lengths stop at the pattern's end; TIE is + * offered only after a step that sounds (a NOTE or a TIE) to tie to. */ +#define BASS_GS_TIE 1000 /* above any length */ + +/* steps from s to the next NOTE after it, or a large number when none is left in the pattern */ +static int bass_next_note(const bpart_t *bp, int s) +{ + int len = bp->len ? bp->len : 16, d; + for (d = 1; s + d < len; d++) + if (bstep_gate(&bp->step[s + d]) == G_NOTE) + return d; + return 99; +} + +/* the note at s, a NOTE, slides into the next note at its tail's end */ +static int bass_slides_on(const bpart_t *bp, int s) +{ + int n = bass_note_len(bp, s); + return bass_next_note(bp, s) == n && (bp->step[s + n - 1].flags & BS_SLIDE); +} + +/* the states step s may take, in knob order; returns how many */ +static int bass_gate_states(const bpart_t *bp, int s, int *k) +{ + int len = bp->len ? bp->len : 16, m = 0, n, d = bass_next_note(bp, s); + k[m++] = 0; + k[m++] = 1; + for (n = 2; n <= d + 1 && (n <= d ? s + n - 1 < len : 1); n++) + k[m++] = n; /* n == d + 1: the slide into the next note */ + if (s > 0 && bstep_gate(&bp->step[s - 1]) != G_REST) + k[m++] = BASS_GS_TIE; + return m; +} + +static int bass_gate_state(const bpart_t *bp, int s) +{ + int g = bstep_gate(&bp->step[s]); + if (g == G_TIE) + return BASS_GS_TIE; + if (g == G_REST) + return 0; + return bass_note_len(bp, s) + bass_slides_on(bp, s); +} + +static void bass_set_gate_state(bpart_t *bp, int s, int k) +{ + int len = bp->len ? bp->len : 16, i, n = k >= 2 && k != BASS_GS_TIE ? k : 1, d; + bstep_t *st = &bp->step[s]; + if (bstep_gate(st) == G_NOTE && bass_slides_on(bp, s)) /* its old slide into the next note */ + bp->step[s + bass_note_len(bp, s) - 1].flags &= (uint8_t)~BS_SLIDE; + for (i = s + 1; i < len && bstep_gate(&bp->step[i]) == G_TIE; i++) /* its old tail: rests */ + bp->step[i].flags = G_REST; + st->flags = (uint8_t)((st->flags & ~BS_GATE_MASK) | (k == BASS_GS_TIE ? G_TIE : k == 0 ? G_REST : G_NOTE)); + d = bass_next_note(bp, s); + for (i = 1; i < n && i < d && s + i < len; i++) + bp->step[s + i].flags = G_TIE; + if (n > d) /* reaches the next note: glide into it */ + bp->step[s + d - 1].flags |= BS_SLIDE; +} + +/* the GATE knob turned by e on step s */ +static void bass_gate_turn(bpart_t *bp, int s, int e) +{ + int k[NSTEPS + 3], m =bass_gate_states(bp, s, k), cur = bass_gate_state(bp, s), j = 0, i; + for (i = 0; i < m; i++) /* its place in the list, or the last one below it */ + if (k[i] <= cur) + j = i; + bass_set_gate_state(bp, s, k[(j + (e > 0 ? 1 : m - 1)) % m]); +} + /* an edit sounds as the drum keys do (KEY SOUND): while stopped or recording, or always */ static int key_sounds(void) { return proj.set.keysound || !seq.playing || ui.rec; } static void bass_step_key(int white, int down) @@ -2014,6 +2120,10 @@ static void bass_step_key(int white, int down) bpart_t *bp = &cur_pat()->bass[b]; if (s >= NSTEPS) return; + if (down && ui.view == V_SEQ && ui.held_step >= 0 && ui.held_step != s) { /* a later step: the note's length */ + bass_tie_to(bp, ui.held_step, s); + return; + } if (down) { /* an empty step is on at once: hold it to edit it */ ui.held_step = (int8_t)s; ui.step_edited = 0; @@ -2545,7 +2655,7 @@ static void input(void) if (i == 0) { held_note_by(e); } else if (i == 1) { - st->flags = (uint8_t)((st->flags & ~BS_GATE_MASK) | (bstep_gate(st) + (e > 0 ? 1 : 2)) % 3); + bass_gate_turn(bp, ui.held_step, e); } else if (i == 2) { st->flags ^= BS_ACCENT; } else { @@ -3130,6 +3240,8 @@ static void draw_303(int band, int gen) q = put_note(q, held_note_of(bp, s) + bp->transpose - 24); if (bstep_gate(st) == G_TIE) q = put_s(q, " TIE"); + else if (bstep_gate(st) == G_NOTE && bass_note_len(bp, s) > 1) + q = put_i(put_s(q, " LEN "), bass_note_len(bp, s)); if (st->flags & BS_ACCENT) q = put_s(q, " ACC"); if (st->flags & BS_SLIDE) @@ -3985,6 +4097,10 @@ static void draw_knobs(void) cv_rect(i * 60, 14, 1, 50, C_LINE); if (i == 0) put_note(v, held_note_of(bp, ui.held_step) + bp->transpose - 24); + else if (i == 1 && bstep_gate(st) == G_NOTE && bass_slides_on(bp, ui.held_step)) + put_s(v, "SLIDE"); + else if (i == 1 && bstep_gate(st) == G_NOTE && bass_note_len(bp, ui.held_step) > 1) + put_i(put_s(v, "LEN"), bass_note_len(bp, ui.held_step)); else if (i == 1) put_s(v, G[bstep_gate(st)]); else