summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-03-18 17:04:02 +0100
committerDavid Robillard <d@drobilla.net>2017-03-18 17:04:02 +0100
commit3ee07e807b3e5490fa274241f7f0552ede133f17 (patch)
tree5109d2ddc8c89c6a974e0ed3ed8b71b6baadadac
parent4dcdf46bf1a221ff8d2fa01a95dff43057ee6437 (diff)
downloadlilv-3ee07e807b3e5490fa274241f7f0552ede133f17.tar.gz
lilv-3ee07e807b3e5490fa274241f7f0552ede133f17.tar.bz2
lilv-3ee07e807b3e5490fa274241f7f0552ede133f17.zip
Support running a single plugin in lv2bench
-rw-r--r--NEWS5
-rw-r--r--utils/lv2bench.c55
2 files changed, 41 insertions, 19 deletions
diff --git a/NEWS b/NEWS
index 3d04427..8803e25 100644
--- a/NEWS
+++ b/NEWS
@@ -1,12 +1,13 @@
lilv (0.24.3) unstable;
- * Fix lv2bench for some plugins with sequence ports
+ * lv2bench: Improve support for plugins with sequence ports
+ * lv2bench: Support running a single plugin given on the command line
* Gracefully handle plugins with missing binary URIs
* Remove use of deprecated readdir_r
* Install Python bindings when configured without tests
(thanks Clement Skau)
- -- David Robillard <d@drobilla.net> Mon, 06 Mar 2017 18:58:42 +0100
+ -- David Robillard <d@drobilla.net> Sat, 18 Mar 2017 17:02:35 +0100
lilv (0.24.2) stable;
diff --git a/utils/lv2bench.c b/utils/lv2bench.c
index 5f293b4..3fd97da 100644
--- a/utils/lv2bench.c
+++ b/utils/lv2bench.c
@@ -1,5 +1,5 @@
/*
- Copyright 2012 David Robillard <http://drobilla.net>
+ Copyright 2012-2017 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -16,6 +16,7 @@
#define _POSIX_C_SOURCE 200809L
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -43,7 +44,7 @@ print_version(void)
{
printf(
"lv2bench (lilv) " LILV_VERSION "\n"
- "Copyright 2012 David Robillard <http://drobilla.net>\n"
+ "Copyright 2012-2017 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");
@@ -53,7 +54,7 @@ static void
print_usage(void)
{
printf("lv2bench - Benchmark all installed and supported LV2 plugins.\n");
- printf("Usage: lv2bench [OPTIONS]\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");
@@ -114,14 +115,24 @@ bench(const LilvPlugin* p, uint32_t sample_count, uint32_t block_size)
return 0.0;
}
- float* controls = (float*)calloc(
- lilv_plugin_get_num_ports(p), sizeof(float));
- lilv_plugin_get_port_ranges_float(p, NULL, NULL, controls);
+ 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);
- const uint32_t n_ports = lilv_plugin_get_num_ports(p);
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)) {
@@ -190,25 +201,30 @@ main(int argc, char** argv)
uint32_t block_size = 512;
uint32_t sample_count = (1 << 19);
- for (int i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "--version")) {
+ int a = 1;
+ for (; a < argc; ++a) {
+ if (!strcmp(argv[a], "--version")) {
print_version();
return 0;
- } else if (!strcmp(argv[i], "--help")) {
+ } else if (!strcmp(argv[a], "--help")) {
print_usage();
return 0;
- } else if (!strcmp(argv[i], "-f")) {
+ } else if (!strcmp(argv[a], "-f")) {
full_output = true;
- } else if (!strcmp(argv[i], "-n") && (i + 1 < argc)) {
- sample_count = atoi(argv[++i]);
- } else if (!strcmp(argv[i], "-b") && (i + 1 < argc)) {
- block_size = atoi(argv[++i]);
+ } 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);
@@ -226,8 +242,13 @@ main(int argc, char** argv)
}
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- LILV_FOREACH(plugins, i, plugins) {
- bench(lilv_plugins_get(plugins, i), sample_count, block_size);
+ 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);
+ } else {
+ LILV_FOREACH(plugins, i, plugins) {
+ bench(lilv_plugins_get(plugins, i), sample_count, block_size);
+ }
}
lilv_node_free(urid_map);