feat: add transport control, clock source, and BPM commands to CLI

Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-01 21:12:37 +00:00
parent 3080c4e962
commit ca2c8de12f

62
cli.c
View File

@@ -50,6 +50,12 @@ int cli_process_line(Engine *engine, const char *line) {
printf(" reset transport - Reset transport\n"); printf(" reset transport - Reset transport\n");
printf(" quantize off|beat|bar - Set quantize mode\n"); printf(" quantize off|beat|bar - Set quantize mode\n");
printf(" threshold <samples> - Set quantize threshold\n"); printf(" threshold <samples> - Set quantize threshold\n");
printf(" play - Start transport\n");
printf(" pause - Pause transport\n");
printf(" stop - Stop transport\n");
printf(" toggle - Toggle play/pause\n");
printf(" clock internal|midi - Set clock source\n");
printf(" bpm <value> - Set BPM (1.0-999.0)\n");
printf(" help - Show this help\n"); printf(" help - Show this help\n");
printf(" quit - Exit CLI\n"); printf(" quit - Exit CLI\n");
return 1; return 1;
@@ -89,7 +95,8 @@ int cli_process_line(Engine *engine, const char *line) {
int idx = atoi(idx_str); int idx = atoi(idx_str);
engine_reset_clip(engine, idx); engine_reset_clip(engine, idx);
} else if (strcasecmp(sub, "transport") == 0) { } else if (strcasecmp(sub, "transport") == 0) {
engine_reset_transport(engine); engine_transport_stop(engine);
engine_process_commands(engine);
} else { } else {
printf("Unknown reset target: %s\n", sub); printf("Unknown reset target: %s\n", sub);
} }
@@ -112,6 +119,59 @@ int cli_process_line(Engine *engine, const char *line) {
jack_nframes_t samples = (jack_nframes_t)atol(val_str); jack_nframes_t samples = (jack_nframes_t)atol(val_str);
engine_set_quantize_threshold(engine, samples); engine_set_quantize_threshold(engine, samples);
} }
else if (strcasecmp(token, "play") == 0) {
engine_transport_play(engine);
engine_process_commands(engine);
printf("Transport: Playing\n");
}
else if (strcasecmp(token, "pause") == 0) {
engine_transport_pause(engine);
engine_process_commands(engine);
printf("Transport: Paused\n");
}
else if (strcasecmp(token, "stop") == 0) {
engine_transport_stop(engine);
engine_process_commands(engine);
printf("Transport: Stopped\n");
}
else if (strcasecmp(token, "toggle") == 0) {
engine_transport_toggle_play(engine);
engine_process_commands(engine);
printf("Transport: Toggled\n");
}
else if (strcasecmp(token, "clock") == 0) {
char *source_str = strtok(NULL, " \t");
if (!source_str) {
printf("Usage: clock internal|midi\n");
return 1;
}
if (strcasecmp(source_str, "internal") == 0) {
engine_set_clock_source(engine, CLOCK_SOURCE_INTERNAL);
engine_process_commands(engine);
printf("Clock source: Internal\n");
} else if (strcasecmp(source_str, "midi") == 0) {
engine_set_clock_source(engine, CLOCK_SOURCE_MIDI);
engine_process_commands(engine);
printf("Clock source: MIDI\n");
} else {
printf("Unknown clock source: %s\n", source_str);
}
}
else if (strcasecmp(token, "bpm") == 0) {
char *bpm_str = strtok(NULL, " \t");
if (!bpm_str) {
printf("Usage: bpm <value>\n");
return 1;
}
double bpm = atof(bpm_str);
if (bpm >= 1.0 && bpm <= 999.0) {
engine_set_bpm(engine, bpm);
engine_process_commands(engine);
printf("BPM set to: %.1f\n", bpm);
} else {
printf("BPM must be between 1.0 and 999.0\n");
}
}
else { else {
printf("Unknown command: %s\n", token); printf("Unknown command: %s\n", token);
} }