FX > REPEAT on the beat: the slice is the beat's first 1/8, 1/16, 1/32

A user's request, the owner's go ("cuantizar el inicio"): while playing, a REPEAT that has to record waits for the
next beat of the transport (clk_n a multiple of 4), so the slice it loops starts on the beat and its repeats stay in
phase with the bar. A shorter REPEAT over one already recorded (a roll 1/8 -> 1/16 -> 1/32) still switches on the next
1/16, and letting a REPEAT go gives the one held before back: both now read the loop where the bar is (perf_grid), not
from its start. Stopped: at once, as before. REVERSE, TAPE STOP, STRETCH: on the 1/16, as before.

perform.c: perf_q (out of perf_begin's RAM code, through a register) and perf_grid (out of perf_switch, its pinned
size kept); RAM code 40432 B as before, perf_begin's target cost unchanged, app slot 9796 B free.
tests/perform_test.c: the timing case on the beat; new "on the beat" (1/8 1/16 1/32 x 93 120 137 BPM x pressed early,
mid, late: live to the beat, then the beat's slice, in phase) and the roll / let-go phase case. Manuals updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
This commit is contained in:
Claude committed 2026-12-05 11:12:09 +00:00
1 parent 7ec71a534a
commit b4b6307ac5
6 files changed
+147 -31

No files matched your search

+3 -2
View File
@@ -2616,8 +2616,9 @@ las pistas sobre las que actúa (ALL, SYN, DRM). Para grabar: REC armado y tocan
la tecla del efecto; los pasos que pasa lo reciben; **G5** sostenido borra por donde pasa el cabezal. Se guarda con
la sección.
- **Sobre el audio**: REPEAT 1/8, 1/16, 1/32 (F3 G3 A3), LPF (B3), HPF (C4). REPEAT arranca en la siguiente 1/16
mientras suena. Por debajo de unos 81 BPM, REPEAT 1/8 es demasiado largo para su buffer y aparece atenuado.
- **Sobre el audio**: REPEAT 1/8, 1/16, 1/32 (F3 G3 A3), LPF (B3), HPF (C4). REPEAT arranca en el siguiente tiempo
mientras suena y repite el primer 1/8, 1/16 o 1/32 de ese tiempo, en fase con el compás; uno más corto encima (un
redoble) cambia en la siguiente 1/16. Parado, al instante. Por debajo de unos 81 BPM, REPEAT 1/8 es demasiado largo para su buffer y aparece atenuado.
- **Sobre las notas**: OCT− / OCT+ (D4 E4), 1/2 TEMPO (F4), DEC− (corto, punteado) / DEC+ (largo) (G4 A4), STUTTER
1/8 / 1/16 (B4 C5), ATK+ (ataques lentos, baterías incluidas) (D5), ARP (E5; en una pista DRUM, un fill nuevo en cada
pulsación), RANDOM (F5). Entran en la siguiente 1/16. **A#4** elige a qué pistas afectan: ALL, SYN (sintes) o DRM
+3 -2
View File
@@ -2476,8 +2476,9 @@ the lane's cells in the effects' colours with the playhead on them, the last eff
on (ALL, SYN, DRM). To record: REC armed and playing (not in a song), hold FX and the effect's key; the steps it
passes get it; **G5** held erases where the playhead passes. Saved with the section.
- **On the audio**: REPEAT 1/8, 1/16, 1/32 (F3 G3 A3), LPF (B3), HPF (C4). REPEAT starts on the next 1/16 while
playing. Below about 81 BPM, REPEAT 1/8 is too long for its buffer and is shown dimmed.
- **On the audio**: REPEAT 1/8, 1/16, 1/32 (F3 G3 A3), LPF (B3), HPF (C4). REPEAT starts on the next beat while
playing and repeats that beat's first 1/8, 1/16 or 1/32, in time with the bar; a shorter one held over it (a roll)
switches on the next 1/16. Stopped, at once. Below about 81 BPM, REPEAT 1/8 is too long for its buffer and is shown dimmed.
- **On the notes**: OCT− / OCT+ (D4 E4), 1/2 TEMPO (F4), DEC− (short, plucky) / DEC+ (long) (G4 A4), STUTTER 1/8 / 1/16
(B4 C5), ATK+ (slow attacks, drums too) (D5), ARP (E5; on a DRUM track a new fill every press), RANDOM (F5). They come
in on the next 1/16. **A#4** chooses which tracks they touch: ALL, SYN (synths) or DRM (drums); the header shows it.
+45 -8
View File
@@ -12,9 +12,11 @@
* SHUFFLE, FREEZE and the sweeps are not here: the app slot (flash) has a few hundred bytes left.
* TONIC keeps only the audio stutters (REPEAT): REVERSE, TAPE STOP, FREEZE and OCT UP / DN (the harmonizer) were
* removed; the punch-in effects of TONIC act on the notes instead (FELUCCA-TONIC-SPEC.md).
* REPEAT starts on the next 1/16 (at once while stopped); the filters at once; all end when let go, with a 2.9 ms
* ramp. Effects of different kinds stack; of the REPEATs the last pressed plays, and letting it go returns to the
* one held before.
* REPEAT starts on the next beat (V10.8.86: its slice the beat's first 1/8, 1/16, 1/32, the repeats with the bar; a
* shorter one than the loop recorded, a roll, on the next 1/16, in the bar's phase; perf_q), the other buffer effects
* on the next 1/16 (all at once while stopped); the filters at once; all end when let go, with a 2.9 ms ramp. Effects
* of different kinds stack; of the REPEATs the last pressed plays, and letting it go returns to the one held before
* (V10.8.86: in the bar's phase, perf_grid).
* The buffer: the SLICER's recordings (sl_buf, 32 KB) borrowed as one stereo loop of 8192 frames at 22.05 kHz
* (371 ms). While borrowed, STUT tracks play live; their recordings are dropped afterwards. A REPEAT 1/8 longer
* than the loop at the tempo (below 81 BPM) records at 11 kHz (V10.59: lo-fi, down to ~41 BPM; slower: dimmed).
@@ -39,7 +41,7 @@ _Static_assert(PF_N == 26 && PF_CLR == 27 && PF_STR == 21 && PF_PDN == 24, "PF b
#define PF_BIT(e) (1u << (e))
#define PF_REPEAT 0x7u /* the three REPEAT rates */
#define PF_PITCH (PF_BIT(PF_PUP) | PF_BIT(PF_PDN))
#define PF_Q (PF_REPEAT | PF_BIT(PF_REV) | PF_BIT(PF_TAPE) | PF_BIT(PF_STR)) /* start on the 1/16 */
#define PF_Q (PF_REPEAT | PF_BIT(PF_REV) | PF_BIT(PF_TAPE) | PF_BIT(PF_STR)) /* start on the 1/16 (REPEAT: the beat) */
#define PF_BUF (PF_Q | PF_PITCH) /* the buffer effects (the last pressed plays) */
#define PF_LOOPS PF_BIT(PF_LP3) /* (snd2) on the sequencer (pfx.c), as the MIDI ones */
#define PF_MUTE (((1u << NTRK) - 1u) << PF_M1)
@@ -235,6 +237,15 @@ static __attribute__((noinline)) void perf_buf_start(uint32_t e)
}
}
/* (V10.8.86) the switch to a REPEAT's loop (pf.src, pf.len), read where the bar is (a loop recorded from a beat): in
* phase when a roll starts on a 1/16, or a REPEAT let go gives the one held before back mid-beat (it was played from its
* start: off the beat). At the block's start, or at pf.split for one started there (perf_block); stopped: from its
* start. Out of perf_switch (its size pinned: tools/audio_layout.txt) */
static __attribute__((noinline)) void perf_grid(void)
{
uint32_t off = (pf.act & ~pf.act0) >> pf.src & 1u ? pf.split : 0u;
pf.rp = song.playing && clk_pos != CLK_START ? ((clk_n & 3u) * pf.P + clk_pos + off) % pf.len : 0u;
}
/* the buffer effect to play becomes e (at a 1/16): a shorter REPEAT of what is
* recorded switches with a cross-fade, anything else fades the old one out first */
static void perf_buf_select(uint32_t e)
@@ -249,7 +260,7 @@ static void perf_buf_select(uint32_t e)
pf.src = (uint8_t)e;
pf.next = PF_N;
pf.len = perf_len(e);
pf.rp = 0;
perf_grid();
return;
}
if (pf.mode == BM_NONE || !pf.w) {
@@ -307,6 +318,30 @@ static __attribute__((noinline)) uint32_t pk_step(uint32_t n)
return 0;
}
static uint32_t (*const volatile PERF_PK)(uint32_t) = pk_step; /* (out of perf_begin's RAM code: its reach) */
/* (V10.8.86, a user's, the owner: "cuantizar el inicio") the 1/16 effects q pressed start at the 1/16 bnd of this block
* (pf.split: its n samples, none at n; stopped: at once). A REPEAT that records waits for the beat (the transport's 1/16
* a multiple of 4; no clock yet: PLAY's), so the slice it repeats is the beat's first 1/8, 1/16, 1/32 and its repeats
* stay with the bar (Fatboy Slim's stutter); one no longer than the loop a REPEAT has recorded (a roll, 1/8 -> 1/16 ->
* 1/32) needs no recording: on the 1/16, read where the bar is (perf_grid). Out of perf_begin's RAM code. (The buffer
* is the SLICER's until a press: nothing recorded before it, so a press just after the beat waits for the next one) */
static __attribute__((noinline)) void perf_q(uint32_t q, uint32_t bnd)
{
uint32_t e, n = pf.split;
if (!song.playing) {
pf.split = 0;
} else {
if (bnd >= n)
return;
if ((clk_pos != CLK_START ? clk_n + (clk_pos + bnd) / pf.P : (pf.ph - n + bnd) / pf.P) & 3u) /* (not a beat) */
for (e = PF_R8; e <= PF_R32; e++)
if (!(pf.mode == BM_LOOP && pf.state && pf.src != PF_N && perf_len(e) <= pf.wr << pf.q))
q &= ~PF_BIT(e);
if (!q)
return;
pf.split = bnd;
}
pf.act |= q;
}
static __attribute__((noinline)) int perf_begin(uint32_t n)
{
uint32_t held = perf_kill ? 0u : (perf_held | perf_latched | PERF_PK(n) | (perf_solo ? (~(uint32_t)perf_solo & ((1u << NTRK) - 1u)) << PF_M1 : 0u)) & perf_avail() & ~(PF_MIDI | PF_LOOPS);
@@ -335,9 +370,11 @@ static __attribute__((noinline)) int perf_begin(uint32_t n)
pf.act0 = pf.act;
q = held & PF_Q & ~pf.act;
pf.split = n;
if (q && (!song.playing || bnd < n)) {
pf.split = song.playing ? bnd : 0u;
pf.act |= q;
if (q) { /* (V10.8.86: REPEAT on the beat; through a register: out of the RAM
* code's reach, no constant moved: tools/audio_layout.txt) */
void (*f)(uint32_t, uint32_t) = perf_q;
FM1_OPAQUE(f);
f(q, bnd);
}
perf_act = pf.act;
if (pf.act & PF_BIT(PF_FRZ)) /* (V10.7.59) FREEZE: the reverb's SIZE at its top (mod.c's offset,
+91 -16
View File
@@ -3,8 +3,10 @@
* Portions Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
/* Host test of the FX hold layer's effects (firmware/src/perform.c), same sources as the firmware (through
* hostsim.c). build/host/perform_test [DEMO_DIR] (run_tests.sh: build/perform_demo)
* 1. timing: REPEAT starts on the next 1/16 of the transport (sample exact) and ends when let go (the live
* signal back, bit for bit, after the 2.9 ms ramp); the filters start at once.
* 1. timing: REPEAT starts on the next beat of the transport (sample exact; V10.8.86, was the 1/16) and ends when let
* go (the live signal back, bit for bit, after the 2.9 ms ramp); the filters start at once. On the beat (V10.8.86):
* 1/8 1/16 1/32 at three tempos, pressed early, mid and late in a beat, repeat the beat's first 1/8 1/16 1/32 in the
* bar's phase; a roll (a shorter one held) switches on the 1/16 and a let go gives the one before back, both in phase.
* 2. stereo: REPEAT keeps left and right apart (a silent right channel stays silent; each side follows its
* own input).
* 3. a REPEAT too long for the loop (1/8 below 81 BPM) does nothing at all.
@@ -124,20 +126,20 @@ static int test_timing(void)
int bad = 0;
char what[160];
test_signal(440, 12000, 277, 9000);
{ /* REPEAT 1/16: pressed mid-1/16, records the next 1/16, then loops it */
ev_t ev[] = {{992, PF_R16 + 1}, {20000, -(PF_R16 + 1)}};
{ /* REPEAT 1/16: pressed in the first beat's first 1/16, records the next beat's first 1/16, then loops it */
ev_t ev[] = {{992, PF_R16 + 1}, {40000, -(PF_R16 + 1)}};
int32_t el, er, el2;
run(120, 1, ev, 2, 40000);
run(120, 1, ev, 2, 60000);
shift_d = P16;
el = err_vs(2 * P16 + 160, 3 * P16 - 160, delayed, 0);
er = err_vs(2 * P16 + 160, 3 * P16 - 160, delayed, 1);
el = err_vs(5 * P16 + 160, 6 * P16 - 160, delayed, 0);
er = err_vs(5 * P16 + 160, 6 * P16 - 160, delayed, 1);
shift_d = 2 * P16;
el2 = err_vs(3 * P16 + 160, 20000 - 160, delayed, 0);
snprintf(what, sizeof what, "REPEAT 1/16: live until the 1/16 after the press + one 1/16 (exact)");
bad += check(what, same(0, 2 * P16));
snprintf(what, sizeof what, " then the 1/16 from that 1/16, looped (error L %d R %d, 2nd pass %d of 12000)", el, er, el2);
el2 = err_vs(6 * P16 + 160, 7 * P16 - 160, delayed, 0);
snprintf(what, sizeof what, "REPEAT 1/16: live until the beat after the press + one 1/16 (exact)");
bad += check(what, same(0, 5 * P16));
snprintf(what, sizeof what, " then the beat's first 1/16, looped (error L %d R %d, 2nd pass %d of 12000)", el, er, el2);
bad += check(what, el < 100 && er < 100 && el2 < 100);
bad += check(" let go: the live signal again after the ramp, bit for bit", same(20000 + 160, 40000));
bad += check(" let go: the live signal again after the ramp, bit for bit", same(40000 + 160, 60000));
bad += check(" the buffer given back, nothing left running", !sl_lent && pf.mode == BM_NONE && !pf.busy);
}
{ /* stopped: at once */
@@ -153,6 +155,76 @@ static int test_timing(void)
return bad;
}
/* -------------------------------------------------- 1b. on the beat --- */
/* out against the loop of len from the beat B, in[B + (t - B) % len], on [a, b) away (160) from each pass's ends (their
* 2.9 ms windows); the worst error */
static int32_t beat_err(uint32_t B, uint32_t len, uint32_t a, uint32_t b)
{
uint32_t t;
int32_t e = 0;
for (t = a; t < b; t++) {
uint32_t r = (t - B) % len, s = B + r;
int32_t d;
if (r < 160u || r + 160u >= len)
continue;
d = abs(out_l[t] - in_l[s]);
d = abs(out_r[t] - in_r[s]) > d ? abs(out_r[t] - in_r[s]) : d;
e = d > e ? d : e;
}
return e;
}
static int test_beat(void)
{
static const uint32_t BPM[3] = {93, 120, 137};
static const char *const NM[3] = {"1/8", "1/16", "1/32"};
static const uint32_t AT[3] = {3, 50, 97}; /* the press: % into the second beat */
uint32_t b, e, k;
int bad = 0, fails = 0;
char what[200];
test_signal(440, 12000, 277, 9000);
for (b = 0; b < 3u; b++)
for (e = PF_R8; e <= PF_R32; e++)
for (k = 0; k < 3u; k++) {
uint32_t beat, len, t0, B, at;
int32_t err;
song.g[G_BPM] = (int16_t)BPM[b];
beat = beat_samples();
len = beat / PF_DEN[e];
at = beat + beat * AT[k] / 100u;
{
ev_t ev[] = {{at, (int)e + 1}, {at + 3u * beat, -((int)e + 1)}};
run(BPM[b], 1, ev, 2, at + 4u * beat);
}
t0 = (at + CTL - 1u) / CTL * CTL; /* (the block the press is seen in) */
B = (t0 + beat - 1u) / beat * beat; /* the next beat (or this one, on it) */
err = beat_err(B, len, B + len, at + 3u * beat);
snprintf(what, sizeof what, "on the beat: REPEAT %s at %u BPM pressed %u %% into a beat: live to the beat, then "
"its first %s (error %d)", NM[e], BPM[b], AT[k], NM[e], err);
if (!(same(0, B) && !same(B, B + len + 160u) && err < 100)) {
fails++;
bad += check(what, 0);
}
}
snprintf(what, sizeof what, "on the beat: REPEAT 1/8 1/16 1/32 x 93 120 137 BPM x early, mid, late: the beat's slice, "
"in phase (%d of 27 off)", fails);
bad += check(what, !fails);
{ /* a roll: 1/8 on the beat, 1/16 pressed mid-1/16 (its switch on the 1/16, in phase), let go mid-1/16 (the 1/8
* back, in phase) */
uint32_t B = 2u * 4u * P16;
ev_t ev[] = {{4u * P16 + 2000u, PF_R8 + 1}, {B + 2u * P16 + 3000u, PF_R16 + 1}, {B + 6u * P16 + 2500u, -(PF_R16 + 1)},
{B + 12u * P16, -(PF_R8 + 1)}};
int32_t e8, e16, eb;
run(120, 1, ev, 4, B + 13u * P16);
e8 = beat_err(B, 2u * P16, B + 2u * P16, B + 3u * P16);
e16 = beat_err(B, P16, B + 3u * P16 + 160u, B + 6u * P16 + 2496u);
eb = beat_err(B, 2u * P16, B + 6u * P16 + 2560u + 160u, B + 12u * P16);
snprintf(what, sizeof what, " a roll: 1/8 on the beat, 1/16 from the next 1/16, the 1/8 back mid-1/16, all in "
"phase (errors %d %d %d)", e8, e16, eb);
bad += check(what, same(0, B) && e8 < 100 && e16 < 100 && eb < 100);
}
return bad;
}
/* ------------------------------------------------------------ 2. stereo --- */
static int test_stereo(void)
{
@@ -192,14 +264,16 @@ static int test_too_long(void)
{
int bad = 0;
ev_t ev[] = {{992, PF_R8 + 1}, {40000, -(PF_R8 + 1)}};
ev_t e72[] = {{992, PF_R8 + 1}, {100000, -(PF_R8 + 1)}};
test_signal(440, 12000, 277, 9000);
run(72, 1, ev, 2, 50000);
run(72, 1, e72, 2, 110000);
bad += check("REPEAT 1/8 at 72 BPM (417 ms, the loop holds 371 at 22 kHz): V10.59 plays it at 11 kHz (lo-fi)",
!same(0, 40000) && (perf_avail() & PF_BIT(PF_R8)));
!same(0, 100000) && (perf_avail() & PF_BIT(PF_R8)));
{ /* (V10.59) the 11 kHz loop repeats: a 1/8 later the same (a 440 Hz / 277 Hz pair: within the lo-fi's error) */
char what[160];
uint32_t L = div_samples(1), t, a0 = 30000u; /* (V10.8.40: the sequencer's 1/8, a beat a multiple of 24 samples) */ /* (recorded from the 1/16 after 992, played
* a 1/8 later: the input of a 1/8 before) */
uint32_t L = div_samples(1), t, a0 = beat_samples() + L + 1000u; /* (V10.8.40: the sequencer's 1/8, a beat a
* multiple of 24 samples) (V10.8.86: recorded from the beat after
* 992, played a 1/8 later: the input of a 1/8 before) */
double e = 0, p = 0;
for (t = a0; t < a0 + 4000u; t++) {
double d = (double)out_l[t] - in_l[t - L];
@@ -1054,6 +1128,7 @@ int main(int argc, char **argv)
bad += test_loops();
bad += test_new();
bad += test_timing();
bad += test_beat();
bad += test_stereo();
bad += test_too_long();
bad += test_slicer();
+2 -2
View File
@@ -56,7 +56,7 @@
# MOD (tests/mod_test.c): the modulation matrix: slots that do nothing are bit-identical, every source on each
# kind of destination, clamping, MIDI CC1 / CC11 / aftertouch routing, the cost of 4 active
# slots (at most +5 %), demos in build/mod_demo/.
# PERFORM (tests/perform_test.c): the FX hold layer (src/perform.c): 1/16 starts, stereo buffer effects, the
# PERFORM (tests/perform_test.c): the FX hold layer (src/perform.c): REPEAT on the beat, 1/16 starts, stereo buffer effects, the
# too-long REPEAT, the SLICER interplay, silent layer keys, idle bit-identical, cost; build/perform_demo/;
# REVERB (tests/reverb_test.c): REVERB TYPE (src/fx.c): ROOM bit for bit as its reference (V10.7.17: a 4-line network),
# its echo density, its decay as the old combs', its tail ending in exact 0; SPRING's decay against SIZE,
@@ -361,7 +361,7 @@ if [ -f build/gen/felucca_tables.h ]; then
run "SWING: track + global at most 100, sequencer and SLICER step lengths, the SWG display" "$OUT/swing_test"
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/perform_test" tests/perform_test.c -lm
mkdir -p build/perform_demo build/fx_demo
run "FX layer effects: on the 1/16, stereo, too-long REPEAT, SLICER, silent keys, idle bit-identical, clicks, cost, demos" "$OUT/perform_test" build/perform_demo
run "FX layer effects: REPEAT on the beat, the others on the 1/16, stereo, too-long REPEAT, SLICER, silent keys, idle bit-identical, clicks, cost, demos" "$OUT/perform_test" build/perform_demo
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/reverb_test" tests/reverb_test.c -lm
run "REVERB TYPE: ROOM bit-identical, dense, clean end, SPRING decay / chirp / stability / level, model change, cost, demos" "$OUT/reverb_test" build/fx_demo
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/cloud_hot_test" tests/cloud_hot_test.c -lm
+3 -1
View File
@@ -1298,6 +1298,7 @@ perf_buf_start 296 text beat_samples memset perf_drop_slicer perf_len
perf_def 64 text
perf_drop_slicer 4 text
perf_frz 78 text *
perf_grid 100 text
perf_hush_end 52 text
perf_key 36 text perf_slot
perf_kpress 284 text * perf_key perf_press perf_slot
@@ -1306,6 +1307,7 @@ perf_master 148 hot_text master_out perf_block
perf_mute 110 text mulq16 perf_hush_end
perf_pre 186 hot_text !
perf_press 96 text
perf_q 176 text * perf_len
perf_rtp 648 text pb_ring_f perf_str
perf_slot 26 text key_black key_place
perf_str 402 text pb_loop
@@ -1481,7 +1483,7 @@ scale_mask 32 text
scale_snap 52 text scale_mask
scale_steps 112 text scale_mask scale_snap
scene_drum_tick 272 text div_samples trk_note_off trk_note_on
scene_follow 144 text * sc_track scene_follow_off trk_index
scene_follow 144 text sc_track scene_follow_off trk_index
scene_follow_off 82 text input_off mo_koff
scene_key 324 text input_off kb_map midi_local_held mo_koff sc_track
scn_notes 278 text chord_build_mode trk_index