diff options
author | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2016-05-24 17:56:14 +0200 |
---|---|---|
committer | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2016-05-24 17:56:14 +0200 |
commit | 649f1ff8684f1915f2ab1c2b0c7d5b6a7cb8c650 (patch) | |
tree | 6f6216e7a5af9a2dea6b7bb9c5f8c13191a123f4 /osc.lv2 | |
parent | b28086186154c0a111d95d782d13f5cade24dc24 (diff) | |
parent | 16035fe14f71638848a9b004cc76f9b8e49be459 (diff) | |
download | moony.lv2-649f1ff8684f1915f2ab1c2b0c7d5b6a7cb8c650.tar.xz |
Merge commit '16035fe14f71638848a9b004cc76f9b8e49be459'
Diffstat (limited to 'osc.lv2')
-rw-r--r-- | osc.lv2/osc.lv2/forge.h | 13 | ||||
-rw-r--r-- | osc.lv2/osc.lv2/osc.h | 11 | ||||
-rw-r--r-- | osc.lv2/osc.lv2/util.h | 31 |
3 files changed, 33 insertions, 22 deletions
diff --git a/osc.lv2/osc.lv2/forge.h b/osc.lv2/osc.lv2/forge.h index d46121f..6dc5fe7 100644 --- a/osc.lv2/osc.lv2/forge.h +++ b/osc.lv2/osc.lv2/forge.h @@ -18,6 +18,8 @@ #ifndef LV2_OSC_FORGE_H #define LV2_OSC_FORGE_H +#include <inttypes.h> + #include <osc.lv2/osc.h> #include <osc.lv2/util.h> #include <osc.lv2/reader.h> @@ -50,10 +52,10 @@ extern "C" { lv2_atom_forge_bool((forge), 0) #define lv2_osc_forge_nil(forge, osc_urid) \ - lv2_atom_forge_atom((forge), 0, 0) + lv2_atom_forge_literal((forge), "", 0, (osc_urid)->OSC_Nil, 0) #define lv2_osc_forge_impulse(forge, osc_urid) \ - lv2_atom_forge_atom((forge), 0, (osc_urid)->OSC_Impulse) + lv2_atom_forge_literal((forge), "", 0, (osc_urid)->OSC_Impulse, 0) #define lv2_osc_forge_symbol(forge, osc_urid, val) \ lv2_atom_forge_urid((forge), (val)) @@ -93,15 +95,16 @@ static inline LV2_Atom_Forge_Ref lv2_osc_forge_char(LV2_Atom_Forge* forge, LV2_OSC_URID *osc_urid, char val) { - return lv2_osc_forge_chunk(forge, osc_urid->OSC_Char, (const uint8_t *)&val, 1); + return lv2_atom_forge_literal(forge, &val, 1, osc_urid->OSC_Char, 0); } static inline LV2_Atom_Forge_Ref lv2_osc_forge_rgba(LV2_Atom_Forge* forge, LV2_OSC_URID *osc_urid, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { - const uint8_t val [4] = {r, g, b, a}; - return lv2_osc_forge_chunk(forge, osc_urid->OSC_RGBA, val, 4); + char val [9]; + sprintf(val, "%02"PRIx8"%02"PRIx8"%02"PRIx8"%02"PRIx8, r, g, b, a); + return lv2_atom_forge_literal(forge, val, 8, osc_urid->OSC_RGBA, 0); } static inline LV2_Atom_Forge_Ref diff --git a/osc.lv2/osc.lv2/osc.h b/osc.lv2/osc.lv2/osc.h index 3b36a19..1ada68c 100644 --- a/osc.lv2/osc.lv2/osc.h +++ b/osc.lv2/osc.lv2/osc.h @@ -44,9 +44,10 @@ #define LV2_OSC__timetagIntegral LV2_OSC_PREFIX "timetagIntegral" // atom object property #define LV2_OSC__timetagFraction LV2_OSC_PREFIX "timetagFraction" // atom object property -#define LV2_OSC__Impulse LV2_OSC_PREFIX "Impulse" // atom type -#define LV2_OSC__Char LV2_OSC_PREFIX "Char" // atom type -#define LV2_OSC__RGBA LV2_OSC_PREFIX "RGBA" // atom type +#define LV2_OSC__Nil LV2_OSC_PREFIX "Nil" // atom literal type +#define LV2_OSC__Impulse LV2_OSC_PREFIX "Impulse" // atom literal type +#define LV2_OSC__Char LV2_OSC_PREFIX "Char" // atom literal type +#define LV2_OSC__RGBA LV2_OSC_PREFIX "RGBA" // atom literal type #define LV2_OSC_PADDED_SIZE(size) ( ( (size_t)(size) + 3 ) & ( ~3 ) ) #define LV2_OSC_IMMEDIATE 1ULL @@ -127,6 +128,7 @@ typedef struct _LV2_OSC_URID { LV2_URID OSC_timetagIntegral; LV2_URID OSC_timetagFraction; + LV2_URID OSC_Nil; LV2_URID OSC_Impulse; LV2_URID OSC_Char; LV2_URID OSC_RGBA; @@ -136,6 +138,7 @@ typedef struct _LV2_OSC_URID { LV2_URID ATOM_Int; LV2_URID ATOM_Long; LV2_URID ATOM_String; + LV2_URID ATOM_Literal; LV2_URID ATOM_Float; LV2_URID ATOM_Double; LV2_URID ATOM_URID; @@ -162,6 +165,7 @@ lv2_osc_urid_init(LV2_OSC_URID *osc_urid, LV2_URID_Map *map) osc_urid->OSC_timetagIntegral = map->map(map->handle, LV2_OSC__timetagIntegral); osc_urid->OSC_timetagFraction = map->map(map->handle, LV2_OSC__timetagFraction); + osc_urid->OSC_Nil = map->map(map->handle, LV2_OSC__Nil); osc_urid->OSC_Impulse = map->map(map->handle, LV2_OSC__Impulse); osc_urid->OSC_Char = map->map(map->handle, LV2_OSC__Char); osc_urid->OSC_RGBA = map->map(map->handle, LV2_OSC__RGBA); @@ -171,6 +175,7 @@ lv2_osc_urid_init(LV2_OSC_URID *osc_urid, LV2_URID_Map *map) osc_urid->ATOM_Int = map->map(map->handle, LV2_ATOM__Int); osc_urid->ATOM_Long = map->map(map->handle, LV2_ATOM__Long); osc_urid->ATOM_String = map->map(map->handle, LV2_ATOM__String); + osc_urid->ATOM_Literal = map->map(map->handle, LV2_ATOM__Literal); osc_urid->ATOM_Float = map->map(map->handle, LV2_ATOM__Float); osc_urid->ATOM_Double = map->map(map->handle, LV2_ATOM__Double); osc_urid->ATOM_URID = map->map(map->handle, LV2_ATOM__URID); diff --git a/osc.lv2/osc.lv2/util.h b/osc.lv2/osc.lv2/util.h index 16c3bf8..c8acc88 100644 --- a/osc.lv2/osc.lv2/util.h +++ b/osc.lv2/osc.lv2/util.h @@ -20,6 +20,7 @@ #include <assert.h> #include <ctype.h> +#include <inttypes.h> #include <osc.lv2/osc.h> @@ -172,19 +173,23 @@ lv2_osc_argument_type(LV2_OSC_URID *osc_urid, const LV2_Atom *atom) else return LV2_OSC_FALSE; } - else if( (atom->type == 0) && (atom->size == 0) ) - return LV2_OSC_NIL; - else if(atom->type == osc_urid->OSC_Impulse) - return LV2_OSC_IMPULSE; + else if(atom->type == osc_urid->ATOM_Literal) + { + const LV2_Atom_Literal *lit = (const LV2_Atom_Literal *)atom; + if(lit->body.datatype == osc_urid->OSC_Nil) + return LV2_OSC_NIL; + else if(lit->body.datatype == osc_urid->OSC_Impulse) + return LV2_OSC_IMPULSE; + else if(lit->body.datatype == osc_urid->OSC_Char) + return LV2_OSC_CHAR; + else if(lit->body.datatype == osc_urid->OSC_RGBA) + return LV2_OSC_RGBA; + } else if(atom->type == osc_urid->ATOM_URID) return LV2_OSC_SYMBOL; else if(atom->type == osc_urid->MIDI_MidiEvent) return LV2_OSC_MIDI; - else if(atom->type == osc_urid->OSC_Char) - return LV2_OSC_CHAR; - else if(atom->type == osc_urid->OSC_RGBA) - return LV2_OSC_RGBA; return '\0'; } @@ -323,7 +328,8 @@ 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; + const char *str = LV2_ATOM_CONTENTS_CONST(LV2_Atom_Literal, atom); + *c = str[0]; return lv2_atom_tuple_next(atom); } @@ -333,11 +339,8 @@ 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]; + const char *str = LV2_ATOM_CONTENTS_CONST(LV2_Atom_Literal, atom); + sscanf(str, "%02"SCNx8"%02"SCNx8"%02"SCNx8"%02"SCNx8, r, g, b, a); return lv2_atom_tuple_next(atom); } |