aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/eg-sampler.lv2/uris.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/eg-sampler.lv2/uris.h')
-rw-r--r--plugins/eg-sampler.lv2/uris.h62
1 files changed, 46 insertions, 16 deletions
diff --git a/plugins/eg-sampler.lv2/uris.h b/plugins/eg-sampler.lv2/uris.h
index 6584c13..97cefca 100644
--- a/plugins/eg-sampler.lv2/uris.h
+++ b/plugins/eg-sampler.lv2/uris.h
@@ -31,6 +31,7 @@
typedef struct {
LV2_URID atom_Blank;
+ LV2_URID atom_Path;
LV2_URID atom_Resource;
LV2_URID atom_eventTransfer;
LV2_URID eg_applySample;
@@ -39,22 +40,21 @@ typedef struct {
LV2_URID midi_Event;
LV2_URID msg_Set;
LV2_URID msg_body;
- LV2_URID state_Path;
} SamplerURIs;
static inline void
map_sampler_uris(LV2_URID_Map* map, SamplerURIs* uris)
{
- uris->atom_Blank = map->map(map->handle, NS_ATOM "Blank");
- uris->atom_Resource = map->map(map->handle, NS_ATOM "Resource");
- uris->atom_eventTransfer = map->map(map->handle, NS_ATOM "eventTransfer");
+ 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_eventTransfer = map->map(map->handle, LV2_ATOM__eventTransfer);
uris->eg_applySample = map->map(map->handle, APPLY_SAMPLE_URI);
uris->eg_file = map->map(map->handle, FILE_URI);
uris->eg_freeSample = map->map(map->handle, FREE_SAMPLE_URI);
uris->midi_Event = map->map(map->handle, MIDI_EVENT_URI);
- uris->msg_Set = map->map(map->handle, LV2_MESSAGE_Set);
- uris->msg_body = map->map(map->handle, LV2_MESSAGE_body);
- uris->state_Path = map->map(map->handle, LV2_STATE_PATH_URI);
+ uris->msg_Set = map->map(map->handle, LV2_MESSAGE__Set);
+ uris->msg_body = map->map(map->handle, LV2_MESSAGE__body);
}
static inline bool
@@ -64,15 +64,45 @@ is_object_type(const SamplerURIs* uris, LV2_URID type)
|| type == uris->atom_Blank;
}
+static inline LV2_Atom*
+write_set_filename_msg(LV2_Atom_Forge* forge,
+ const SamplerURIs* uris,
+ const char* filename,
+ const size_t filename_len)
+{
+ /* Send [
+ * a msg:Set ;
+ * msg:body [
+ * eg-sampler:filename </home/me/foo.wav> ;
+ * ] ;
+ * ]
+ */
+ LV2_Atom_Forge_Frame set_frame;
+ LV2_Atom* set = (LV2_Atom*)lv2_atom_forge_blank(
+ forge, &set_frame, 1, uris->msg_Set);
+
+ lv2_atom_forge_property_head(forge, uris->msg_body, 0);
+ LV2_Atom_Forge_Frame body_frame;
+ lv2_atom_forge_blank(forge, &body_frame, 2, 0);
+
+ lv2_atom_forge_property_head(forge, uris->eg_file, 0);
+ lv2_atom_forge_path(forge, (const uint8_t*)filename, filename_len);
+
+ lv2_atom_forge_pop(forge, &body_frame);
+ lv2_atom_forge_pop(forge, &set_frame);
+
+ return set;
+}
+
static inline const LV2_Atom*
-get_msg_file_uri(const SamplerURIs* uris,
- const LV2_Atom_Object* obj)
+get_msg_file_path(const SamplerURIs* uris,
+ const LV2_Atom_Object* obj)
{
/* Message should look like this:
* [
* a msg:Set ;
* msg:body [
- * eg-sampler:file <file://hal/home/me/foo.wav> ;
+ * eg-sampler:file </home/me/foo.wav> ;
* ] ;
* ]
*/
@@ -94,15 +124,15 @@ get_msg_file_uri(const SamplerURIs* uris,
return NULL;
}
- /* Get file URI from body. */
- const LV2_Atom* file_uri = NULL;
- lv2_object_getv(body, uris->eg_file, &file_uri, 0);
- if (!file_uri) {
- fprintf(stderr, "Ignored set message with no file URI.\n");
+ /* Get file path from body. */
+ const LV2_Atom* file_path = NULL;
+ lv2_object_getv(body, uris->eg_file, &file_path, 0);
+ if (!file_path) {
+ fprintf(stderr, "Ignored set message with no file PATH.\n");
return NULL;
}
- return file_uri;
+ return file_path;
}
#endif /* SAMPLER_URIS_H */