aboutsummaryrefslogtreecommitdiffstats
path: root/lv2/lv2plug.in/ns/ext/atom/atom.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-02-23 01:53:15 +0000
committerDavid Robillard <d@drobilla.net>2012-02-23 01:53:15 +0000
commitc2cc2607f8d5b9eea933a18abd91b2ce708fc90c (patch)
tree9923ca1257024897eccad5aae61c74cd37ce6609 /lv2/lv2plug.in/ns/ext/atom/atom.h
parentc69ce6e891824fc64022a3615542fc30edc89cd7 (diff)
downloadlv2-c2cc2607f8d5b9eea933a18abd91b2ce708fc90c.tar.xz
Separately define body types for atoms with non-trivial bodies so the type definitions are useful when only the body is available (e.g. state API).
Use a single int64_t stamp for frame times since range is more important now and subframes was never really used anyway. Add atom:frameTime and atom:beatTime for serialising events. Consistently use name "body" for all types of atom bodies. Add lv2_atom_forge_atom() and lv2_atom_forge_raw() for constructing arbitrary atoms. Merge similar string-like forge methods. Update language URI requirements to match current (and hopefully permanent, geeze) http://lexvo.org reality.
Diffstat (limited to 'lv2/lv2plug.in/ns/ext/atom/atom.h')
-rw-r--r--lv2/lv2plug.in/ns/ext/atom/atom.h128
1 files changed, 72 insertions, 56 deletions
diff --git a/lv2/lv2plug.in/ns/ext/atom/atom.h b/lv2/lv2plug.in/ns/ext/atom/atom.h
index 3609cc9..6f104e2 100644
--- a/lv2/lv2plug.in/ns/ext/atom/atom.h
+++ b/lv2/lv2plug.in/ns/ext/atom/atom.h
@@ -28,34 +28,37 @@
#define LV2_ATOM_URI "http://lv2plug.in/ns/ext/atom"
#define LV2_ATOM__Atom LV2_ATOM_URI "#Atom"
-#define LV2_ATOM__Number LV2_ATOM_URI "#Number"
+#define LV2_ATOM__AtomPort LV2_ATOM_URI "#AtomPort"
+#define LV2_ATOM__AudioFrames LV2_ATOM_URI "#AudioFrames"
+#define LV2_ATOM__Beats LV2_ATOM_URI "#Beats"
+#define LV2_ATOM__Blank LV2_ATOM_URI "#Blank"
+#define LV2_ATOM__Bool LV2_ATOM_URI "#Bool"
+#define LV2_ATOM__Double LV2_ATOM_URI "#Double"
+#define LV2_ATOM__Event LV2_ATOM_URI "#Event"
+#define LV2_ATOM__Float LV2_ATOM_URI "#Float"
#define LV2_ATOM__Int32 LV2_ATOM_URI "#Int32"
#define LV2_ATOM__Int64 LV2_ATOM_URI "#Int64"
-#define LV2_ATOM__Float LV2_ATOM_URI "#Float"
-#define LV2_ATOM__Double LV2_ATOM_URI "#Double"
-#define LV2_ATOM__Bool LV2_ATOM_URI "#Bool"
-#define LV2_ATOM__String LV2_ATOM_URI "#String"
#define LV2_ATOM__Literal LV2_ATOM_URI "#Literal"
+#define LV2_ATOM__MessagePort LV2_ATOM_URI "#MessagePort"
+#define LV2_ATOM__Number LV2_ATOM_URI "#Number"
+#define LV2_ATOM__Object LV2_ATOM_URI "#Object"
#define LV2_ATOM__Path LV2_ATOM_URI "#Path"
-#define LV2_ATOM__URI LV2_ATOM_URI "#URI"
-#define LV2_ATOM__URID LV2_ATOM_URI "#URID"
-#define LV2_ATOM__Vector LV2_ATOM_URI "#Vector"
-#define LV2_ATOM__Tuple LV2_ATOM_URI "#Tuple"
#define LV2_ATOM__Property LV2_ATOM_URI "#Property"
-#define LV2_ATOM__Object LV2_ATOM_URI "#Object"
#define LV2_ATOM__Resource LV2_ATOM_URI "#Resource"
-#define LV2_ATOM__Blank LV2_ATOM_URI "#Blank"
-#define LV2_ATOM__TimeUnit LV2_ATOM_URI "#TimeUnit"
-#define LV2_ATOM__AudioFrames LV2_ATOM_URI "#AudioFrames"
-#define LV2_ATOM__Beats LV2_ATOM_URI "#Beats"
-#define LV2_ATOM__Event LV2_ATOM_URI "#Event"
#define LV2_ATOM__Sequence LV2_ATOM_URI "#Sequence"
-#define LV2_ATOM__AtomPort LV2_ATOM_URI "#AtomPort"
+#define LV2_ATOM__String LV2_ATOM_URI "#String"
+#define LV2_ATOM__TimeUnit LV2_ATOM_URI "#TimeUnit"
+#define LV2_ATOM__Tuple LV2_ATOM_URI "#Tuple"
+#define LV2_ATOM__URI LV2_ATOM_URI "#URI"
+#define LV2_ATOM__URID LV2_ATOM_URI "#URID"
#define LV2_ATOM__ValuePort LV2_ATOM_URI "#ValuePort"
-#define LV2_ATOM__MessagePort LV2_ATOM_URI "#MessagePort"
+#define LV2_ATOM__Vector LV2_ATOM_URI "#Vector"
+#define LV2_ATOM__beatTime LV2_ATOM_URI "#beatTime"
#define LV2_ATOM__bufferType LV2_ATOM_URI "#bufferType"
-#define LV2_ATOM__supports LV2_ATOM_URI "#supports"
#define LV2_ATOM__eventTransfer LV2_ATOM_URI "#eventTransfer"
+#define LV2_ATOM__frameTime LV2_ATOM_URI "#frameTime"
+#define LV2_ATOM__supports LV2_ATOM_URI "#supports"
+#define LV2_ATOM__timeUnit LV2_ATOM_URI "#timeUnit"
#define LV2_ATOM_REFERENCE_TYPE 0
@@ -68,14 +71,18 @@ typedef char lv2_atom_assert_double_fits_in_64_bits[
((sizeof(double) <= sizeof(uint64_t)) * 2) - 1];
/**
- Return a pointer to the contents of an Atom.
+ Return a pointer to the contents of an Atom. The "contents" of an atom
+ is the data past the complete type-specific header.
@param type The type of the atom, e.g. LV2_Atom_String.
@param atom A variable-sized atom.
*/
#define LV2_ATOM_CONTENTS(type, atom) \
((void*)((uint8_t*)(atom) + sizeof(type)))
-/** Return a pointer to the body of @p atom (just past the LV2_Atom head). */
+/**
+ Return a pointer to the body of an Atom. The "body" of an atom is the
+ data just past the LV2_Atom head (i.e. the same offset for all types).
+*/
#define LV2_ATOM_BODY(atom) LV2_ATOM_CONTENTS(LV2_Atom, atom)
/** The header of an atom:Atom. */
@@ -86,26 +93,26 @@ typedef struct {
/** An atom:Int32 or atom:Bool. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- int32_t value; /**< Integer value. */
+ LV2_Atom atom; /**< Atom header. */
+ int32_t body; /**< Integer value. */
} LV2_Atom_Int32;
/** An atom:Int64. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- int64_t value; /**< Integer value. */
+ LV2_Atom atom; /**< Atom header. */
+ int64_t body; /**< Integer value. */
} LV2_Atom_Int64;
/** An atom:Float. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- float value; /**< Floating point value. */
+ LV2_Atom atom; /**< Atom header. */
+ float body; /**< Floating point value. */
} LV2_Atom_Float;
/** An atom:Double. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- double value; /**< Floating point value. */
+ LV2_Atom atom; /**< Atom header. */
+ double body; /**< Floating point value. */
} LV2_Atom_Double;
/** An atom:Bool. May be cast to LV2_Atom. */
@@ -114,83 +121,87 @@ typedef LV2_Atom_Int32 LV2_Atom_Bool;
/** An atom:URID. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
- uint32_t id; /**< URID. */
+ uint32_t body; /**< URID. */
} LV2_Atom_URID;
-/** The complete header of an atom:String. */
+/** An atom:String. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
/* Contents (a null-terminated UTF-8 string) follow here. */
} LV2_Atom_String;
-/** The complete header of an atom:Literal. */
+/** The body of an atom:Literal. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
uint32_t datatype; /**< Datatype URID. */
uint32_t lang; /**< Language URID. */
/* Contents (a null-terminated UTF-8 string) follow here. */
+} LV2_Atom_Literal_Body;
+
+/** An atom:Literal. May be cast to LV2_Atom. */
+typedef struct {
+ LV2_Atom atom; /**< Atom header. */
+ LV2_Atom_Literal_Body body; /**< Body. */
} LV2_Atom_Literal;
-/** The complete header of an atom:Tuple. */
+/** An atom:Tuple. May be cast to LV2_Atom. */
typedef struct {
LV2_Atom atom; /**< Atom header. */
/* Contents (a series of complete atoms) follow here. */
} LV2_Atom_Tuple;
-/** The complete header of an atom:Vector. */
+/** The body of an atom:Vector. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
uint32_t elem_count; /**< The number of elements in the vector */
uint32_t elem_type; /**< The type of each element in the vector */
/* Contents (a series of packed atom bodies) follow here. */
+} LV2_Atom_Vector_Body;
+
+/** An atom:Vector. May be cast to LV2_Atom. */
+typedef struct {
+ LV2_Atom atom; /**< Atom header. */
+ LV2_Atom_Vector_Body body; /**< Body. */
} LV2_Atom_Vector;
-/** The header of an atom:Property body (e.g. in an atom:Object). */
+/** The body of an atom:Property (e.g. in an atom:Object). */
typedef struct {
uint32_t key; /**< Key (predicate) (mapped URI). */
uint32_t context; /**< Context URID (may be, and generally is, 0). */
LV2_Atom value; /**< Value atom header. */
+ /* Value atom body follows here. */
} LV2_Atom_Property_Body;
-/** The complete header of an atom:Property. */
+/** An atom:Property. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- uint32_t key; /**< Key (predicate) (mapped URI). */
- uint32_t context; /**< Context URID (may be, and generally is, 0). */
- LV2_Atom value; /**< Value atom header. */
- /* Value atom body follows here. */
+ LV2_Atom atom; /**< Atom header. */
+ LV2_Atom_Property_Body body; /**< Body. */
} LV2_Atom_Property;
-/** The complete header of an atom:Object. */
+/** The body of an atom:Object. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
uint32_t id; /**< URID (atom:Resource) or blank ID (atom:Blank). */
uint32_t otype; /**< Type URID (same as rdf:type, for fast dispatch). */
/* Contents (a series of property bodies) follow here. */
-} LV2_Atom_Object;
+} LV2_Atom_Object_Body;
-/** A time stamp in frames. Note this type is NOT an LV2_Atom. */
+/** An atom:Object. May be cast to LV2_Atom. */
typedef struct {
- uint32_t frames; /**< Time in frames relative to this block. */
- uint32_t subframes; /**< Fractional time in 1/(2^32)ths of a frame. */
-} LV2_Atom_Audio_Time;
+ LV2_Atom atom; /**< Atom header. */
+ LV2_Atom_Object_Body body; /**< Body. */
+} LV2_Atom_Object;
/** The header of an atom:Event. Note this type is NOT an LV2_Atom. */
typedef struct {
/** Time stamp. Which type is valid is determined by context. */
union {
- LV2_Atom_Audio_Time audio; /**< Time in audio frames. */
- double beats; /**< Time in beats. */
+ int64_t frames; /**< Time in audio frames. */
+ double beats; /**< Time in beats. */
} time;
LV2_Atom body; /**< Event body atom header. */
/* Body atom contents follow here. */
} LV2_Atom_Event;
/**
- A sequence of events (time-stamped atoms).
-
- This is used as the contents of an atom:EventPort, but is a generic Atom
- type which can be used anywhere.
+ The body of an atom:Sequence (a sequence of events).
The unit field is either a URID that described an appropriate time stamp
type, or may be 0 where a default stamp type is known. For
@@ -207,10 +218,15 @@ typedef struct {
</pre>
*/
typedef struct {
- LV2_Atom atom; /**< Atom header. */
uint32_t unit; /**< URID of unit of event time stamps. */
uint32_t pad; /**< Currently unused. */
/* Contents (a series of events) follow here. */
+} LV2_Atom_Sequence_Body;
+
+/** An atom:Sequence. */
+typedef struct {
+ LV2_Atom atom; /**< Atom header. */
+ LV2_Atom_Literal_Body body; /**< Body. */
} LV2_Atom_Sequence;
/**