aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-10-31 23:55:55 +0000
committerDavid Robillard <d@drobilla.net>2014-10-31 23:55:55 +0000
commit118ec555a37ff2324dad2ea81b2b6bef3d0d2c20 (patch)
tree30b3a885a974182c79d1a62ccccf1bcb579e34cf
parent6df6f3b58f366e5772bf1950a39696adcac9b9c6 (diff)
downloadlv2-118ec555a37ff2324dad2ea81b2b6bef3d0d2c20.tar.xz
eg-sampler: Support patch:Get, and request initial state from UI.
-rw-r--r--lv2/lv2plug.in/ns/meta/meta.ttl9
-rw-r--r--plugins/eg-sampler.lv2/sampler.c7
-rw-r--r--plugins/eg-sampler.lv2/sampler_ui.c15
-rw-r--r--plugins/eg-sampler.lv2/uris.h4
4 files changed, 32 insertions, 3 deletions
diff --git a/lv2/lv2plug.in/ns/meta/meta.ttl b/lv2/lv2plug.in/ns/meta/meta.ttl
index d607765..e79f23d 100644
--- a/lv2/lv2plug.in/ns/meta/meta.ttl
+++ b/lv2/lv2plug.in/ns/meta/meta.ttl
@@ -48,6 +48,15 @@ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH R
meta:kfoltman ,
meta:paniq ;
doap:release [
+ doap:revision "1.11.0" ;
+ doap:created "2014-10-31" ;
+ dcs:blame <http://drobilla.net/drobilla#me> ;
+ dcs:changeset [
+ dcs:item [
+ rdfs:label "eg-sampler: Support patch:Get, and request initial state from UI."
+ ]
+ ]
+ ] , [
doap:revision "1.10.0" ;
doap:created "2014-08-08" ;
doap:file-release <http://lv2plug.in/spec/lv2-1.10.0.tar.bz2> ;
diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c
index 54da799..0471a90 100644
--- a/plugins/eg-sampler.lv2/sampler.c
+++ b/plugins/eg-sampler.lv2/sampler.c
@@ -350,6 +350,13 @@ run(LV2_Handle instance,
self->schedule->schedule_work(self->schedule->handle,
lv2_atom_total_size(&ev->body),
&ev->body);
+ } else if (obj->body.otype == uris->patch_Get) {
+ // Received a get message, emit our state (probably to UI)
+ lv2_log_trace(&self->logger, "Responding to get request\n");
+ lv2_atom_forge_frame_time(&self->forge, self->frame_offset);
+ write_set_file(&self->forge, &self->uris,
+ self->sample->path,
+ self->sample->path_len);
} else {
lv2_log_trace(&self->logger,
"Unknown object type %d\n", obj->body.otype);
diff --git a/plugins/eg-sampler.lv2/sampler_ui.c b/plugins/eg-sampler.lv2/sampler_ui.c
index d691c98..643f8c7 100644
--- a/plugins/eg-sampler.lv2/sampler_ui.c
+++ b/plugins/eg-sampler.lv2/sampler_ui.c
@@ -131,6 +131,19 @@ instantiate(const LV2UI_Descriptor* descriptor,
G_CALLBACK(on_load_clicked),
ui);
+ // Request state (filename) from plugin
+ uint8_t get_buf[512];
+ lv2_atom_forge_set_buffer(&ui->forge, get_buf, sizeof(get_buf));
+
+ LV2_Atom_Forge_Frame frame;
+ LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(
+ &ui->forge, &frame, 0, ui->uris.patch_Get);
+ lv2_atom_forge_pop(&ui->forge, &frame);
+
+ ui->write(ui->controller, 0, lv2_atom_total_size(msg),
+ ui->uris.atom_eventTransfer,
+ msg);
+
*widget = ui->box;
return ui;
@@ -154,7 +167,7 @@ port_event(LV2UI_Handle handle,
SamplerUI* ui = (SamplerUI*)handle;
if (format == ui->uris.atom_eventTransfer) {
const LV2_Atom* atom = (const LV2_Atom*)buffer;
- if (atom->type == ui->uris.atom_Blank) {
+ if (lv2_atom_forge_is_object_type(&ui->forge, atom->type)) {
const LV2_Atom_Object* obj = (const LV2_Atom_Object*)atom;
const LV2_Atom* file_uri = read_set_file(&ui->uris, obj);
if (!file_uri) {
diff --git a/plugins/eg-sampler.lv2/uris.h b/plugins/eg-sampler.lv2/uris.h
index 8e9faee..c21c6c8 100644
--- a/plugins/eg-sampler.lv2/uris.h
+++ b/plugins/eg-sampler.lv2/uris.h
@@ -28,7 +28,6 @@
#define EG_SAMPLER__freeSample EG_SAMPLER_URI "#freeSample"
typedef struct {
- LV2_URID atom_Blank;
LV2_URID atom_Path;
LV2_URID atom_Resource;
LV2_URID atom_Sequence;
@@ -38,6 +37,7 @@ typedef struct {
LV2_URID eg_sample;
LV2_URID eg_freeSample;
LV2_URID midi_Event;
+ LV2_URID patch_Get;
LV2_URID patch_Set;
LV2_URID patch_property;
LV2_URID patch_value;
@@ -46,7 +46,6 @@ typedef struct {
static inline void
map_sampler_uris(LV2_URID_Map* map, SamplerURIs* uris)
{
- uris->atom_Blank = map->map(map->handle, LV2_ATOM__Blank);
uris->atom_Path = map->map(map->handle, LV2_ATOM__Path);
uris->atom_Resource = map->map(map->handle, LV2_ATOM__Resource);
uris->atom_Sequence = map->map(map->handle, LV2_ATOM__Sequence);
@@ -56,6 +55,7 @@ map_sampler_uris(LV2_URID_Map* map, SamplerURIs* uris)
uris->eg_freeSample = map->map(map->handle, EG_SAMPLER__freeSample);
uris->eg_sample = map->map(map->handle, EG_SAMPLER__sample);
uris->midi_Event = map->map(map->handle, LV2_MIDI__MidiEvent);
+ uris->patch_Get = map->map(map->handle, LV2_PATCH__Get);
uris->patch_Set = map->map(map->handle, LV2_PATCH__Set);
uris->patch_property = map->map(map->handle, LV2_PATCH__property);
uris->patch_value = map->map(map->handle, LV2_PATCH__value);