diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/jalv_console.c | 42 |
2 files changed, 41 insertions, 4 deletions
@@ -1,13 +1,14 @@ jalv (1.4.7) unstable; * Set Jack port order metadata + * Add command prompt to console version for changing controls * Exit on Jack shutdown (Patch from Robin Gareus) * Report Jack latency (Patch from Robin Gareus) * Exit GUI versions on interrupt * Fix semaphore correctness issues * Use moc-qt4 if present for systems with multiple Qt versions - -- David Robillard <d@drobilla.net> Sat, 21 Feb 2015 23:26:19 -0500 + -- David Robillard <d@drobilla.net> Thu, 05 Mar 2015 23:18:11 -0500 jalv (1.4.6) stable; diff --git a/src/jalv_console.c b/src/jalv_console.c index 0632098..79cde0f 100644 --- a/src/jalv_console.c +++ b/src/jalv_console.c @@ -116,6 +116,30 @@ jalv_native_ui_type(Jalv* jalv) return NULL; } +static void +jalv_process_command(Jalv* jalv, const char* cmd) +{ + char sym[64]; + float value; + if (sscanf(cmd, "%[a-zA-Z0-9] = %f", sym, &value) == 2) { + struct Port* port = NULL; + for (uint32_t i = 0; i < jalv->num_ports; ++i) { + struct Port* p = &jalv->ports[i]; + const LilvNode* s = lilv_port_get_symbol(jalv->plugin, p->lilv_port); + if (!strcmp(lilv_node_as_string(s), sym)) { + port = p; + break; + } + } + if (port) { + port->control = value; + printf("%-*s = %f\n", jalv->longest_sym, sym, value); + } else { + fprintf(stderr, "error: no port `%s'\n", sym); + } + } +} + int jalv_open_ui(Jalv* jalv) { @@ -142,10 +166,22 @@ jalv_open_ui(Jalv* jalv) show_iface->hide(suil_instance_get_handle(jalv->ui_instance)); - // Caller waits on the done sem, so increment it again to exit - zix_sem_post(jalv->done); - } + } else { + // Primitive command prompt for setting control values + while (!zix_sem_try_wait(jalv->done)) { + char line[128]; + printf("> "); + if (fgets(line, sizeof(line), stdin)) { + jalv_process_command(jalv, line); + } else { + break; + } + } + } + // Caller waits on the done sem, so increment it again to exit + zix_sem_post(jalv->done); + return 0; } |