From e49ddd41e5549c1c6abab8005edd2e8b18ee0e09 Mon Sep 17 00:00:00 2001 From: yo mama Date: Sun, 25 Jan 2015 23:46:43 -0800 Subject: working copy...first push --- src/LV2-render_console.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/LV2-render_console.c (limited to 'src/LV2-render_console.c') diff --git a/src/LV2-render_console.c b/src/LV2-render_console.c new file mode 100644 index 0000000..1d421d2 --- /dev/null +++ b/src/LV2-render_console.c @@ -0,0 +1,73 @@ +#define _XOPEN_SOURCE 500 + +#include +#include +#include +#include + +#include "jalv_config.h" +#include "LV2-render_internal.h" + +#include "lv2/lv2plug.in/ns/extensions/ui/ui.h" + +static int +print_usage(const char* name, bool error) +{ + FILE* const os = error ? stderr : stdout; + fprintf(os, "Usage: %s [OPTION...] PLUGIN_URI\n", name); + fprintf(os, "Render a midi file with an LV2 plugin instrument.\n"); + fprintf(os, " -h Display this help and exit\n"); + fprintf(os, " -p Print control output changes to stdout\n"); + fprintf(os, " -c SYM=VAL Set control value (e.g. \"vol=1.4\")\n"); + fprintf(os, " -l DIR Load state from save directory\n"); + fprintf(os, " -d DIR Dump plugin <=> UI communication\n"); + fprintf(os, " -b SIZE Buffer size for plugin <=> UI communication\n"); + return error ? 1 : 0; +} + +int +jalv_init(int* argc, char*** argv, JalvOptions* opts) +{ + 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); + } else if ((*argv)[a][1] == 's') { + opts->show_ui = true; + } else if ((*argv)[a][1] == 'p') { + opts->print_controls = true; + } else if ((*argv)[a][1] == 'l') { + if (++a == *argc) { + fprintf(stderr, "Missing argument for -l\n"); + return 1; + } + opts->load = jalv_strdup((*argv)[a]); + } else if ((*argv)[a][1] == 'b') { + if (++a == *argc) { + fprintf(stderr, "Missing argument for -b\n"); + 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 { + fprintf(stderr, "Unknown option %s\n", (*argv)[a]); + return print_usage((*argv)[0], true); + } + } + + return 0; +} -- cgit v1.2.3-70-g09d2