summaryrefslogtreecommitdiffstats
path: root/hosts/lv2_jack_host.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-05-03 17:27:00 +0000
committerDavid Robillard <d@drobilla.net>2008-05-03 17:27:00 +0000
commit9dd89e3a4b9d9f0bfb408c827358f8e97c12373b (patch)
treecd6db99dfac1fac9745f2313920e80f1fdcc6195 /hosts/lv2_jack_host.c
parent572832bfd010ee82717ea0217b125404d11e5a16 (diff)
downloadlilv-9dd89e3a4b9d9f0bfb408c827358f8e97c12373b.tar.gz
lilv-9dd89e3a4b9d9f0bfb408c827358f8e97c12373b.tar.bz2
lilv-9dd89e3a4b9d9f0bfb408c827358f8e97c12373b.zip
Add slv2_plugin_get_port_ranges.
Use slv2_plugin_get_port_ranges in lv2_jack_host and lv2_inspect (significant performance improvement for plugins with lots of ports). git-svn-id: http://svn.drobilla.net/lad/slv2@1193 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'hosts/lv2_jack_host.c')
-rw-r--r--hosts/lv2_jack_host.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/hosts/lv2_jack_host.c b/hosts/lv2_jack_host.c
index 52b6aff..2368352 100644
--- a/hosts/lv2_jack_host.c
+++ b/hosts/lv2_jack_host.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include <slv2/slv2.h>
#include <jack/jack.h>
#include <jack/midiport.h>
@@ -100,7 +101,7 @@ static const LV2_Feature event_ref_feature = { "http://lv2plug.in/ns/ext/event",
const LV2_Feature* features[3] = { &uri_map_feature, &event_ref_feature, NULL };
void die(const char* msg);
-void create_port(struct JackHost* host, uint32_t port_index);
+void create_port(struct JackHost* host, uint32_t port_index, float default_value);
int jack_process_cb(jack_nframes_t nframes, void* data);
void list_plugins(SLV2Plugins list);
@@ -189,9 +190,12 @@ main(int argc, char** argv)
/* Create ports */
host.num_ports = slv2_plugin_get_num_ports(host.plugin);
host.ports = calloc((size_t)host.num_ports, sizeof(struct Port));
-
+ float* default_values = calloc(slv2_plugin_get_num_ports(host.plugin),
+ sizeof(float));
+ slv2_plugin_get_port_ranges(host.plugin, NULL, NULL, default_values);
+
for (uint32_t i=0; i < host.num_ports; ++i)
- create_port(&host, i);
+ create_port(&host, i, default_values[i]);
/* Activate plugin and JACK */
slv2_instance_activate(host.instance);
@@ -254,7 +258,8 @@ die(const char* msg)
*/
void
create_port(struct JackHost* host,
- uint32_t port_index)
+ uint32_t port_index,
+ float default_value)
{
struct Port* const port = &host->ports[port_index];
@@ -285,11 +290,8 @@ create_port(struct JackHost* host,
/* Set control values */
if (slv2_port_is_a(host->plugin, port->slv2_port, host->control_class)) {
port->type = CONTROL;
- SLV2Value def;
- slv2_port_get_range(host->plugin, port->slv2_port, &def, NULL, NULL);
- port->control = def ? slv2_value_as_float(def) : 0.0f;
+ port->control = isnan(default_value) ? 0.0 : default_value;
printf("Set %s to %f\n", symbol_str, host->ports[port_index].control);
- slv2_value_free(def);
} else if (slv2_port_is_a(host->plugin, port->slv2_port, host->audio_class)) {
port->type = AUDIO;
} else if (slv2_port_is_a(host->plugin, port->slv2_port, host->event_class)) {