aboutsummaryrefslogtreecommitdiff
path: root/osc.lv2
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2016-05-17 17:27:50 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2016-05-17 17:27:50 +0200
commitb3346080bd2930c4fd583664ddfa9d40f415f4a2 (patch)
treea27083effd63936fa29d40ca332ed72b9fa8e4be /osc.lv2
parent346f8c3407d711c19822f9d3fb2c10e24348df84 (diff)
downloadsherlock.lv2-b3346080bd2930c4fd583664ddfa9d40f415f4a2.tar.xz
implement argument iterator helpers.
Diffstat (limited to 'osc.lv2')
-rw-r--r--osc.lv2/util.h136
-rw-r--r--osc.lv2/writer.h4
2 files changed, 131 insertions, 9 deletions
diff --git a/osc.lv2/util.h b/osc.lv2/util.h
index d1cb762..16c3bf8 100644
--- a/osc.lv2/util.h
+++ b/osc.lv2/util.h
@@ -189,11 +189,64 @@ lv2_osc_argument_type(LV2_OSC_URID *osc_urid, const LV2_Atom *atom)
return '\0';
}
-/**
- TODO
-*/
-static inline void
-lv2_osc_timetag_get(LV2_OSC_URID *osc_urid, const LV2_Atom_Object *obj,
+static inline const LV2_Atom *
+lv2_osc_int32_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, int32_t *i)
+{
+ assert(i);
+ *i = ((const LV2_Atom_Int *)atom)->body;
+
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_float_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, float *f)
+{
+ assert(f);
+ *f = ((const LV2_Atom_Float *)atom)->body;
+
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_string_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, const char **s)
+{
+ assert(s);
+ *s = LV2_ATOM_BODY_CONST(atom);
+
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_blob_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, uint32_t *size,
+ const uint8_t **b)
+{
+ assert(size && b);
+ *size = atom->size;
+ *b = LV2_ATOM_BODY_CONST(atom);
+
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_int64_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, int64_t *h)
+{
+ assert(h);
+ *h = ((const LV2_Atom_Long *)atom)->body;
+
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_double_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, double *d)
+{
+ assert(d);
+ *d = ((const LV2_Atom_Double *)atom)->body;
+
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_timetag_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom,
LV2_OSC_Timetag *timetag)
{
assert(timetag);
@@ -201,7 +254,7 @@ lv2_osc_timetag_get(LV2_OSC_URID *osc_urid, const LV2_Atom_Object *obj,
const LV2_Atom_Long *integral = NULL;
const LV2_Atom_Long *fraction = NULL;
- lv2_atom_object_get(obj,
+ lv2_atom_object_get((const LV2_Atom_Object *)atom,
osc_urid->OSC_timetagIntegral, &integral,
osc_urid->OSC_timetagFraction, &fraction,
0);
@@ -218,6 +271,75 @@ lv2_osc_timetag_get(LV2_OSC_URID *osc_urid, const LV2_Atom_Object *obj,
timetag->integral = 0;
timetag->fraction = 1;
}
+
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_true_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom)
+{
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_false_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom)
+{
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_nil_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom)
+{
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_impulse_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom)
+{
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_symbol_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, const char **s)
+{
+ assert(s);
+ *s = LV2_ATOM_BODY_CONST(atom);
+
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_midi_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, uint32_t *size,
+ const uint8_t **m)
+{
+ assert(size && m);
+ *size = atom->size;
+ *m = LV2_ATOM_BODY_CONST(atom);
+
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_char_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, char *c)
+{
+ assert(c);
+ *c = ((const LV2_Atom_Int *)atom)->body;
+
+ return lv2_atom_tuple_next(atom);
+}
+
+static inline const LV2_Atom *
+lv2_osc_rgba_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom,
+ uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *a)
+{
+ assert(r && g && b && a);
+ const uint8_t *rgba = LV2_ATOM_BODY_CONST(atom);
+ *r = rgba[0];
+ *g = rgba[1];
+ *b = rgba[2];
+ *a = rgba[3];
+
+ return lv2_atom_tuple_next(atom);
}
/**
@@ -306,7 +428,7 @@ lv2_osc_body_unroll(LV2_OSC_URID *osc_urid, uint32_t size, const LV2_Atom_Object
return false;
LV2_OSC_Timetag tt;
- lv2_osc_timetag_get(osc_urid, timetag, &tt);
+ lv2_osc_timetag_get(osc_urid, &timetag->atom, &tt);
LV2_ATOM_TUPLE_FOREACH(items, atom)
{
diff --git a/osc.lv2/writer.h b/osc.lv2/writer.h
index 2cc89bb..4a1f449 100644
--- a/osc.lv2/writer.h
+++ b/osc.lv2/writer.h
@@ -425,7 +425,7 @@ lv2_osc_writer_packet(LV2_OSC_Writer *writer, LV2_OSC_URID *osc_urid,
LV2_OSC_Timetag tt;
LV2_OSC_Writer_Frame bndl;
- lv2_osc_timetag_get(osc_urid, timetag, &tt);
+ lv2_osc_timetag_get(osc_urid, &timetag->atom, &tt);
if(!lv2_osc_writer_push_bundle(writer, &bndl, lv2_osc_timetag_parse(&tt)))
return false;
@@ -502,7 +502,7 @@ lv2_osc_writer_packet(LV2_OSC_Writer *writer, LV2_OSC_URID *osc_urid,
else if( (atom->type == osc_urid->ATOM_Object) && (obj->body.otype == osc_urid->OSC_Timetag) )
{
LV2_OSC_Timetag tt;
- lv2_osc_timetag_get(osc_urid, obj, &tt);
+ lv2_osc_timetag_get(osc_urid, &obj->atom, &tt);
if(!lv2_osc_writer_add_timetag(writer, lv2_osc_timetag_parse(&tt)))
return false;
}