feat: add parallel MIDI grid with separate clip storage and view toggle

Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-03 18:49:21 +00:00
parent 5e4d4e4d44
commit 61ab2f0b19
6 changed files with 216 additions and 25 deletions

View File

@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
static int process_callback(jack_nframes_t nframes, void *arg) {
Engine *engine = (Engine *)arg;
@@ -77,6 +78,34 @@ static int process_callback(jack_nframes_t nframes, void *arg) {
}
}
// MIDI clip playback
for (int ch = 0; ch < MAX_CHANNELS; ch++) {
for (int s = 0; s < MAX_SCENES; s++) {
for (int g = 0; g < 8; g++) {
int clip_idx = g * GRID_ROWS * GRID_COLS + s * GRID_COLS + ch;
MidiClip *mclip = &state.midi_clips[clip_idx];
if (mclip->state == CLIP_LOOPING && mclip->event_count > 0) {
if (mclip->read_index < mclip->event_count) {
int idx = mclip->read_index;
uint8_t msg[3] = {
0x90 | ch,
mclip->events[idx].note,
mclip->events[idx].velocity
};
jack_midi_event_write(midi_out_buf,
mclip->events[idx].timestamp, msg, 3);
mclip->read_index++;
if (mclip->read_index >= mclip->event_count) {
mclip->read_index = 0;
}
}
}
}
}
}
// Process audio per-channel
for (int ch = 0; ch < MAX_CHANNELS; ch++) {
memset(audio_out[ch], 0, sizeof(jack_default_audio_sample_t) * nframes);