diff options
author | David Robillard <d@drobilla.net> | 2013-12-25 19:11:30 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-12-25 19:11:30 +0000 |
commit | e0b7e4f26111f0e5dddf6a6b5f2285b39e1e0368 (patch) | |
tree | 81eb9322074a3af06bddd354150d0933f83e3178 | |
parent | d8f7e5c92f7e03bfd28cb137ce40536f9f36818f (diff) | |
download | jalv-e0b7e4f26111f0e5dddf6a6b5f2285b39e1e0368.tar.gz jalv-e0b7e4f26111f0e5dddf6a6b5f2285b39e1e0368.tar.bz2 jalv-e0b7e4f26111f0e5dddf6a6b5f2285b39e1e0368.zip |
Add -c option for setting controls from the command line (#816).
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5202 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/jalv.c | 24 | ||||
-rw-r--r-- | src/jalv_console.c | 15 | ||||
-rw-r--r-- | src/jalv_gtk.c | 2 | ||||
-rw-r--r-- | src/jalv_internal.h | 1 |
5 files changed, 43 insertions, 2 deletions
@@ -1,12 +1,13 @@ jalv (1.4.3) unstable; + * Add -c option for setting controls from the command line * Hide controls for ports with notOnGUI property in generic UI (based on patch from Robin Gareus) * Support ui:portMap feature to allow UIs to avoid hard-coded port indices (useful for compatibility and separately distributed UIs) * Add --no-menu option for jalv.gtk - -- David Robillard <d@drobilla.net> Wed, 18 Dec 2013 22:54:27 -0500 + -- David Robillard <d@drobilla.net> Wed, 25 Dec 2013 14:03:37 -0500 jalv (1.4.2) stable; @@ -795,6 +795,26 @@ jalv_emit_ui_events(Jalv* jalv) return true; } +static bool +jalv_apply_control_arg(Jalv* jalv, const char* s) +{ + char sym[256]; + float val = 0.0f; + if (sscanf(s, "%[^=]=%f", sym, &val) != 2) { + fprintf(stderr, "warning: Ignoring invalid value `%s'\n", s); + return false; + } + + struct Port* port = jalv_port_by_symbol(jalv, sym); + if (!port) { + fprintf(stderr, "warning: Ignoring value for unknown port `%s'\n", sym); + return false; + } + + port->control = val; + return true; +} + static void signal_handler(int ignored) { @@ -1120,6 +1140,10 @@ main(int argc, char** argv) jalv_apply_state(&jalv, state); } + for (char** c = jalv.opts.controls; *c; ++c) { + jalv_apply_control_arg(&jalv, *c); + } + /* Set Jack callbacks */ jack_set_process_callback(jalv.jack_client, &jack_process_cb, (void*)(&jalv)); diff --git a/src/jalv_console.c b/src/jalv_console.c index 0fb3125..b75bb3c 100644 --- a/src/jalv_console.c +++ b/src/jalv_console.c @@ -53,7 +53,11 @@ jalv_ui_port_event(Jalv* jalv, int jalv_init(int* argc, char*** argv, JalvOptions* opts) { - int a = 1; + opts->controls = malloc(sizeof(char*)); + opts->controls[0] = NULL; + + int n_controls = 0; + int a = 1; for (; a < *argc && (*argv)[a][0] == '-'; ++a) { if ((*argv)[a][1] == 'h') { return print_usage((*argv)[0], true); @@ -75,6 +79,15 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts) return 1; } opts->buffer_size = atoi((*argv)[a]); + } else if ((*argv)[a][1] == 'c') { + if (++a == *argc) { + fprintf(stderr, "Missing argument for -c\n"); + return 1; + } + opts->controls = realloc(opts->controls, + (++n_controls + 1) * sizeof(char*)); + opts->controls[n_controls - 1] = (*argv)[a]; + opts->controls[n_controls] = NULL; } else if ((*argv)[a][1] == 'd') { opts->dump = true; } else { diff --git a/src/jalv_gtk.c b/src/jalv_gtk.c index ed7c78b..bb92dbb 100644 --- a/src/jalv_gtk.c +++ b/src/jalv_gtk.c @@ -97,6 +97,8 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts) "Buffer size for plugin <=> UI communication", "SIZE"}, { "update-frequency", 'r', 0, G_OPTION_ARG_DOUBLE, &opts->update_rate, "UI update frequency", NULL}, + { "control", 'c', 0, G_OPTION_ARG_STRING_ARRAY, &opts->controls, + "UI update frequency", NULL}, { 0, 0, 0, 0, 0, 0, 0 } }; GError* error = NULL; const int err = gtk_init_with_args( diff --git a/src/jalv_internal.h b/src/jalv_internal.h index 4952d4f..4531ee6 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -87,6 +87,7 @@ typedef struct { typedef struct { char* uuid; ///< Session UUID char* load; ///< Path for state to load + char** controls; ///< Control values uint32_t buffer_size; ///< Plugin<=>UI communication buffer size double update_rate; ///< UI update rate in Hz int dump; ///< Dump communication iff true |