feat: add script module for note-to-command mapping with FIFO support
This commit is contained in:
committed by
Loic Coenen (aider)
parent
16a800209f
commit
f776b8a361
@@ -12,6 +12,7 @@
|
||||
#include "carla_host.h"
|
||||
#include "client_cmd.h"
|
||||
#include "plugins.h"
|
||||
#include "script.h"
|
||||
#include <CarlaHost.h>
|
||||
|
||||
/* ---------- FIFO command helper ---------- */
|
||||
@@ -43,6 +44,7 @@ static const char *clip_state_string(ClipState s) { (void)s; return "?"; }
|
||||
/* status FIFO path */
|
||||
#define STATUS_FIFO "/tmp/looper_status"
|
||||
#define CMD_FIFO "/tmp/looper_cmd"
|
||||
#define NOTES_FIFO "/tmp/looper_notes"
|
||||
|
||||
/* Per‑cell state array (indexed by row*GRID_COLS+col) */
|
||||
typedef enum { STATE_IDLE, STATE_RECORD, STATE_LOOPING, STATE_PAUSED } ChannelState;
|
||||
@@ -193,6 +195,9 @@ void tui_init(void) {
|
||||
cell_state[i] = STATE_IDLE;
|
||||
/* open the JACK client used for Carla plugins */
|
||||
carla_init_jack();
|
||||
/* create note FIFO (for scripted controller input) */
|
||||
unlink(NOTES_FIFO);
|
||||
mkfifo(NOTES_FIFO, 0666);
|
||||
}
|
||||
|
||||
/* ---------- TUI run ---------- */
|
||||
@@ -229,6 +234,28 @@ void tui_run(void) {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
/* read any available note events (for script macros) */
|
||||
int nfd = open(NOTES_FIFO, O_RDONLY | O_NONBLOCK);
|
||||
if (nfd >= 0) {
|
||||
char nbuf[256];
|
||||
int m = read(nfd, nbuf, sizeof(nbuf)-1);
|
||||
if (m > 0) {
|
||||
nbuf[m] = '\0';
|
||||
char *p = nbuf;
|
||||
while (*p) {
|
||||
char *nl = strchr(p, '\n');
|
||||
if (nl) *nl = '\0';
|
||||
int note = atoi(p);
|
||||
script_handle_note(note);
|
||||
if (nl) {
|
||||
*nl = '\n';
|
||||
p = nl + 1;
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
close(nfd);
|
||||
}
|
||||
|
||||
if (in_colon) {
|
||||
int chc = getch();
|
||||
if (chc == '\n') {
|
||||
@@ -374,6 +401,7 @@ void tui_cleanup(void) {
|
||||
/* delete FIFOs */
|
||||
unlink(STATUS_FIFO);
|
||||
unlink(CMD_FIFO);
|
||||
unlink(NOTES_FIFO);
|
||||
/* close the Carla JACK client */
|
||||
carla_cleanup_jack();
|
||||
curs_set(1); endwin();
|
||||
|
||||
Reference in New Issue
Block a user