summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/bench.h18
-rw-r--r--utils/lilv-bench.c18
-rw-r--r--utils/lv2apply.c525
-rw-r--r--utils/lv2bench.c436
-rw-r--r--utils/lv2info.c783
-rw-r--r--utils/lv2ls.c92
-rw-r--r--utils/uri_table.h56
7 files changed, 961 insertions, 967 deletions
diff --git a/utils/bench.h b/utils/bench.h
index a04996b..28e5221 100644
--- a/utils/bench.h
+++ b/utils/bench.h
@@ -30,24 +30,24 @@ typedef struct timespec BenchmarkTime;
static inline double
bench_elapsed_s(const BenchmarkTime* start, const BenchmarkTime* end)
{
- return ((end->tv_sec - start->tv_sec)
- + ((end->tv_nsec - start->tv_nsec) * 0.000000001));
+ return ((end->tv_sec - start->tv_sec) +
+ ((end->tv_nsec - start->tv_nsec) * 0.000000001));
}
static inline BenchmarkTime
bench_start(void)
{
- BenchmarkTime start_t;
- clock_gettime(CLOCK_REALTIME, &start_t);
- return start_t;
+ BenchmarkTime start_t;
+ clock_gettime(CLOCK_REALTIME, &start_t);
+ return start_t;
}
static inline double
bench_end(const BenchmarkTime* start_t)
{
- BenchmarkTime end_t;
- clock_gettime(CLOCK_REALTIME, &end_t);
- return bench_elapsed_s(start_t, &end_t);
+ BenchmarkTime end_t;
+ clock_gettime(CLOCK_REALTIME, &end_t);
+ return bench_elapsed_s(start_t, &end_t);
}
-#endif /* BENCH_H */
+#endif /* BENCH_H */
diff --git a/utils/lilv-bench.c b/utils/lilv-bench.c
index 59e49fe..3068123 100644
--- a/utils/lilv-bench.c
+++ b/utils/lilv-bench.c
@@ -19,16 +19,16 @@
int
main(int argc, char** argv)
{
- LilvWorld* world = lilv_world_new();
- lilv_world_load_all(world);
+ LilvWorld* world = lilv_world_new();
+ lilv_world_load_all(world);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- LILV_FOREACH(plugins, p, plugins) {
- const LilvPlugin* plugin = lilv_plugins_get(plugins, p);
- lilv_plugin_get_class(plugin);
- }
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ LILV_FOREACH (plugins, p, plugins) {
+ const LilvPlugin* plugin = lilv_plugins_get(plugins, p);
+ lilv_plugin_get_class(plugin);
+ }
- lilv_world_free(world);
+ lilv_world_free(world);
- return 0;
+ return 0;
}
diff --git a/utils/lv2apply.c b/utils/lv2apply.c
index 1d11c50..0a1123a 100644
--- a/utils/lv2apply.c
+++ b/utils/lv2apply.c
@@ -28,73 +28,71 @@
#include <string.h>
#if defined(__GNUC__)
-# define LILV_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1)))
+# define LILV_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1)))
#else
-# define LILV_LOG_FUNC(fmt, arg1)
+# define LILV_LOG_FUNC(fmt, arg1)
#endif
/** Control port value set from the command line */
typedef struct Param {
- const char* sym; ///< Port symbol
- float value; ///< Control value
+ const char* sym; ///< Port symbol
+ float value; ///< Control value
} Param;
/** Port type (only float ports are supported) */
-typedef enum {
- TYPE_CONTROL,
- TYPE_AUDIO
-} PortType;
+typedef enum { TYPE_CONTROL, TYPE_AUDIO } PortType;
/** Runtime port information */
typedef struct {
- const LilvPort* lilv_port; ///< Port description
- PortType type; ///< Datatype
- uint32_t index; ///< Port index
- float value; ///< Control value (if applicable)
- bool is_input; ///< True iff an input port
- bool optional; ///< True iff connection optional
+ const LilvPort* lilv_port; ///< Port description
+ PortType type; ///< Datatype
+ uint32_t index; ///< Port index
+ float value; ///< Control value (if applicable)
+ bool is_input; ///< True iff an input port
+ bool optional; ///< True iff connection optional
} Port;
/** Application state */
typedef struct {
- LilvWorld* world;
- const LilvPlugin* plugin;
- LilvInstance* instance;
- const char* in_path;
- const char* out_path;
- SNDFILE* in_file;
- SNDFILE* out_file;
- unsigned n_params;
- Param* params;
- unsigned n_ports;
- unsigned n_audio_in;
- unsigned n_audio_out;
- Port* ports;
+ LilvWorld* world;
+ const LilvPlugin* plugin;
+ LilvInstance* instance;
+ const char* in_path;
+ const char* out_path;
+ SNDFILE* in_file;
+ SNDFILE* out_file;
+ unsigned n_params;
+ Param* params;
+ unsigned n_ports;
+ unsigned n_audio_in;
+ unsigned n_audio_out;
+ Port* ports;
} LV2Apply;
-static int fatal(LV2Apply* self, int status, const char* fmt, ...);
+static int
+fatal(LV2Apply* self, int status, const char* fmt, ...);
/** Open a sound file with error handling. */
static SNDFILE*
sopen(LV2Apply* self, const char* path, int mode, SF_INFO* fmt)
{
- SNDFILE* file = sf_open(path, mode, fmt);
- const int st = sf_error(file);
- if (st) {
- fatal(self, 1, "Failed to open %s (%s)\n", path, sf_error_number(st));
- return NULL;
- }
- return file;
+ SNDFILE* file = sf_open(path, mode, fmt);
+ const int st = sf_error(file);
+ if (st) {
+ fatal(self, 1, "Failed to open %s (%s)\n", path, sf_error_number(st));
+ return NULL;
+ }
+ return file;
}
/** Close a sound file with error handling. */
static void
sclose(const char* path, SNDFILE* file)
{
- int st = 0;
- if (file && (st = sf_close(file))) {
- fatal(NULL, 1, "Failed to close %s (%s)\n", path, sf_error_number(st));
- }
+ int st = 0;
+ if (file && (st = sf_close(file))) {
+ fatal(NULL, 1, "Failed to close %s (%s)\n", path, sf_error_number(st));
+ }
}
/**
@@ -106,24 +104,24 @@ sclose(const char* path, SNDFILE* file)
static bool
sread(SNDFILE* file, unsigned file_chans, float* buf, unsigned buf_chans)
{
- const sf_count_t n_read = sf_readf_float(file, buf, 1);
- for (unsigned i = file_chans - 1; i < buf_chans; ++i) {
- buf[i] = buf[i % file_chans];
- }
- return n_read == 1;
+ const sf_count_t n_read = sf_readf_float(file, buf, 1);
+ for (unsigned i = file_chans - 1; i < buf_chans; ++i) {
+ buf[i] = buf[i % file_chans];
+ }
+ return n_read == 1;
}
/** Clean up all resources. */
static int
cleanup(int status, LV2Apply* self)
{
- sclose(self->in_path, self->in_file);
- sclose(self->out_path, self->out_file);
- lilv_instance_free(self->instance);
- lilv_world_free(self->world);
- free(self->ports);
- free(self->params);
- return status;
+ sclose(self->in_path, self->in_file);
+ sclose(self->out_path, self->out_file);
+ lilv_instance_free(self->instance);
+ lilv_world_free(self->world);
+ free(self->ports);
+ free(self->params);
+ return status;
}
/** Print a fatal error and clean up for exit. */
@@ -131,12 +129,12 @@ LILV_LOG_FUNC(3, 4)
static int
fatal(LV2Apply* self, int status, const char* fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- fprintf(stderr, "error: ");
- vfprintf(stderr, fmt, args);
- va_end(args);
- return self ? cleanup(status, self) : status;
+ va_list args;
+ va_start(args, fmt);
+ fprintf(stderr, "error: ");
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+ return self ? cleanup(status, self) : status;
}
/**
@@ -145,225 +143,226 @@ fatal(LV2Apply* self, int status, const char* fmt, ...)
static int
create_ports(LV2Apply* self)
{
- LilvWorld* world = self->world;
- const uint32_t n_ports = lilv_plugin_get_num_ports(self->plugin);
-
- self->n_ports = n_ports;
- self->ports = (Port*)calloc(self->n_ports, sizeof(Port));
-
- /* Get default values for all ports */
- float* values = (float*)calloc(n_ports, sizeof(float));
- lilv_plugin_get_port_ranges_float(self->plugin, NULL, NULL, values);
-
- LilvNode* lv2_InputPort = lilv_new_uri(world, LV2_CORE__InputPort);
- LilvNode* lv2_OutputPort = lilv_new_uri(world, LV2_CORE__OutputPort);
- LilvNode* lv2_AudioPort = lilv_new_uri(world, LV2_CORE__AudioPort);
- LilvNode* lv2_ControlPort = lilv_new_uri(world, LV2_CORE__ControlPort);
- LilvNode* lv2_connectionOptional = lilv_new_uri(world, LV2_CORE__connectionOptional);
-
- for (uint32_t i = 0; i < n_ports; ++i) {
- Port* port = &self->ports[i];
- const LilvPort* lport = lilv_plugin_get_port_by_index(self->plugin, i);
-
- port->lilv_port = lport;
- port->index = i;
- port->value = isnan(values[i]) ? 0.0f : values[i];
- port->optional = lilv_port_has_property(
- self->plugin, lport, lv2_connectionOptional);
-
- /* Check if port is an input or output */
- if (lilv_port_is_a(self->plugin, lport, lv2_InputPort)) {
- port->is_input = true;
- } else if (!lilv_port_is_a(self->plugin, lport, lv2_OutputPort) &&
- !port->optional) {
- return fatal(self, 1, "Port %u is neither input nor output\n", i);
- }
-
- /* Check if port is an audio or control port */
- if (lilv_port_is_a(self->plugin, lport, lv2_ControlPort)) {
- port->type = TYPE_CONTROL;
- } else if (lilv_port_is_a(self->plugin, lport, lv2_AudioPort)) {
- port->type = TYPE_AUDIO;
- if (port->is_input) {
- ++self->n_audio_in;
- } else {
- ++self->n_audio_out;
- }
- } else if (!port->optional) {
- return fatal(self, 1, "Port %u has unsupported type\n", i);
- }
- }
-
- lilv_node_free(lv2_connectionOptional);
- lilv_node_free(lv2_ControlPort);
- lilv_node_free(lv2_AudioPort);
- lilv_node_free(lv2_OutputPort);
- lilv_node_free(lv2_InputPort);
- free(values);
-
- return 0;
+ LilvWorld* world = self->world;
+ const uint32_t n_ports = lilv_plugin_get_num_ports(self->plugin);
+
+ self->n_ports = n_ports;
+ self->ports = (Port*)calloc(self->n_ports, sizeof(Port));
+
+ /* Get default values for all ports */
+ float* values = (float*)calloc(n_ports, sizeof(float));
+ lilv_plugin_get_port_ranges_float(self->plugin, NULL, NULL, values);
+
+ LilvNode* lv2_InputPort = lilv_new_uri(world, LV2_CORE__InputPort);
+ LilvNode* lv2_OutputPort = lilv_new_uri(world, LV2_CORE__OutputPort);
+ LilvNode* lv2_AudioPort = lilv_new_uri(world, LV2_CORE__AudioPort);
+ LilvNode* lv2_ControlPort = lilv_new_uri(world, LV2_CORE__ControlPort);
+ LilvNode* lv2_connectionOptional =
+ lilv_new_uri(world, LV2_CORE__connectionOptional);
+
+ for (uint32_t i = 0; i < n_ports; ++i) {
+ Port* port = &self->ports[i];
+ const LilvPort* lport = lilv_plugin_get_port_by_index(self->plugin, i);
+
+ port->lilv_port = lport;
+ port->index = i;
+ port->value = isnan(values[i]) ? 0.0f : values[i];
+ port->optional =
+ lilv_port_has_property(self->plugin, lport, lv2_connectionOptional);
+
+ /* Check if port is an input or output */
+ if (lilv_port_is_a(self->plugin, lport, lv2_InputPort)) {
+ port->is_input = true;
+ } else if (!lilv_port_is_a(self->plugin, lport, lv2_OutputPort) &&
+ !port->optional) {
+ return fatal(self, 1, "Port %u is neither input nor output\n", i);
+ }
+
+ /* Check if port is an audio or control port */
+ if (lilv_port_is_a(self->plugin, lport, lv2_ControlPort)) {
+ port->type = TYPE_CONTROL;
+ } else if (lilv_port_is_a(self->plugin, lport, lv2_AudioPort)) {
+ port->type = TYPE_AUDIO;
+ if (port->is_input) {
+ ++self->n_audio_in;
+ } else {
+ ++self->n_audio_out;
+ }
+ } else if (!port->optional) {
+ return fatal(self, 1, "Port %u has unsupported type\n", i);
+ }
+ }
+
+ lilv_node_free(lv2_connectionOptional);
+ lilv_node_free(lv2_ControlPort);
+ lilv_node_free(lv2_AudioPort);
+ lilv_node_free(lv2_OutputPort);
+ lilv_node_free(lv2_InputPort);
+ free(values);
+
+ return 0;
}
static void
print_version(void)
{
- printf(
- "lv2apply (lilv) " LILV_VERSION "\n"
- "Copyright 2007-2019 David Robillard <http://drobilla.net>\n"
- "License: <http://www.opensource.org/licenses/isc-license>\n"
- "This is free software: you are free to change and redistribute it.\n"
- "There is NO WARRANTY, to the extent permitted by law.\n");
+ printf("lv2apply (lilv) " LILV_VERSION "\n"
+ "Copyright 2007-2019 David Robillard <http://drobilla.net>\n"
+ "License: <http://www.opensource.org/licenses/isc-license>\n"
+ "This is free software: you are free to change and redistribute it.\n"
+ "There is NO WARRANTY, to the extent permitted by law.\n");
}
static int
print_usage(int status)
{
- fprintf(status ? stderr : stdout,
- "Usage: lv2apply [OPTION]... PLUGIN_URI\n"
- "Apply an LV2 plugin to an audio file.\n\n"
- " -i IN_FILE Input file\n"
- " -o OUT_FILE Output file\n"
- " -c SYM VAL Control value\n"
- " --help Display this help and exit\n"
- " --version Display version information and exit\n");
- return status;
+ fprintf(status ? stderr : stdout,
+ "Usage: lv2apply [OPTION]... PLUGIN_URI\n"
+ "Apply an LV2 plugin to an audio file.\n\n"
+ " -i IN_FILE Input file\n"
+ " -o OUT_FILE Output file\n"
+ " -c SYM VAL Control value\n"
+ " --help Display this help and exit\n"
+ " --version Display version information and exit\n");
+ return status;
}
int
main(int argc, char** argv)
{
- LV2Apply self = {
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 0, NULL
- };
-
- /* Parse command line arguments */
- const char* plugin_uri = NULL;
- for (int i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "--version")) {
- free(self.params);
- print_version();
- return 0;
- }
-
- if (!strcmp(argv[i], "--help")) {
- free(self.params);
- return print_usage(0);
- }
-
- if (!strcmp(argv[i], "-i")) {
- self.in_path = argv[++i];
- } else if (!strcmp(argv[i], "-o")) {
- self.out_path = argv[++i];
- } else if (!strcmp(argv[i], "-c")) {
- if (argc < i + 3) {
- return fatal(&self, 1, "Missing argument for -c\n");
- }
- self.params = (Param*)realloc(self.params,
- ++self.n_params * sizeof(Param));
- self.params[self.n_params - 1].sym = argv[++i];
- self.params[self.n_params - 1].value = atof(argv[++i]);
- } else if (argv[i][0] == '-') {
- free(self.params);
- return print_usage(1);
- } else if (i == argc - 1) {
- plugin_uri = argv[i];
- }
- }
-
- /* Check that required arguments are given */
- if (!self.in_path || !self.out_path || !plugin_uri) {
- free(self.params);
- return print_usage(1);
- }
-
- /* Create world and plugin URI */
- self.world = lilv_world_new();
- LilvNode* uri = lilv_new_uri(self.world, plugin_uri);
- if (!uri) {
- return fatal(&self, 2, "Invalid plugin URI <%s>\n", plugin_uri);
- }
-
- /* Discover world */
- lilv_world_load_all(self.world);
-
- /* Get plugin */
- const LilvPlugins* plugins = lilv_world_get_all_plugins(self.world);
- const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, uri);
- lilv_node_free(uri);
- if (!(self.plugin = plugin)) {
- return fatal(&self, 3, "Plugin <%s> not found\n", plugin_uri);
- }
-
- /* Open input file */
- SF_INFO in_fmt = { 0, 0, 0, 0, 0, 0 };
- if (!(self.in_file = sopen(&self, self.in_path, SFM_READ, &in_fmt))) {
- return 4;
- }
-
- /* Create port structures */
- if (create_ports(&self)) {
- return 5;
- }
-
- if (self.n_audio_in == 0 ||
- (in_fmt.channels != (int)self.n_audio_in && in_fmt.channels != 1)) {
- return fatal(&self, 6, "Unable to map %d inputs to %u ports\n",
- in_fmt.channels, self.n_audio_in);
- }
-
- /* Set control values */
- for (unsigned i = 0; i < self.n_params; ++i) {
- const Param* param = &self.params[i];
- LilvNode* sym = lilv_new_string(self.world, param->sym);
- const LilvPort* port = lilv_plugin_get_port_by_symbol(plugin, sym);
- lilv_node_free(sym);
- if (!port) {
- return fatal(&self, 7, "Unknown port `%s'\n", param->sym);
- }
-
- self.ports[lilv_port_get_index(plugin, port)].value = param->value;
- }
-
- /* Open output file */
- SF_INFO out_fmt = in_fmt;
- out_fmt.channels = self.n_audio_out;
- if (!(self.out_file = sopen(&self, self.out_path, SFM_WRITE, &out_fmt))) {
- free(self.ports);
- return 8;
- }
-
- /* Instantiate plugin and connect ports */
- const uint32_t n_ports = lilv_plugin_get_num_ports(plugin);
- float in_buf[self.n_audio_in > 0 ? self.n_audio_in : 1];
- float out_buf[self.n_audio_out > 0 ? self.n_audio_out : 1];
- self.instance = lilv_plugin_instantiate(
- self.plugin, in_fmt.samplerate, NULL);
- for (uint32_t p = 0, i = 0, o = 0; p < n_ports; ++p) {
- if (self.ports[p].type == TYPE_CONTROL) {
- lilv_instance_connect_port(self.instance, p, &self.ports[p].value);
- } else if (self.ports[p].type == TYPE_AUDIO) {
- if (self.ports[p].is_input) {
- lilv_instance_connect_port(self.instance, p, in_buf + i++);
- } else {
- lilv_instance_connect_port(self.instance, p, out_buf + o++);
- }
- } else {
- lilv_instance_connect_port(self.instance, p, NULL);
- }
- }
-
- /* Ports are now connected to buffers in interleaved format, so we can run
- a single frame at a time and avoid having to interleave buffers to
- read/write from/to sndfile. */
-
- lilv_instance_activate(self.instance);
- while (sread(self.in_file, in_fmt.channels, in_buf, self.n_audio_in)) {
- lilv_instance_run(self.instance, 1);
- if (sf_writef_float(self.out_file, out_buf, 1) != 1) {
- return fatal(&self, 9, "Failed to write to output file\n");
- }
- }
- lilv_instance_deactivate(self.instance);
-
- return cleanup(0, &self);
+ LV2Apply self = {
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 0, NULL};
+
+ /* Parse command line arguments */
+ const char* plugin_uri = NULL;
+ for (int i = 1; i < argc; ++i) {
+ if (!strcmp(argv[i], "--version")) {
+ free(self.params);
+ print_version();
+ return 0;
+ }
+
+ if (!strcmp(argv[i], "--help")) {
+ free(self.params);
+ return print_usage(0);
+ }
+
+ if (!strcmp(argv[i], "-i")) {
+ self.in_path = argv[++i];
+ } else if (!strcmp(argv[i], "-o")) {
+ self.out_path = argv[++i];
+ } else if (!strcmp(argv[i], "-c")) {
+ if (argc < i + 3) {
+ return fatal(&self, 1, "Missing argument for -c\n");
+ }
+ self.params =
+ (Param*)realloc(self.params, ++self.n_params * sizeof(Param));
+ self.params[self.n_params - 1].sym = argv[++i];
+ self.params[self.n_params - 1].value = atof(argv[++i]);
+ } else if (argv[i][0] == '-') {
+ free(self.params);
+ return print_usage(1);
+ } else if (i == argc - 1) {
+ plugin_uri = argv[i];
+ }
+ }
+
+ /* Check that required arguments are given */
+ if (!self.in_path || !self.out_path || !plugin_uri) {
+ free(self.params);
+ return print_usage(1);
+ }
+
+ /* Create world and plugin URI */
+ self.world = lilv_world_new();
+ LilvNode* uri = lilv_new_uri(self.world, plugin_uri);
+ if (!uri) {
+ return fatal(&self, 2, "Invalid plugin URI <%s>\n", plugin_uri);
+ }
+
+ /* Discover world */
+ lilv_world_load_all(self.world);
+
+ /* Get plugin */
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(self.world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, uri);
+ lilv_node_free(uri);
+ if (!(self.plugin = plugin)) {
+ return fatal(&self, 3, "Plugin <%s> not found\n", plugin_uri);
+ }
+
+ /* Open input file */
+ SF_INFO in_fmt = {0, 0, 0, 0, 0, 0};
+ if (!(self.in_file = sopen(&self, self.in_path, SFM_READ, &in_fmt))) {
+ return 4;
+ }
+
+ /* Create port structures */
+ if (create_ports(&self)) {
+ return 5;
+ }
+
+ if (self.n_audio_in == 0 ||
+ (in_fmt.channels != (int)self.n_audio_in && in_fmt.channels != 1)) {
+ return fatal(&self,
+ 6,
+ "Unable to map %d inputs to %u ports\n",
+ in_fmt.channels,
+ self.n_audio_in);
+ }
+
+ /* Set control values */
+ for (unsigned i = 0; i < self.n_params; ++i) {
+ const Param* param = &self.params[i];
+ LilvNode* sym = lilv_new_string(self.world, param->sym);
+ const LilvPort* port = lilv_plugin_get_port_by_symbol(plugin, sym);
+ lilv_node_free(sym);
+ if (!port) {
+ return fatal(&self, 7, "Unknown port `%s'\n", param->sym);
+ }
+
+ self.ports[lilv_port_get_index(plugin, port)].value = param->value;
+ }
+
+ /* Open output file */
+ SF_INFO out_fmt = in_fmt;
+ out_fmt.channels = self.n_audio_out;
+ if (!(self.out_file = sopen(&self, self.out_path, SFM_WRITE, &out_fmt))) {
+ free(self.ports);
+ return 8;
+ }
+
+ /* Instantiate plugin and connect ports */
+ const uint32_t n_ports = lilv_plugin_get_num_ports(plugin);
+ float in_buf[self.n_audio_in > 0 ? self.n_audio_in : 1];
+ float out_buf[self.n_audio_out > 0 ? self.n_audio_out : 1];
+ self.instance = lilv_plugin_instantiate(self.plugin, in_fmt.samplerate, NULL);
+ for (uint32_t p = 0, i = 0, o = 0; p < n_ports; ++p) {
+ if (self.ports[p].type == TYPE_CONTROL) {
+ lilv_instance_connect_port(self.instance, p, &self.ports[p].value);
+ } else if (self.ports[p].type == TYPE_AUDIO) {
+ if (self.ports[p].is_input) {
+ lilv_instance_connect_port(self.instance, p, in_buf + i++);
+ } else {
+ lilv_instance_connect_port(self.instance, p, out_buf + o++);
+ }
+ } else {
+ lilv_instance_connect_port(self.instance, p, NULL);
+ }
+ }
+
+ /* Ports are now connected to buffers in interleaved format, so we can run
+ a single frame at a time and avoid having to interleave buffers to
+ read/write from/to sndfile. */
+
+ lilv_instance_activate(self.instance);
+ while (sread(self.in_file, in_fmt.channels, in_buf, self.n_audio_in)) {
+ lilv_instance_run(self.instance, 1);
+ if (sf_writef_float(self.out_file, out_buf, 1) != 1) {
+ return fatal(&self, 9, "Failed to write to output file\n");
+ }
+ }
+ lilv_instance_deactivate(self.instance);
+
+ return cleanup(0, &self);
}
diff --git a/utils/lv2bench.c b/utils/lv2bench.c
index 000f062..7365b5b 100644
--- a/utils/lv2bench.c
+++ b/utils/lv2bench.c
@@ -47,236 +47,238 @@ static bool full_output = false;
static void
print_version(void)
{
- printf(
- "lv2bench (lilv) " LILV_VERSION "\n"
- "Copyright 2012-2019 David Robillard <http://drobilla.net>\n"
- "License: <http://www.opensource.org/licenses/isc-license>\n"
- "This is free software: you are free to change and redistribute it.\n"
- "There is NO WARRANTY, to the extent permitted by law.\n");
+ printf("lv2bench (lilv) " LILV_VERSION "\n"
+ "Copyright 2012-2019 David Robillard <http://drobilla.net>\n"
+ "License: <http://www.opensource.org/licenses/isc-license>\n"
+ "This is free software: you are free to change and redistribute it.\n"
+ "There is NO WARRANTY, to the extent permitted by law.\n");
}
static void
print_usage(void)
{
- printf("lv2bench - Benchmark all installed and supported LV2 plugins.\n");
- printf("Usage: lv2bench [OPTIONS] [PLUGIN_URI]\n");
- printf("\n");
- printf(" -b BLOCK_SIZE Specify block size, in audio frames.\n");
- printf(" -f, --full Full plottable output.\n");
- printf(" -h, --help Display this help and exit.\n");
- printf(" -n FRAMES Total number of audio frames to process\n");
- printf(" --version Display version information and exit\n");
+ printf("lv2bench - Benchmark all installed and supported LV2 plugins.\n");
+ printf("Usage: lv2bench [OPTIONS] [PLUGIN_URI]\n");
+ printf("\n");
+ printf(" -b BLOCK_SIZE Specify block size, in audio frames.\n");
+ printf(" -f, --full Full plottable output.\n");
+ printf(" -h, --help Display this help and exit.\n");
+ printf(" -n FRAMES Total number of audio frames to process\n");
+ printf(" --version Display version information and exit\n");
}
static double
bench(const LilvPlugin* p, uint32_t sample_count, uint32_t block_size)
{
- URITable uri_table;
- uri_table_init(&uri_table);
-
- LV2_URID_Map map = { &uri_table, uri_table_map };
- LV2_Feature map_feature = { LV2_URID_MAP_URI, &map };
- LV2_URID_Unmap unmap = { &uri_table, uri_table_unmap };
- LV2_Feature unmap_feature = { LV2_URID_UNMAP_URI, &unmap };
- const LV2_Feature* features[] = { &map_feature, &unmap_feature, NULL };
-
- float* const buf = (float*)calloc(block_size * 2, sizeof(float));
- float* const in = buf;
- float* const out = buf + block_size;
- if (!buf) {
- fprintf(stderr, "Out of memory\n");
- return 0.0;
- }
-
- const size_t atom_capacity = 1024;
-
- LV2_Atom_Sequence seq_in = {
- { sizeof(LV2_Atom_Sequence_Body),
- uri_table_map(&uri_table, LV2_ATOM__Sequence) },
- { 0, 0 } };
-
- LV2_Atom_Sequence* seq_out = (LV2_Atom_Sequence*)malloc(
- sizeof(LV2_Atom_Sequence) + atom_capacity);
-
- const char* uri = lilv_node_as_string(lilv_plugin_get_uri(p));
- LilvNodes* required = lilv_plugin_get_required_features(p);
- LILV_FOREACH(nodes, i, required) {
- const LilvNode* feature = lilv_nodes_get(required, i);
- if (!lilv_node_equals(feature, urid_map)) {
- fprintf(stderr, "<%s> requires feature <%s>, skipping\n",
- uri, lilv_node_as_uri(feature));
- free(seq_out);
- free(buf);
- uri_table_destroy(&uri_table);
- return 0.0;
- }
- }
-
- LilvInstance* instance = lilv_plugin_instantiate(p, 48000.0, features);
- if (!instance) {
- fprintf(stderr, "Failed to instantiate <%s>\n",
- lilv_node_as_uri(lilv_plugin_get_uri(p)));
- free(seq_out);
- free(buf);
- uri_table_destroy(&uri_table);
- return 0.0;
- }
-
- const uint32_t n_ports = lilv_plugin_get_num_ports(p);
- float* const mins = (float*)calloc(n_ports, sizeof(float));
- float* const maxes = (float*)calloc(n_ports, sizeof(float));
- float* const controls = (float*)calloc(n_ports, sizeof(float));
- lilv_plugin_get_port_ranges_float(p, mins, maxes, controls);
-
- for (uint32_t index = 0; index < n_ports; ++index) {
- const LilvPort* port = lilv_plugin_get_port_by_index(p, index);
- if (lilv_port_is_a(p, port, lv2_ControlPort)) {
- if (isnan(controls[index])) {
- if (!isnan(mins[index])) {
- controls[index] = mins[index];
- } else if (!isnan(maxes[index])) {
- controls[index] = maxes[index];
- } else {
- controls[index] = 0.0;
- }
- }
- lilv_instance_connect_port(instance, index, &controls[index]);
- } else if (lilv_port_is_a(p, port, lv2_AudioPort) ||
- lilv_port_is_a(p, port, lv2_CVPort)) {
- if (lilv_port_is_a(p, port, lv2_InputPort)) {
- lilv_instance_connect_port(instance, index, in);
- } else if (lilv_port_is_a(p, port, lv2_OutputPort)) {
- lilv_instance_connect_port(instance, index, out);
- } else {
- fprintf(stderr, "<%s> port %u neither input nor output, skipping\n",
- uri, index);
- lilv_instance_free(instance);
- free(seq_out);
- free(buf);
- free(controls);
- uri_table_destroy(&uri_table);
- return 0.0;
- }
- } else if (lilv_port_is_a(p, port, atom_AtomPort)) {
- if (lilv_port_is_a(p, port, lv2_InputPort)) {
- lilv_instance_connect_port(instance, index, &seq_in);
- } else {
- lilv_instance_connect_port(instance, index, seq_out);
- }
- } else {
- fprintf(stderr, "<%s> port %u has unknown type, skipping\n",
- uri, index);
- lilv_instance_free(instance);
- free(seq_out);
- free(buf);
- free(controls);
- uri_table_destroy(&uri_table);
- return 0.0;
- }
- }
-
- lilv_instance_activate(instance);
-
- struct timespec ts = bench_start();
- for (uint32_t i = 0; i < (sample_count / block_size); ++i) {
- seq_in.atom.size = sizeof(LV2_Atom_Sequence_Body);
- seq_in.atom.type = uri_table_map(&uri_table, LV2_ATOM__Sequence);
- seq_out->atom.size = atom_capacity;
- seq_out->atom.type = uri_table_map(&uri_table, LV2_ATOM__Chunk);
-
- lilv_instance_run(instance, block_size);
- }
- const double elapsed = bench_end(&ts);
-
- lilv_instance_deactivate(instance);
- lilv_instance_free(instance);
- free(controls);
- free(maxes);
- free(mins);
- free(seq_out);
-
- uri_table_destroy(&uri_table);
-
- if (full_output) {
- printf("%u %u ", block_size, sample_count);
- }
- printf("%lf %s\n", elapsed, uri);
-
- free(buf);
- return elapsed;
+ URITable uri_table;
+ uri_table_init(&uri_table);
+
+ LV2_URID_Map map = {&uri_table, uri_table_map};
+ LV2_Feature map_feature = {LV2_URID_MAP_URI, &map};
+ LV2_URID_Unmap unmap = {&uri_table, uri_table_unmap};
+ LV2_Feature unmap_feature = {LV2_URID_UNMAP_URI, &unmap};
+ const LV2_Feature* features[] = {&map_feature, &unmap_feature, NULL};
+
+ float* const buf = (float*)calloc(block_size * 2, sizeof(float));
+ float* const in = buf;
+ float* const out = buf + block_size;
+ if (!buf) {
+ fprintf(stderr, "Out of memory\n");
+ return 0.0;
+ }
+
+ const size_t atom_capacity = 1024;
+
+ LV2_Atom_Sequence seq_in = {{sizeof(LV2_Atom_Sequence_Body),
+ uri_table_map(&uri_table, LV2_ATOM__Sequence)},
+ {0, 0}};
+
+ LV2_Atom_Sequence* seq_out =
+ (LV2_Atom_Sequence*)malloc(sizeof(LV2_Atom_Sequence) + atom_capacity);
+
+ const char* uri = lilv_node_as_string(lilv_plugin_get_uri(p));
+ LilvNodes* required = lilv_plugin_get_required_features(p);
+ LILV_FOREACH (nodes, i, required) {
+ const LilvNode* feature = lilv_nodes_get(required, i);
+ if (!lilv_node_equals(feature, urid_map)) {
+ fprintf(stderr,
+ "<%s> requires feature <%s>, skipping\n",
+ uri,
+ lilv_node_as_uri(feature));
+ free(seq_out);
+ free(buf);
+ uri_table_destroy(&uri_table);
+ return 0.0;
+ }
+ }
+
+ LilvInstance* instance = lilv_plugin_instantiate(p, 48000.0, features);
+ if (!instance) {
+ fprintf(stderr,
+ "Failed to instantiate <%s>\n",
+ lilv_node_as_uri(lilv_plugin_get_uri(p)));
+ free(seq_out);
+ free(buf);
+ uri_table_destroy(&uri_table);
+ return 0.0;
+ }
+
+ const uint32_t n_ports = lilv_plugin_get_num_ports(p);
+ float* const mins = (float*)calloc(n_ports, sizeof(float));
+ float* const maxes = (float*)calloc(n_ports, sizeof(float));
+ float* const controls = (float*)calloc(n_ports, sizeof(float));
+ lilv_plugin_get_port_ranges_float(p, mins, maxes, controls);
+
+ for (uint32_t index = 0; index < n_ports; ++index) {
+ const LilvPort* port = lilv_plugin_get_port_by_index(p, index);
+ if (lilv_port_is_a(p, port, lv2_ControlPort)) {
+ if (isnan(controls[index])) {
+ if (!isnan(mins[index])) {
+ controls[index] = mins[index];
+ } else if (!isnan(maxes[index])) {
+ controls[index] = maxes[index];
+ } else {
+ controls[index] = 0.0;
+ }
+ }
+ lilv_instance_connect_port(instance, index, &controls[index]);
+ } else if (lilv_port_is_a(p, port, lv2_AudioPort) ||
+ lilv_port_is_a(p, port, lv2_CVPort)) {
+ if (lilv_port_is_a(p, port, lv2_InputPort)) {
+ lilv_instance_connect_port(instance, index, in);
+ } else if (lilv_port_is_a(p, port, lv2_OutputPort)) {
+ lilv_instance_connect_port(instance, index, out);
+ } else {
+ fprintf(stderr,
+ "<%s> port %u neither input nor output, skipping\n",
+ uri,
+ index);
+ lilv_instance_free(instance);
+ free(seq_out);
+ free(buf);
+ free(controls);
+ uri_table_destroy(&uri_table);
+ return 0.0;
+ }
+ } else if (lilv_port_is_a(p, port, atom_AtomPort)) {
+ if (lilv_port_is_a(p, port, lv2_InputPort)) {
+ lilv_instance_connect_port(instance, index, &seq_in);
+ } else {
+ lilv_instance_connect_port(instance, index, seq_out);
+ }
+ } else {
+ fprintf(stderr, "<%s> port %u has unknown type, skipping\n", uri, index);
+ lilv_instance_free(instance);
+ free(seq_out);
+ free(buf);
+ free(controls);
+ uri_table_destroy(&uri_table);
+ return 0.0;
+ }
+ }
+
+ lilv_instance_activate(instance);
+
+ struct timespec ts = bench_start();
+ for (uint32_t i = 0; i < (sample_count / block_size); ++i) {
+ seq_in.atom.size = sizeof(LV2_Atom_Sequence_Body);
+ seq_in.atom.type = uri_table_map(&uri_table, LV2_ATOM__Sequence);
+ seq_out->atom.size = atom_capacity;
+ seq_out->atom.type = uri_table_map(&uri_table, LV2_ATOM__Chunk);
+
+ lilv_instance_run(instance, block_size);
+ }
+ const double elapsed = bench_end(&ts);
+
+ lilv_instance_deactivate(instance);
+ lilv_instance_free(instance);
+ free(controls);
+ free(maxes);
+ free(mins);
+ free(seq_out);
+
+ uri_table_destroy(&uri_table);
+
+ if (full_output) {
+ printf("%u %u ", block_size, sample_count);
+ }
+ printf("%lf %s\n", elapsed, uri);
+
+ free(buf);
+ return elapsed;
}
int
main(int argc, char** argv)
{
- uint32_t block_size = 512;
- uint32_t sample_count = (1 << 19);
-
- int a = 1;
- for (; a < argc; ++a) {
- if (!strcmp(argv[a], "--version")) {
- print_version();
- return 0;
- }
-
- if (!strcmp(argv[a], "--help")) {
- print_usage();
- return 0;
- }
-
- if (!strcmp(argv[a], "-f")) {
- full_output = true;
- } else if (!strcmp(argv[a], "-n") && (a + 1 < argc)) {
- sample_count = atoi(argv[++a]);
- } else if (!strcmp(argv[a], "-b") && (a + 1 < argc)) {
- block_size = atoi(argv[++a]);
- } else if (argv[a][0] != '-') {
- break;
- } else {
- print_usage();
- return 1;
- }
- }
-
- const char* const plugin_uri_str = (a < argc ? argv[a++] : NULL);
-
- LilvWorld* world = lilv_world_new();
- lilv_world_load_all(world);
-
- atom_AtomPort = lilv_new_uri(world, LV2_ATOM__AtomPort);
- atom_Sequence = lilv_new_uri(world, LV2_ATOM__Sequence);
- lv2_AudioPort = lilv_new_uri(world, LV2_CORE__AudioPort);
- lv2_CVPort = lilv_new_uri(world, LV2_CORE__CVPort);
- lv2_ControlPort = lilv_new_uri(world, LV2_CORE__ControlPort);
- lv2_InputPort = lilv_new_uri(world, LV2_CORE__InputPort);
- lv2_OutputPort = lilv_new_uri(world, LV2_CORE__OutputPort);
- urid_map = lilv_new_uri(world, LV2_URID__map);
-
- if (full_output) {
- printf("# Block Samples Time Plugin\n");
- }
-
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- if (plugin_uri_str) {
- LilvNode* uri = lilv_new_uri(world, plugin_uri_str);
- bench(lilv_plugins_get_by_uri(plugins, uri), sample_count, block_size);
- lilv_node_free(uri);
- } else {
- LILV_FOREACH(plugins, i, plugins) {
- bench(lilv_plugins_get(plugins, i), sample_count, block_size);
- }
- }
-
- lilv_node_free(urid_map);
- lilv_node_free(lv2_OutputPort);
- lilv_node_free(lv2_InputPort);
- lilv_node_free(lv2_ControlPort);
- lilv_node_free(lv2_CVPort);
- lilv_node_free(lv2_AudioPort);
- lilv_node_free(atom_Sequence);
- lilv_node_free(atom_AtomPort);
-
- lilv_world_free(world);
-
- return 0;
+ uint32_t block_size = 512;
+ uint32_t sample_count = (1 << 19);
+
+ int a = 1;
+ for (; a < argc; ++a) {
+ if (!strcmp(argv[a], "--version")) {
+ print_version();
+ return 0;
+ }
+
+ if (!strcmp(argv[a], "--help")) {
+ print_usage();
+ return 0;
+ }
+
+ if (!strcmp(argv[a], "-f")) {
+ full_output = true;
+ } else if (!strcmp(argv[a], "-n") && (a + 1 < argc)) {
+ sample_count = atoi(argv[++a]);
+ } else if (!strcmp(argv[a], "-b") && (a + 1 < argc)) {
+ block_size = atoi(argv[++a]);
+ } else if (argv[a][0] != '-') {
+ break;
+ } else {
+ print_usage();
+ return 1;
+ }
+ }
+
+ const char* const plugin_uri_str = (a < argc ? argv[a++] : NULL);
+
+ LilvWorld* world = lilv_world_new();
+ lilv_world_load_all(world);
+
+ atom_AtomPort = lilv_new_uri(world, LV2_ATOM__AtomPort);
+ atom_Sequence = lilv_new_uri(world, LV2_ATOM__Sequence);
+ lv2_AudioPort = lilv_new_uri(world, LV2_CORE__AudioPort);
+ lv2_CVPort = lilv_new_uri(world, LV2_CORE__CVPort);
+ lv2_ControlPort = lilv_new_uri(world, LV2_CORE__ControlPort);
+ lv2_InputPort = lilv_new_uri(world, LV2_CORE__InputPort);
+ lv2_OutputPort = lilv_new_uri(world, LV2_CORE__OutputPort);
+ urid_map = lilv_new_uri(world, LV2_URID__map);
+
+ if (full_output) {
+ printf("# Block Samples Time Plugin\n");
+ }
+
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ if (plugin_uri_str) {
+ LilvNode* uri = lilv_new_uri(world, plugin_uri_str);
+ bench(lilv_plugins_get_by_uri(plugins, uri), sample_count, block_size);
+ lilv_node_free(uri);
+ } else {
+ LILV_FOREACH (plugins, i, plugins) {
+ bench(lilv_plugins_get(plugins, i), sample_count, block_size);
+ }
+ }
+
+ lilv_node_free(urid_map);
+ lilv_node_free(lv2_OutputPort);
+ lilv_node_free(lv2_InputPort);
+ lilv_node_free(lv2_ControlPort);
+ lilv_node_free(lv2_CVPort);
+ lilv_node_free(lv2_AudioPort);
+ lilv_node_free(atom_Sequence);
+ lilv_node_free(atom_AtomPort);
+
+ lilv_world_free(world);
+
+ return 0;
}
diff --git a/utils/lv2info.c b/utils/lv2info.c
index f5dd621..0c79268 100644
--- a/utils/lv2info.c
+++ b/utils/lv2info.c
@@ -45,417 +45,412 @@ print_port(const LilvPlugin* p,
float* maxes,
float* defaults)
{
- const LilvPort* port = lilv_plugin_get_port_by_index(p, index);
-
- printf("\n\tPort %u:\n", index);
-
- if (!port) {
- printf("\t\tERROR: Illegal/nonexistent port\n");
- return;
- }
-
- bool first = true;
-
- const LilvNodes* classes = lilv_port_get_classes(p, port);
- printf("\t\tType: ");
- LILV_FOREACH(nodes, i, classes) {
- const LilvNode* value = lilv_nodes_get(classes, i);
- if (!first) {
- printf("\n\t\t ");
- }
- printf("%s", lilv_node_as_uri(value));
- first = false;
- }
-
- if (lilv_port_is_a(p, port, event_class)) {
- LilvNodes* supported = lilv_port_get_value(
- p, port, supports_event_pred);
- if (lilv_nodes_size(supported) > 0) {
- printf("\n\t\tSupported events:\n");
- LILV_FOREACH(nodes, i, supported) {
- const LilvNode* value = lilv_nodes_get(supported, i);
- printf("\t\t\t%s\n", lilv_node_as_uri(value));
- }
- }
- lilv_nodes_free(supported);
- }
-
- LilvScalePoints* points = lilv_port_get_scale_points(p, port);
- if (points) {
- printf("\n\t\tScale Points:\n");
- }
- LILV_FOREACH(scale_points, i, points) {
- const LilvScalePoint* point = lilv_scale_points_get(points, i);
- printf("\t\t\t%s = \"%s\"\n",
- lilv_node_as_string(lilv_scale_point_get_value(point)),
- lilv_node_as_string(lilv_scale_point_get_label(point)));
- }
- lilv_scale_points_free(points);
-
- const LilvNode* sym = lilv_port_get_symbol(p, port);
- printf("\n\t\tSymbol: %s\n", lilv_node_as_string(sym));
-
- LilvNode* name = lilv_port_get_name(p, port);
- printf("\t\tName: %s\n", lilv_node_as_string(name));
- lilv_node_free(name);
-
- LilvNodes* groups = lilv_port_get_value(p, port, group_pred);
- if (lilv_nodes_size(groups) > 0) {
- printf("\t\tGroup: %s\n",
- lilv_node_as_string(lilv_nodes_get_first(groups)));
- }
- lilv_nodes_free(groups);
-
- LilvNodes* designations = lilv_port_get_value(p, port, designation_pred);
- if (lilv_nodes_size(designations) > 0) {
- printf("\t\tDesignation: %s\n",
- lilv_node_as_string(lilv_nodes_get_first(designations)));
- }
- lilv_nodes_free(designations);
-
- if (lilv_port_is_a(p, port, control_class)) {
- if (!isnan(mins[index])) {
- printf("\t\tMinimum: %f\n", mins[index]);
- }
- if (!isnan(maxes[index])) {
- printf("\t\tMaximum: %f\n", maxes[index]);
- }
- if (!isnan(defaults[index])) {
- printf("\t\tDefault: %f\n", defaults[index]);
- }
- }
-
- LilvNodes* properties = lilv_port_get_properties(p, port);
- if (lilv_nodes_size(properties) > 0) {
- printf("\t\tProperties: ");
- }
- first = true;
- LILV_FOREACH(nodes, i, properties) {
- if (!first) {
- printf("\t\t ");
- }
- printf("%s\n", lilv_node_as_uri(lilv_nodes_get(properties, i)));
- first = false;
- }
- if (lilv_nodes_size(properties) > 0) {
- printf("\n");
- }
- lilv_nodes_free(properties);
+ const LilvPort* port = lilv_plugin_get_port_by_index(p, index);
+
+ printf("\n\tPort %u:\n", index);
+
+ if (!port) {
+ printf("\t\tERROR: Illegal/nonexistent port\n");
+ return;
+ }
+
+ bool first = true;
+
+ const LilvNodes* classes = lilv_port_get_classes(p, port);
+ printf("\t\tType: ");
+ LILV_FOREACH (nodes, i, classes) {
+ const LilvNode* value = lilv_nodes_get(classes, i);
+ if (!first) {
+ printf("\n\t\t ");
+ }
+ printf("%s", lilv_node_as_uri(value));
+ first = false;
+ }
+
+ if (lilv_port_is_a(p, port, event_class)) {
+ LilvNodes* supported = lilv_port_get_value(p, port, supports_event_pred);
+ if (lilv_nodes_size(supported) > 0) {
+ printf("\n\t\tSupported events:\n");
+ LILV_FOREACH (nodes, i, supported) {
+ const LilvNode* value = lilv_nodes_get(supported, i);
+ printf("\t\t\t%s\n", lilv_node_as_uri(value));
+ }
+ }
+ lilv_nodes_free(supported);
+ }
+
+ LilvScalePoints* points = lilv_port_get_scale_points(p, port);
+ if (points) {
+ printf("\n\t\tScale Points:\n");
+ }
+ LILV_FOREACH (scale_points, i, points) {
+ const LilvScalePoint* point = lilv_scale_points_get(points, i);
+ printf("\t\t\t%s = \"%s\"\n",
+ lilv_node_as_string(lilv_scale_point_get_value(point)),
+ lilv_node_as_string(lilv_scale_point_get_label(point)));
+ }
+ lilv_scale_points_free(points);
+
+ const LilvNode* sym = lilv_port_get_symbol(p, port);
+ printf("\n\t\tSymbol: %s\n", lilv_node_as_string(sym));
+
+ LilvNode* name = lilv_port_get_name(p, port);
+ printf("\t\tName: %s\n", lilv_node_as_string(name));
+ lilv_node_free(name);
+
+ LilvNodes* groups = lilv_port_get_value(p, port, group_pred);
+ if (lilv_nodes_size(groups) > 0) {
+ printf("\t\tGroup: %s\n",
+ lilv_node_as_string(lilv_nodes_get_first(groups)));
+ }
+ lilv_nodes_free(groups);
+
+ LilvNodes* designations = lilv_port_get_value(p, port, designation_pred);
+ if (lilv_nodes_size(designations) > 0) {
+ printf("\t\tDesignation: %s\n",
+ lilv_node_as_string(lilv_nodes_get_first(designations)));
+ }
+ lilv_nodes_free(designations);
+
+ if (lilv_port_is_a(p, port, control_class)) {
+ if (!isnan(mins[index])) {
+ printf("\t\tMinimum: %f\n", mins[index]);
+ }
+ if (!isnan(maxes[index])) {
+ printf("\t\tMaximum: %f\n", maxes[index]);
+ }
+ if (!isnan(defaults[index])) {
+ printf("\t\tDefault: %f\n", defaults[index]);
+ }
+ }
+
+ LilvNodes* properties = lilv_port_get_properties(p, port);
+ if (lilv_nodes_size(properties) > 0) {
+ printf("\t\tProperties: ");
+ }
+ first = true;
+ LILV_FOREACH (nodes, i, properties) {
+ if (!first) {
+ printf("\t\t ");
+ }
+ printf("%s\n", lilv_node_as_uri(lilv_nodes_get(properties, i)));
+ first = false;
+ }
+ if (lilv_nodes_size(properties) > 0) {
+ printf("\n");
+ }
+ lilv_nodes_free(properties);
}
static void
-print_plugin(LilvWorld* world,
- const LilvPlugin* p)
+print_plugin(LilvWorld* world, const LilvPlugin* p)
{
- LilvNode* val = NULL;
-
- printf("%s\n\n", lilv_node_as_uri(lilv_plugin_get_uri(p)));
-
- val = lilv_plugin_get_name(p);
- if (val) {
- printf("\tName: %s\n", lilv_node_as_string(val));
- lilv_node_free(val);
- }
-
- const LilvPluginClass* pclass = lilv_plugin_get_class(p);
- const LilvNode* class_label = lilv_plugin_class_get_label(pclass);
- if (class_label) {
- printf("\tClass: %s\n", lilv_node_as_string(class_label));
- }
-
- val = lilv_plugin_get_author_name(p);
- if (val) {
- printf("\tAuthor: %s\n", lilv_node_as_string(val));
- lilv_node_free(val);
- }
-
- val = lilv_plugin_get_author_email(p);
- if (val) {
- printf("\tAuthor Email: %s\n", lilv_node_as_uri(val));
- lilv_node_free(val);
- }
-
- val = lilv_plugin_get_author_homepage(p);
- if (val) {
- printf("\tAuthor Homepage: %s\n", lilv_node_as_uri(val));
- lilv_node_free(val);
- }
-
- if (lilv_plugin_has_latency(p)) {
- uint32_t latency_port = lilv_plugin_get_latency_port_index(p);
- printf("\tHas latency: yes, reported by port %u\n", latency_port);
- } else {
- printf("\tHas latency: no\n");
- }
-
- printf("\tBundle: %s\n",
- lilv_node_as_uri(lilv_plugin_get_bundle_uri(p)));
-
- const LilvNode* binary_uri = lilv_plugin_get_library_uri(p);
- if (binary_uri) {
- printf("\tBinary: %s\n",
- lilv_node_as_uri(lilv_plugin_get_library_uri(p)));
- }
-
- LilvUIs* uis = lilv_plugin_get_uis(p);
- if (lilv_nodes_size(uis) > 0) {
- printf("\tUIs:\n");
- LILV_FOREACH(uis, i, uis) {
- const LilvUI* ui = lilv_uis_get(uis, i);
- printf("\t\t%s\n", lilv_node_as_uri(lilv_ui_get_uri(ui)));
-
- const char* binary = lilv_node_as_uri(lilv_ui_get_binary_uri(ui));
-
- const LilvNodes* types = lilv_ui_get_classes(ui);
- LILV_FOREACH(nodes, t, types) {
- printf("\t\t\tClass: %s\n",
- lilv_node_as_uri(lilv_nodes_get(types, t)));
- }
-
- if (binary) {
- printf("\t\t\tBinary: %s\n", binary);
- }
-
- printf("\t\t\tBundle: %s\n",
- lilv_node_as_uri(lilv_ui_get_bundle_uri(ui)));
- }
- }
- lilv_uis_free(uis);
-
- printf("\tData URIs: ");
- const LilvNodes* data_uris = lilv_plugin_get_data_uris(p);
- bool first = true;
- LILV_FOREACH(nodes, i, data_uris) {
- if (!first) {
- printf("\n\t ");
- }
- printf("%s", lilv_node_as_uri(lilv_nodes_get(data_uris, i)));
- first = false;
- }
- printf("\n");
-
- /* Required Features */
-
- LilvNodes* features = lilv_plugin_get_required_features(p);
- if (features) {
- printf("\tRequired Features: ");
- }
- first = true;
- LILV_FOREACH(nodes, i, features) {
- if (!first) {
- printf("\n\t ");
- }
- printf("%s", lilv_node_as_uri(lilv_nodes_get(features, i)));
- first = false;
- }
- if (features) {
- printf("\n");
- }
- lilv_nodes_free(features);
-
- /* Optional Features */
-
- features = lilv_plugin_get_optional_features(p);
- if (features) {
- printf("\tOptional Features: ");
- }
- first = true;
- LILV_FOREACH(nodes, i, features) {
- if (!first) {
- printf("\n\t ");
- }
- printf("%s", lilv_node_as_uri(lilv_nodes_get(features, i)));
- first = false;
- }
- if (features) {
- printf("\n");
- }
- lilv_nodes_free(features);
-
- /* Extension Data */
-
- LilvNodes* data = lilv_plugin_get_extension_data(p);
- if (data) {
- printf("\tExtension Data: ");
- }
- first = true;
- LILV_FOREACH(nodes, i, data) {
- if (!first) {
- printf("\n\t ");
- }
- printf("%s", lilv_node_as_uri(lilv_nodes_get(data, i)));
- first = false;
- }
- if (data) {
- printf("\n");
- }
- lilv_nodes_free(data);
-
- /* Presets */
-
- LilvNodes* presets = lilv_plugin_get_related(p, preset_class);
- if (presets) {
- printf("\tPresets: \n");
- }
- LILV_FOREACH(nodes, i, presets) {
- const LilvNode* preset = lilv_nodes_get(presets, i);
- lilv_world_load_resource(world, preset);
- LilvNodes* titles = lilv_world_find_nodes(
- world, preset, label_pred, NULL);
- if (titles) {
- const LilvNode* title = lilv_nodes_get_first(titles);
- printf("\t %s\n", lilv_node_as_string(title));
- lilv_nodes_free(titles);
- } else {
- fprintf(stderr, "Preset <%s> has no rdfs:label\n",
- lilv_node_as_string(lilv_nodes_get(presets, i)));
- }
- }
- lilv_nodes_free(presets);
-
- /* Ports */
-
- const uint32_t num_ports = lilv_plugin_get_num_ports(p);
- float* mins = (float*)calloc(num_ports, sizeof(float));
- float* maxes = (float*)calloc(num_ports, sizeof(float));
- float* defaults = (float*)calloc(num_ports, sizeof(float));
- lilv_plugin_get_port_ranges_float(p, mins, maxes, defaults);
-
- for (uint32_t i = 0; i < num_ports; ++i) {
- print_port(p, i, mins, maxes, defaults);
- }
-
- free(mins);
- free(maxes);
- free(defaults);
+ LilvNode* val = NULL;
+
+ printf("%s\n\n", lilv_node_as_uri(lilv_plugin_get_uri(p)));
+
+ val = lilv_plugin_get_name(p);
+ if (val) {
+ printf("\tName: %s\n", lilv_node_as_string(val));
+ lilv_node_free(val);
+ }
+
+ const LilvPluginClass* pclass = lilv_plugin_get_class(p);
+ const LilvNode* class_label = lilv_plugin_class_get_label(pclass);
+ if (class_label) {
+ printf("\tClass: %s\n", lilv_node_as_string(class_label));
+ }
+
+ val = lilv_plugin_get_author_name(p);
+ if (val) {
+ printf("\tAuthor: %s\n", lilv_node_as_string(val));
+ lilv_node_free(val);
+ }
+
+ val = lilv_plugin_get_author_email(p);
+ if (val) {
+ printf("\tAuthor Email: %s\n", lilv_node_as_uri(val));
+ lilv_node_free(val);
+ }
+
+ val = lilv_plugin_get_author_homepage(p);
+ if (val) {
+ printf("\tAuthor Homepage: %s\n", lilv_node_as_uri(val));
+ lilv_node_free(val);
+ }
+
+ if (lilv_plugin_has_latency(p)) {
+ uint32_t latency_port = lilv_plugin_get_latency_port_index(p);
+ printf("\tHas latency: yes, reported by port %u\n", latency_port);
+ } else {
+ printf("\tHas latency: no\n");
+ }
+
+ printf("\tBundle: %s\n",
+ lilv_node_as_uri(lilv_plugin_get_bundle_uri(p)));
+
+ const LilvNode* binary_uri = lilv_plugin_get_library_uri(p);
+ if (binary_uri) {
+ printf("\tBinary: %s\n",
+ lilv_node_as_uri(lilv_plugin_get_library_uri(p)));
+ }
+
+ LilvUIs* uis = lilv_plugin_get_uis(p);
+ if (lilv_nodes_size(uis) > 0) {
+ printf("\tUIs:\n");
+ LILV_FOREACH (uis, i, uis) {
+ const LilvUI* ui = lilv_uis_get(uis, i);
+ printf("\t\t%s\n", lilv_node_as_uri(lilv_ui_get_uri(ui)));
+
+ const char* binary = lilv_node_as_uri(lilv_ui_get_binary_uri(ui));
+
+ const LilvNodes* types = lilv_ui_get_classes(ui);
+ LILV_FOREACH (nodes, t, types) {
+ printf("\t\t\tClass: %s\n",
+ lilv_node_as_uri(lilv_nodes_get(types, t)));
+ }
+
+ if (binary) {
+ printf("\t\t\tBinary: %s\n", binary);
+ }
+
+ printf("\t\t\tBundle: %s\n",
+ lilv_node_as_uri(lilv_ui_get_bundle_uri(ui)));
+ }
+ }
+ lilv_uis_free(uis);
+
+ printf("\tData URIs: ");
+ const LilvNodes* data_uris = lilv_plugin_get_data_uris(p);
+ bool first = true;
+ LILV_FOREACH (nodes, i, data_uris) {
+ if (!first) {
+ printf("\n\t ");
+ }
+ printf("%s", lilv_node_as_uri(lilv_nodes_get(data_uris, i)));
+ first = false;
+ }
+ printf("\n");
+
+ /* Required Features */
+
+ LilvNodes* features = lilv_plugin_get_required_features(p);
+ if (features) {
+ printf("\tRequired Features: ");
+ }
+ first = true;
+ LILV_FOREACH (nodes, i, features) {
+ if (!first) {
+ printf("\n\t ");
+ }
+ printf("%s", lilv_node_as_uri(lilv_nodes_get(features, i)));
+ first = false;
+ }
+ if (features) {
+ printf("\n");
+ }
+ lilv_nodes_free(features);
+
+ /* Optional Features */
+
+ features = lilv_plugin_get_optional_features(p);
+ if (features) {
+ printf("\tOptional Features: ");
+ }
+ first = true;
+ LILV_FOREACH (nodes, i, features) {
+ if (!first) {
+ printf("\n\t ");
+ }
+ printf("%s", lilv_node_as_uri(lilv_nodes_get(features, i)));
+ first = false;
+ }
+ if (features) {
+ printf("\n");
+ }
+ lilv_nodes_free(features);
+
+ /* Extension Data */
+
+ LilvNodes* data = lilv_plugin_get_extension_data(p);
+ if (data) {
+ printf("\tExtension Data: ");
+ }
+ first = true;
+ LILV_FOREACH (nodes, i, data) {
+ if (!first) {
+ printf("\n\t ");
+ }
+ printf("%s", lilv_node_as_uri(lilv_nodes_get(data, i)));
+ first = false;
+ }
+ if (data) {
+ printf("\n");
+ }
+ lilv_nodes_free(data);
+
+ /* Presets */
+
+ LilvNodes* presets = lilv_plugin_get_related(p, preset_class);
+ if (presets) {
+ printf("\tPresets: \n");
+ }
+ LILV_FOREACH (nodes, i, presets) {
+ const LilvNode* preset = lilv_nodes_get(presets, i);
+ lilv_world_load_resource(world, preset);
+ LilvNodes* titles = lilv_world_find_nodes(world, preset, label_pred, NULL);
+ if (titles) {
+ const LilvNode* title = lilv_nodes_get_first(titles);
+ printf("\t %s\n", lilv_node_as_string(title));
+ lilv_nodes_free(titles);
+ } else {
+ fprintf(stderr,
+ "Preset <%s> has no rdfs:label\n",
+ lilv_node_as_string(lilv_nodes_get(presets, i)));
+ }
+ }
+ lilv_nodes_free(presets);
+
+ /* Ports */
+
+ const uint32_t num_ports = lilv_plugin_get_num_ports(p);
+ float* mins = (float*)calloc(num_ports, sizeof(float));
+ float* maxes = (float*)calloc(num_ports, sizeof(float));
+ float* defaults = (float*)calloc(num_ports, sizeof(float));
+ lilv_plugin_get_port_ranges_float(p, mins, maxes, defaults);
+
+ for (uint32_t i = 0; i < num_ports; ++i) {
+ print_port(p, i, mins, maxes, defaults);
+ }
+
+ free(mins);
+ free(maxes);
+ free(defaults);
}
static void
print_version(void)
{
- printf(
- "lv2info (lilv) " LILV_VERSION "\n"
- "Copyright 2007-2019 David Robillard <http://drobilla.net>\n"
- "License: <http://www.opensource.org/licenses/isc-license>\n"
- "This is free software: you are free to change and redistribute it.\n"
- "There is NO WARRANTY, to the extent permitted by law.\n");
+ printf("lv2info (lilv) " LILV_VERSION "\n"
+ "Copyright 2007-2019 David Robillard <http://drobilla.net>\n"
+ "License: <http://www.opensource.org/licenses/isc-license>\n"
+ "This is free software: you are free to change and redistribute it.\n"
+ "There is NO WARRANTY, to the extent permitted by law.\n");
}
static void
print_usage(void)
{
- printf(
- "Usage: lv2info [OPTION]... PLUGIN_URI\n"
- "Print information about an installed LV2 plugin.\n\n"
- " -p FILE Write Turtle description of plugin to FILE\n"
- " -m FILE Add record of plugin to manifest FILE\n"
- " --help Display this help and exit\n"
- " --version Display version information and exit\n\n"
- "For -p and -m, Turtle files are appended to (not overwritten),\n"
- "and @prefix directives are only written if the file was empty.\n"
- "This allows several plugins to be added to a single file.\n");
+ printf("Usage: lv2info [OPTION]... PLUGIN_URI\n"
+ "Print information about an installed LV2 plugin.\n\n"
+ " -p FILE Write Turtle description of plugin to FILE\n"
+ " -m FILE Add record of plugin to manifest FILE\n"
+ " --help Display this help and exit\n"
+ " --version Display version information and exit\n\n"
+ "For -p and -m, Turtle files are appended to (not overwritten),\n"
+ "and @prefix directives are only written if the file was empty.\n"
+ "This allows several plugins to be added to a single file.\n");
}
int
main(int argc, char** argv)
{
- if (argc == 1) {
- print_usage();
- return 1;
- }
-
- const char* plugin_file = NULL;
- const char* manifest_file = NULL;
- const char* plugin_uri = NULL;
- for (int i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "--version")) {
- print_version();
- return 0;
- }
-
- if (!strcmp(argv[i], "--help")) {
- print_usage();
- return 0;
- }
-
- if (!strcmp(argv[i], "-p")) {
- plugin_file = argv[++i];
- } else if (!strcmp(argv[i], "-m")) {
- manifest_file = argv[++i];
- } else if (argv[i][0] == '-') {
- print_usage();
- return 1;
- } else if (i == argc - 1) {
- plugin_uri = argv[i];
- }
- }
-
- int ret = 0;
-
- LilvWorld* world = lilv_world_new();
- lilv_world_load_all(world);
-
- LilvNode* uri = lilv_new_uri(world, plugin_uri);
- if (!uri) {
- fprintf(stderr, "Invalid plugin URI\n");
- lilv_world_free(world);
- return 1;
- }
-
- applies_to_pred = lilv_new_uri(world, LV2_CORE__appliesTo);
- control_class = lilv_new_uri(world, LILV_URI_CONTROL_PORT);
- event_class = lilv_new_uri(world, LILV_URI_EVENT_PORT);
- group_pred = lilv_new_uri(world, LV2_PORT_GROUPS__group);
- label_pred = lilv_new_uri(world, LILV_NS_RDFS "label");
- preset_class = lilv_new_uri(world, LV2_PRESETS__Preset);
- designation_pred = lilv_new_uri(world, LV2_CORE__designation);
- supports_event_pred = lilv_new_uri(world, LV2_EVENT__supportsEvent);
-
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* p = lilv_plugins_get_by_uri(plugins, uri);
-
- if (p && plugin_file) {
- LilvNode* base = lilv_new_file_uri(world, NULL, plugin_file);
-
- FILE* plugin_fd = fopen(plugin_file, "a");
- if (plugin_fd) {
- lilv_plugin_write_description(world, p, base, plugin_fd);
- fclose(plugin_fd);
- } else {
- fprintf(stderr, "error: Failed to open %s\n", plugin_file);
- }
-
- if (manifest_file) {
- FILE* manifest_fd = fopen(manifest_file, "a");
- if (manifest_fd) {
- lilv_plugin_write_manifest_entry(
- world, p, base, manifest_fd, plugin_file);
- fclose(manifest_fd);
- } else {
- fprintf(stderr, "error: Failed to open %s\n", manifest_file);
- }
- }
- lilv_node_free(base);
- } else if (p) {
- print_plugin(world, p);
- } else {
- fprintf(stderr, "Plugin not found.\n");
- }
-
- ret = (p != NULL ? 0 : -1);
-
- lilv_node_free(uri);
-
- lilv_node_free(supports_event_pred);
- lilv_node_free(designation_pred);
- lilv_node_free(preset_class);
- lilv_node_free(label_pred);
- lilv_node_free(group_pred);
- lilv_node_free(event_class);
- lilv_node_free(control_class);
- lilv_node_free(applies_to_pred);
-
- lilv_world_free(world);
- return ret;
+ if (argc == 1) {
+ print_usage();
+ return 1;
+ }
+
+ const char* plugin_file = NULL;
+ const char* manifest_file = NULL;
+ const char* plugin_uri = NULL;
+ for (int i = 1; i < argc; ++i) {
+ if (!strcmp(argv[i], "--version")) {
+ print_version();
+ return 0;
+ }
+
+ if (!strcmp(argv[i], "--help")) {
+ print_usage();
+ return 0;
+ }
+
+ if (!strcmp(argv[i], "-p")) {
+ plugin_file = argv[++i];
+ } else if (!strcmp(argv[i], "-m")) {
+ manifest_file = argv[++i];
+ } else if (argv[i][0] == '-') {
+ print_usage();
+ return 1;
+ } else if (i == argc - 1) {
+ plugin_uri = argv[i];
+ }
+ }
+
+ int ret = 0;
+
+ LilvWorld* world = lilv_world_new();
+ lilv_world_load_all(world);
+
+ LilvNode* uri = lilv_new_uri(world, plugin_uri);
+ if (!uri) {
+ fprintf(stderr, "Invalid plugin URI\n");
+ lilv_world_free(world);
+ return 1;
+ }
+
+ applies_to_pred = lilv_new_uri(world, LV2_CORE__appliesTo);
+ control_class = lilv_new_uri(world, LILV_URI_CONTROL_PORT);
+ event_class = lilv_new_uri(world, LILV_URI_EVENT_PORT);
+ group_pred = lilv_new_uri(world, LV2_PORT_GROUPS__group);
+ label_pred = lilv_new_uri(world, LILV_NS_RDFS "label");
+ preset_class = lilv_new_uri(world, LV2_PRESETS__Preset);
+ designation_pred = lilv_new_uri(world, LV2_CORE__designation);
+ supports_event_pred = lilv_new_uri(world, LV2_EVENT__supportsEvent);
+
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* p = lilv_plugins_get_by_uri(plugins, uri);
+
+ if (p && plugin_file) {
+ LilvNode* base = lilv_new_file_uri(world, NULL, plugin_file);
+
+ FILE* plugin_fd = fopen(plugin_file, "a");
+ if (plugin_fd) {
+ lilv_plugin_write_description(world, p, base, plugin_fd);
+ fclose(plugin_fd);
+ } else {
+ fprintf(stderr, "error: Failed to open %s\n", plugin_file);
+ }
+
+ if (manifest_file) {
+ FILE* manifest_fd = fopen(manifest_file, "a");
+ if (manifest_fd) {
+ lilv_plugin_write_manifest_entry(
+ world, p, base, manifest_fd, plugin_file);
+ fclose(manifest_fd);
+ } else {
+ fprintf(stderr, "error: Failed to open %s\n", manifest_file);
+ }
+ }
+ lilv_node_free(base);
+ } else if (p) {
+ print_plugin(world, p);
+ } else {
+ fprintf(stderr, "Plugin not found.\n");
+ }
+
+ ret = (p != NULL ? 0 : -1);
+
+ lilv_node_free(uri);
+
+ lilv_node_free(supports_event_pred);
+ lilv_node_free(designation_pred);
+ lilv_node_free(preset_class);
+ lilv_node_free(label_pred);
+ lilv_node_free(group_pred);
+ lilv_node_free(event_class);
+ lilv_node_free(control_class);
+ lilv_node_free(applies_to_pred);
+
+ lilv_world_free(world);
+ return ret;
}
-
diff --git a/utils/lv2ls.c b/utils/lv2ls.c
index 90ae1eb..e5df2b3 100644
--- a/utils/lv2ls.c
+++ b/utils/lv2ls.c
@@ -25,70 +25,70 @@
static void
list_plugins(const LilvPlugins* list, bool show_names)
{
- LILV_FOREACH(plugins, i, list) {
- const LilvPlugin* p = lilv_plugins_get(list, i);
- if (show_names) {
- LilvNode* n = lilv_plugin_get_name(p);
- printf("%s\n", lilv_node_as_string(n));
- lilv_node_free(n);
- } else {
- printf("%s\n", lilv_node_as_uri(lilv_plugin_get_uri(p)));
- }
- }
+ LILV_FOREACH (plugins, i, list) {
+ const LilvPlugin* p = lilv_plugins_get(list, i);
+ if (show_names) {
+ LilvNode* n = lilv_plugin_get_name(p);
+ printf("%s\n", lilv_node_as_string(n));
+ lilv_node_free(n);
+ } else {
+ printf("%s\n", lilv_node_as_uri(lilv_plugin_get_uri(p)));
+ }
+ }
}
static void
print_version(void)
{
- printf(
- "lv2ls (lilv) " LILV_VERSION "\n"
- "Copyright 2007-2019 David Robillard <http://drobilla.net>\n"
- "License: <http://www.opensource.org/licenses/isc-license>\n"
- "This is free software: you are free to change and redistribute it.\n"
- "There is NO WARRANTY, to the extent permitted by law.\n");
+ printf("lv2ls (lilv) " LILV_VERSION "\n"
+ "Copyright 2007-2019 David Robillard <http://drobilla.net>\n"
+ "License: <http://www.opensource.org/licenses/isc-license>\n"
+ "This is free software: you are free to change and redistribute it.\n"
+ "There is NO WARRANTY, to the extent permitted by law.\n");
}
static void
print_usage(void)
{
- printf("Usage: lv2ls [OPTION]...\n");
- printf("List all installed LV2 plugins.\n");
- printf("\n");
- printf(" -n, --names Show names instead of URIs\n");
- printf(" --help Display this help and exit\n");
- printf(" --version Display version information and exit\n");
- printf("\n");
- printf("The environment variable LV2_PATH can be used to control where\n");
- printf("this (and all other lilv based LV2 hosts) will search for plugins.\n");
+ printf("Usage: lv2ls [OPTION]...\n");
+ printf("List all installed LV2 plugins.\n");
+ printf("\n");
+ printf(" -n, --names Show names instead of URIs\n");
+ printf(" --help Display this help and exit\n");
+ printf(" --version Display version information and exit\n");
+ printf("\n");
+ printf("The environment variable LV2_PATH can be used to control where\n");
+ printf(
+ "this (and all other lilv based LV2 hosts) will search for plugins.\n");
}
int
main(int argc, char** argv)
{
- bool show_names = false;
- for (int i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "--names") || !strcmp(argv[i], "-n")) {
- show_names = true;
- } else if (!strcmp(argv[i], "--version")) {
- print_version();
- return 0;
- } else if (!strcmp(argv[i], "--help")) {
- print_usage();
- return 0;
- } else {
- print_usage();
- return 1;
- }
- }
+ bool show_names = false;
+ for (int i = 1; i < argc; ++i) {
+ if (!strcmp(argv[i], "--names") || !strcmp(argv[i], "-n")) {
+ show_names = true;
+ } else if (!strcmp(argv[i], "--version")) {
+ print_version();
+ return 0;
+ } else if (!strcmp(argv[i], "--help")) {
+ print_usage();
+ return 0;
+ } else {
+ print_usage();
+ return 1;
+ }
+ }
- LilvWorld* world = lilv_world_new();
- lilv_world_load_all(world);
+ LilvWorld* world = lilv_world_new();
+ lilv_world_load_all(world);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- list_plugins(plugins, show_names);
+ list_plugins(plugins, show_names);
- lilv_world_free(world);
+ lilv_world_free(world);
- return 0;
+ return 0;
}
diff --git a/utils/uri_table.h b/utils/uri_table.h
index 70635a3..78d3916 100644
--- a/utils/uri_table.h
+++ b/utils/uri_table.h
@@ -29,54 +29,52 @@
#include <string.h>
typedef struct {
- char** uris;
- size_t n_uris;
+ char** uris;
+ size_t n_uris;
} URITable;
static void
uri_table_init(URITable* table)
{
- table->uris = NULL;
- table->n_uris = 0;
+ table->uris = NULL;
+ table->n_uris = 0;
}
static void
uri_table_destroy(URITable* table)
{
- for (size_t i = 0; i < table->n_uris; ++i) {
- free(table->uris[i]);
- }
+ for (size_t i = 0; i < table->n_uris; ++i) {
+ free(table->uris[i]);
+ }
- free(table->uris);
+ free(table->uris);
}
static LV2_URID
-uri_table_map(LV2_URID_Map_Handle handle,
- const char* uri)
+uri_table_map(LV2_URID_Map_Handle handle, const char* uri)
{
- URITable* table = (URITable*)handle;
- for (size_t i = 0; i < table->n_uris; ++i) {
- if (!strcmp(table->uris[i], uri)) {
- return i + 1;
- }
- }
+ URITable* table = (URITable*)handle;
+ for (size_t i = 0; i < table->n_uris; ++i) {
+ if (!strcmp(table->uris[i], uri)) {
+ return i + 1;
+ }
+ }
- const size_t len = strlen(uri);
- table->uris = (char**)realloc(table->uris, ++table->n_uris * sizeof(char*));
- table->uris[table->n_uris - 1] = (char*)malloc(len + 1);
- memcpy(table->uris[table->n_uris - 1], uri, len + 1);
- return table->n_uris;
+ const size_t len = strlen(uri);
+ table->uris = (char**)realloc(table->uris, ++table->n_uris * sizeof(char*));
+ table->uris[table->n_uris - 1] = (char*)malloc(len + 1);
+ memcpy(table->uris[table->n_uris - 1], uri, len + 1);
+ return table->n_uris;
}
static const char*
-uri_table_unmap(LV2_URID_Map_Handle handle,
- LV2_URID urid)
+uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid)
{
- URITable* table = (URITable*)handle;
- if (urid > 0 && urid <= table->n_uris) {
- return table->uris[urid - 1];
- }
- return NULL;
+ URITable* table = (URITable*)handle;
+ if (urid > 0 && urid <= table->n_uris) {
+ return table->uris[urid - 1];
+ }
+ return NULL;
}
-#endif /* URI_TABLE_H */
+#endif /* URI_TABLE_H */