aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2016-05-01 12:39:04 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2016-05-01 12:39:04 +0200
commitb414874896a4fdeccaee7d24e6f5ab0b3c1eb6c4 (patch)
treecb220d3ff08cf33f6dba32221ac2ad0bb807a14f
parent867553fb978f43024b707f677a66d51d2a1aa68a (diff)
parent926858b6cb0c9bebaa81683aed7e1a59b659db03 (diff)
downloadsherlock.lv2-b414874896a4fdeccaee7d24e6f5ab0b3c1eb6c4.tar.xz
Merge commit '926858b6cb0c9bebaa81683aed7e1a59b659db03'
-rw-r--r--sandbox_ui.lv2/sandbox_io.h3
-rw-r--r--sandbox_ui.lv2/sandbox_slave.c18
-rw-r--r--sandbox_ui.lv2/sandbox_ui.c21
3 files changed, 38 insertions, 4 deletions
diff --git a/sandbox_ui.lv2/sandbox_io.h b/sandbox_ui.lv2/sandbox_io.h
index 1fca98e..aa11427 100644
--- a/sandbox_ui.lv2/sandbox_io.h
+++ b/sandbox_ui.lv2/sandbox_io.h
@@ -26,6 +26,7 @@
#include <lv2/lv2plug.in/ns/lv2core/lv2.h>
#include <lv2/lv2plug.in/ns/ext/urid/urid.h>
#include <lv2/lv2plug.in/ns/ext/atom/atom.h>
+#include <lv2/lv2plug.in/ns/ext/parameters/parameters.h>
#include <lv2/lv2plug.in/ns/extensions/ui/ui.h>
#ifdef __cplusplus
@@ -88,6 +89,7 @@ struct _sandbox_io_t {
LV2_URID ui_peak;
LV2_URID ui_window_title;
LV2_URID ui_port_subscribe;
+ LV2_URID params_sample_rate;
};
static inline LV2_Atom_Forge_Ref
@@ -515,6 +517,7 @@ _sandbox_io_init(sandbox_io_t *io, LV2_URID_Map *map, LV2_URID_Unmap *unmap,
io->ui_peak = map->map(map->handle, LV2_UI_PREFIX"peak");
io->ui_window_title = map->map(map->handle, LV2_UI__windowTitle);
io->ui_port_subscribe = map->map(map->handle, LV2_UI__portSubscribe);
+ io->params_sample_rate = map->map(map->handle, LV2_PARAMETERS__sampleRate);
_sandbox_io_reset(io);
diff --git a/sandbox_ui.lv2/sandbox_slave.c b/sandbox_ui.lv2/sandbox_slave.c
index 0d6fa0c..dd97040 100644
--- a/sandbox_ui.lv2/sandbox_slave.c
+++ b/sandbox_ui.lv2/sandbox_slave.c
@@ -67,6 +67,7 @@ struct _sandbox_slave_t {
const char *ui_uri;
const char *socket_path;
const char *window_title;
+ float sample_rate
};
static inline LV2_URID
@@ -187,8 +188,10 @@ sandbox_slave_new(int argc, char **argv, const sandbox_slave_driver_t *driver, v
goto fail;
}
+ sb->sample_rate = 44100; // fall-back
+
int c;
- while((c = getopt(argc, argv, "p:b:u:s:w:")) != -1)
+ while((c = getopt(argc, argv, "p:b:u:s:w:r:")) != -1)
{
switch(c)
{
@@ -207,8 +210,11 @@ sandbox_slave_new(int argc, char **argv, const sandbox_slave_driver_t *driver, v
case 'w':
sb->window_title = optarg;
break;
+ case 'r':
+ sb->sample_rate = atof(optarg);
+ break;
case '?':
- if( (optopt == 'p') || (optopt == 'b') || (optopt == 'u') || (optopt == 's') || (optopt == 'w') )
+ if( (optopt == 'p') || (optopt == 'b') || (optopt == 'u') || (optopt == 's') || (optopt == 'w') || (optopt == 'r') )
fprintf(stderr, "Option `-%c' requires an argument.\n", optopt);
else if(isprint(optopt))
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
@@ -427,6 +433,14 @@ sandbox_slave_instantiate(sandbox_slave_t *sb, const LV2_Feature *parent_feature
.value = sb->plugin_uri
},
[1] = {
+ .context = LV2_OPTIONS_INSTANCE,
+ .subject = 0,
+ .key = sb->io.params_sample_rate,
+ .size = sizeof(float)
+ .type = sb->io.forge.Float,
+ .value = &sb->sample_rate
+ },
+ [2] = {
.key = 0,
.value = NULL
}
diff --git a/sandbox_ui.lv2/sandbox_ui.c b/sandbox_ui.lv2/sandbox_ui.c
index 482ff41..9acadea 100644
--- a/sandbox_ui.lv2/sandbox_ui.c
+++ b/sandbox_ui.lv2/sandbox_ui.c
@@ -26,6 +26,7 @@
#include <lv2/lv2plug.in/ns/ext/options/options.h>
#include <lv2/lv2plug.in/ns/ext/atom/atom.h>
+#include <lv2/lv2plug.in/ns/ext/parameters/parameters.h>
#include <sandbox_ui.h>
#include <sandbox_master.h>
@@ -50,10 +51,13 @@ struct _plughandle_t {
char *executable;
char *ui_uri;
char *window_title;
+ char *sample_rate;
char socket_path [SOCKET_PATH_LEN];
LV2_URID ui_window_title;
+ LV2_URID params_sample_rate;
LV2_URID atom_string;
+ LV2_URID atom_float;
pid_t pid;
@@ -118,6 +122,7 @@ _show_cb(LV2UI_Handle instance)
"-u", handle->ui_uri,
"-s", handle->socket_path,
"-w", handle->window_title,
+ "-r", handle->sample_rate,
NULL
};
execv(handle->executable, argv); // p = search PATH for executable
@@ -253,6 +258,8 @@ _free_strdups(plughandle_t *handle)
free(handle->ui_uri);
if(handle->window_title)
free(handle->window_title);
+ if(handle->sample_rate)
+ free(handle->sample_rate);
};
LV2UI_Handle
@@ -291,8 +298,12 @@ sandbox_ui_instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_ur
handle->ui_window_title = handle->driver.map->map(handle->driver.map->handle,
LV2_UI__windowTitle);
+ handle->params_sample_rate= handle->driver.map->map(handle->driver.map->handle,
+ LV2_PARAMETERS__sampleRate);
handle->atom_string = handle->driver.map->map(handle->driver.map->handle,
LV2_ATOM__String);
+ handle->atom_float = handle->driver.map->map(handle->driver.map->handle,
+ LV2_ATOM__Float);
handle->plugin_uri = strdup(plugin_uri);
handle->bundle_path = strdup(bundle_path);
@@ -310,7 +321,11 @@ sandbox_ui_instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_ur
if( (opt->key == handle->ui_window_title) && (opt->type == handle->atom_string) )
{
handle->window_title = strdup(opt->value);
- break;
+ }
+ else if( (opt->key == handle->params_sample_rate) && (opt->type == handle->atom_float) )
+ {
+ if(asprintf(&handle->sample_rate, "%f", *(const float *)opt->value) == -1)
+ handle->sample_rate = NULL;
}
}
}
@@ -318,8 +333,10 @@ sandbox_ui_instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_ur
handle->window_title = strdup(handle->kx.host->plugin_human_id);
if(!handle->window_title)
handle->window_title = strdup(descriptor->URI);
+ if(!handle->sample_rate)
+ handle->sample_rate = strdup("44100");
- if(!handle->plugin_uri || !handle->bundle_path || !handle->executable || !handle->ui_uri || !handle->window_title)
+ if(!handle->plugin_uri || !handle->bundle_path || !handle->executable || !handle->ui_uri || !handle->window_title || !handle->sample_rate)
{
_free_strdups(handle);
free(handle);