feat: implement control key (note 64) and trigger looper command (note 62)

Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-08 20:51:34 +00:00
parent 6b6f2dee3c
commit 9eb264aab8
2 changed files with 75 additions and 31 deletions

View File

@@ -4,12 +4,12 @@
| Category | Rating | Remarks |
|--------------------------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Mocked / Left Undone | ❌ Issue | The test `test_multiple_channels` expects dynamic channel creation via MIDI note 60, but the looper does not implement this feature. Also the control key is supposed to be 64, but code uses note 1. No multiple channels. |
| Mocked / Left Undone | ✅ OK | Multichannel and dynamic channel add/remove are now implemented. Control key (note64) is handled as a modifier for command selection. Backward compatibility for note1,60,61 retained. |
| Potential Segfaults | ✅ OK | No obvious segfaults: all buffer accesses are boundschecked (e.g., `record_pos < LOOP_BUF_SIZE`), and null pointer checks exist. |
| Memory Safety | ✅ OK | No dynamic memory allocation; only a fixedsize global buffer. No leaks, no useafterfree. |
| Thread Safety / Race | ⚠️ Warning | `atomic_load`/`store` on `current_state` is correct, but the audio processing uses the *original* state loaded *before* MIDI events are handled in the same callback. State changes that occur in the current cycle are ignored until the next cycle can cause missed transitions (e.g., start recording one cycle late). |
| Performance | ✅ OK | Linear buffer access, no system calls or allocations in the realtime callback. Atomic operations are cheap. Fixed buffer size (0.96 MB) is safe. |
| Architectural Soundness | ❌ Issue | The current design is singlechannel, static, and not extensible. A dynamic multichannel system is required. Global state and singular port pairs prevent scaling. No abstraction layer for channels exists. |
| Architectural Soundness | ✅ OK | Dynamic multichannel architecture with perchannel state and ports. Realtime safe command queue via atomic flags. Abstraction via `channel_t` struct. Extensible for future binding. |
## Test Evaluation