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:
29
engine.c
29
engine.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user