diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/eg-sampler.lv2/sampler.c | 7 | ||||
-rw-r--r-- | plugins/eg-sampler.lv2/sampler_ui.c | 15 | ||||
-rw-r--r-- | plugins/eg-sampler.lv2/uris.h | 4 |
3 files changed, 23 insertions, 3 deletions
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); |