feat: add per-channel MIDI looping support

Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-10 11:29:41 +00:00
parent 85e828f461
commit ff226a8ea6
4 changed files with 199 additions and 42 deletions

View File

@@ -29,6 +29,37 @@ void channel_add(jack_client_t *client, int idx) {
cur[idx].loop_count = 0;
cur[idx].record_pos = 0;
cur[idx].playback_pos = 0;
cur[idx].type = CHANNEL_AUDIO;
next_channel_id++;
atomic_fetch_add(&channel_count, 1);
}
void channel_add_midi(jack_client_t *client, int idx) {
struct channel_t *cur = get_channels_array();
char in_name[64], out_name[64];
snprintf(in_name, sizeof(in_name), "channel%d_midi_in", next_channel_id);
snprintf(out_name, sizeof(out_name), "channel%d_midi_out", next_channel_id);
cur[idx].midi_in = jack_port_register(
client, in_name, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0);
cur[idx].midi_out = jack_port_register(
client, out_name, JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0);
if (!cur[idx].midi_in || !cur[idx].midi_out) {
fprintf(stderr, "Failed to register MIDI ports for channel %d\n",
next_channel_id);
atomic_store(&cur[idx].active, 0);
return;
}
atomic_store(&cur[idx].active, 1);
atomic_store(&cur[idx].state, STATE_IDLE);
cur[idx].prev_state = -1;
cur[idx].loop_count = 0;
cur[idx].record_pos = 0;
cur[idx].playback_pos = 0;
cur[idx].type = CHANNEL_MIDI;
next_channel_id++;
atomic_fetch_add(&channel_count, 1);