feat: implement URI-based plugin loading and GUI text input for Carla

Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-02 22:35:55 +00:00
parent 426e36087b
commit 12a2f8ede2
2 changed files with 129 additions and 3 deletions

48
gui.c
View File

@@ -9,6 +9,7 @@
#include "engine.h"
#include "gui.h"
#include "dispatcher.h"
#include "carla.h"
/* microui includes */
#define MU_IMPLEMENTATION
@@ -44,6 +45,12 @@ static float bpm = 120.0f;
static int loop_length = 8; /* beats */
static int current_beat = 0;
/* Carla host and plugin URI input */
static CarlaHost carla_host;
static char plugin_uri_input[256];
static int plugin_uri_input_len = 0;
static int selected_channel = 0;
/* ---------------------------------------------------------------------------
* drawing helpers (stubs for microui)
* ------------------------------------------------------------------------- */
@@ -114,6 +121,27 @@ static void gui_update(void)
}
}
/* Plugin URI input */
mu_layout_row(ctx, 2, (int[]) { 60, -1 }, 0);
mu_label(ctx, "URI:");
{
char display[256];
if (plugin_uri_input_len > 0) {
snprintf(display, sizeof(display), "%s_", plugin_uri_input);
} else {
snprintf(display, sizeof(display), "type URI here...");
}
mu_label(ctx, display);
}
mu_layout_row(ctx, 1, (int[]) { -1 }, 0);
if (mu_button(ctx, "Add Plugin")) {
if (plugin_uri_input_len > 0) {
carla_add_plugin(&carla_host, selected_channel, plugin_uri_input, PLUGIN_TYPE_INTERNAL);
plugin_uri_input_len = 0;
plugin_uri_input[0] = '\0';
}
}
mu_end_window(ctx);
}
@@ -127,6 +155,9 @@ int gui_main(Engine *engine)
{
g_engine = engine;
/* Initialize Carla host */
carla_init(&carla_host, engine->client);
/* initialise microui */
ctx = malloc(sizeof(mu_Context));
if (!ctx) return -1;
@@ -148,6 +179,22 @@ int gui_main(Engine *engine)
/* handle input */
int ch = getch();
if (ch != ERR) {
/* Handle text input for plugin URI */
if (ch >= 32 && ch <= 126 && plugin_uri_input_len < 255) {
plugin_uri_input[plugin_uri_input_len++] = (char)ch;
plugin_uri_input[plugin_uri_input_len] = '\0';
} else if (ch == 127 || ch == KEY_BACKSPACE) {
if (plugin_uri_input_len > 0) {
plugin_uri_input[--plugin_uri_input_len] = '\0';
}
} else if (ch == '\n' || ch == '\r') {
/* Submit plugin URI */
if (plugin_uri_input_len > 0) {
carla_add_plugin(&carla_host, selected_channel, plugin_uri_input, PLUGIN_TYPE_INTERNAL);
plugin_uri_input_len = 0;
plugin_uri_input[0] = '\0';
}
}
switch (ch) {
case 'q':
case 'Q':
@@ -212,6 +259,7 @@ int gui_main(Engine *engine)
}
/* cleanup */
carla_cleanup(&carla_host);
endwin();
free(ctx);
return 0;