feat: implement clip deletion via 'd' key and CMD_DELETE command
This commit is contained in:
committed by
Loic Coenen (aider)
parent
18eb27e9c8
commit
2c30bba5fa
@@ -16,6 +16,7 @@ typedef enum {
|
||||
CMD_ADD_SCENE,
|
||||
CMD_REMOVE_SCENE,
|
||||
CMD_SET_SCENE,
|
||||
CMD_DELETE,
|
||||
} cmd_type_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -279,6 +279,24 @@ static void exec_command(command_t cmd, jack_client_t *client) {
|
||||
break;
|
||||
}
|
||||
|
||||
case CMD_DELETE: {
|
||||
int dch = cmd.channel;
|
||||
if (dch >= 0 && dch < MAX_CHANNELS) {
|
||||
int dsc_idx = atomic_load(&channels[dch].current_scene);
|
||||
scene_t *dsc = &channels[dch].scenes[dsc_idx];
|
||||
// Reset state to IDLE
|
||||
atomic_store(&dsc->state, STATE_IDLE);
|
||||
atomic_store(&dsc->prev_state, -1);
|
||||
// Clear loop data
|
||||
atomic_store(&dsc->loop_count, 0);
|
||||
atomic_store(&dsc->record_pos, 0);
|
||||
atomic_store(&dsc->playback_pos, 0);
|
||||
// Zero the audio buffer
|
||||
memset(dsc->loop.audio_buffer, 0, sizeof(dsc->loop.audio_buffer));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -101,6 +101,14 @@ static void *pipe_thread_func(void *arg) {
|
||||
} else if (strcmp(line, "save") == 0) {
|
||||
command_t cmd = {.type = CMD_SAVE, .channel = -1, .data = 0};
|
||||
queue_push(&cmd_queue_main_fifo, cmd);
|
||||
} else if (strncmp(line, "delete", 6) == 0) {
|
||||
int ch = -1;
|
||||
const char *arg = line + 6;
|
||||
while (*arg == ' ') arg++;
|
||||
if (*arg) ch = atoi(arg);
|
||||
fprintf(stderr, "FIFO RECEIVED delete\n");
|
||||
command_t cmd = {.type = CMD_DELETE, .channel = ch, .data = 0};
|
||||
queue_push(&cmd_queue_main_fifo, cmd);
|
||||
} else if (strncmp(line, "from ", 5) == 0) {
|
||||
const char *port = line + 5;
|
||||
fprintf(stderr, "FIFO RECEIVED from: %s\n", port);
|
||||
|
||||
Reference in New Issue
Block a user