From ca2c8de12f5054b69d60d1b4755b56187e63405a Mon Sep 17 00:00:00 2001 From: Loic Coenen Date: Fri, 1 May 2026 21:12:37 +0000 Subject: [PATCH] feat: add transport control, clock source, and BPM commands to CLI Co-authored-by: aider (deepseek/deepseek-coder) --- cli.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/cli.c b/cli.c index 1309c90..43cabc6 100644 --- a/cli.c +++ b/cli.c @@ -50,6 +50,12 @@ int cli_process_line(Engine *engine, const char *line) { printf(" reset transport - Reset transport\n"); printf(" quantize off|beat|bar - Set quantize mode\n"); printf(" threshold - 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 - Set BPM (1.0-999.0)\n"); printf(" help - Show this help\n"); printf(" quit - Exit CLI\n"); return 1; @@ -89,7 +95,8 @@ int cli_process_line(Engine *engine, const char *line) { int idx = atoi(idx_str); engine_reset_clip(engine, idx); } else if (strcasecmp(sub, "transport") == 0) { - engine_reset_transport(engine); + engine_transport_stop(engine); + engine_process_commands(engine); } else { 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); 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 \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 { printf("Unknown command: %s\n", token); }