aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/eg-sampler.lv2/uris.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-02-18 23:12:49 +0000
committerDavid Robillard <d@drobilla.net>2012-02-18 23:12:49 +0000
commit9977d659105937112587e7eb68c59fae7169d945 (patch)
treebb702e76f01b79050a4cbf7cb7b8052e21d84fc6 /plugins/eg-sampler.lv2/uris.h
parent12c86dfba742f1ac3585846f52d5039e9854861c (diff)
downloadlv2-9977d659105937112587e7eb68c59fae7169d945.tar.xz
Remove state:Path and use new atom:Path instead.
Remove suggestion to use file URIs in plugins, which is much too tedious. If plugins use standard atom types, hosts should be able to map paths in any way (which they may need to regardless). Unfortunately it's slightly less pretty in Turtle to have a special path type rather than a (possibly relative) URI. Factor out common write_set_filename_msg in sampler example. Establish common URI define convention LV2_EXTNAME__URILOCALNAME and define all URIs in state, message, and atom.
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 */