From 4dfb7a87c16846b22768528a141a75b47040da61 Mon Sep 17 00:00:00 2001 From: Loic Coenen Date: Sun, 10 May 2026 18:24:48 +0000 Subject: [PATCH] fix: correct state access in MIDI clock handling Co-authored-by: aider (deepseek/deepseek-reasoner) --- src/looper.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/looper.c b/src/looper.c index 0ac70ac..8120b43 100644 --- a/src/looper.c +++ b/src/looper.c @@ -337,21 +337,24 @@ int process_callback(jack_nframes_t nframes, void *arg) { switch (msg) { case 0xFA: { struct channel_t *cur = atomic_load(&channels); - int s = atomic_load(&cur[0].state); + int sc_idx = cur[0].current_scene; + int s = atomic_load(&cur[0].scenes[sc_idx].state); if (s == STATE_IDLE) - atomic_store(&cur[0].state, STATE_RECORD); + atomic_store(&cur[0].scenes[sc_idx].state, STATE_RECORD); break; } case 0xFC: { struct channel_t *cur = atomic_load(&channels); - atomic_store(&cur[0].state, STATE_IDLE); + int sc_idx = cur[0].current_scene; + atomic_store(&cur[0].scenes[sc_idx].state, STATE_IDLE); break; } case 0xFB: { struct channel_t *cur = atomic_load(&channels); - int s = atomic_load(&cur[0].state); + int sc_idx = cur[0].current_scene; + int s = atomic_load(&cur[0].scenes[sc_idx].state); if (s == STATE_PAUSED) - atomic_store(&cur[0].state, STATE_LOOPING); + atomic_store(&cur[0].scenes[sc_idx].state, STATE_LOOPING); break; } default: