Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

257 lines
10KB

  1. /*
  2. Copyright 2008-2016 David Robillard <http://drobilla.net>
  3. Permission to use, copy, modify, and/or distribute this software for any
  4. purpose with or without fee is hereby granted, provided that the above
  5. copyright notice and this permission notice appear in all copies.
  6. THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  7. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  8. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  9. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13. */
  14. /**
  15. @defgroup atom Atom
  16. A generic value container and several data types, see
  17. <http://lv2plug.in/ns/ext/atom> for details.
  18. @{
  19. */
  20. #ifndef LV2_ATOM_H
  21. #define LV2_ATOM_H
  22. #include <stdint.h>
  23. #include <stddef.h>
  24. #define LV2_ATOM_URI "http://lv2plug.in/ns/ext/atom" ///< http://lv2plug.in/ns/ext/atom
  25. #define LV2_ATOM_PREFIX LV2_ATOM_URI "#" ///< http://lv2plug.in/ns/ext/atom#
  26. #define LV2_ATOM__Atom LV2_ATOM_PREFIX "Atom" ///< http://lv2plug.in/ns/ext/atom#Atom
  27. #define LV2_ATOM__AtomPort LV2_ATOM_PREFIX "AtomPort" ///< http://lv2plug.in/ns/ext/atom#AtomPort
  28. #define LV2_ATOM__Blank LV2_ATOM_PREFIX "Blank" ///< http://lv2plug.in/ns/ext/atom#Blank
  29. #define LV2_ATOM__Bool LV2_ATOM_PREFIX "Bool" ///< http://lv2plug.in/ns/ext/atom#Bool
  30. #define LV2_ATOM__Chunk LV2_ATOM_PREFIX "Chunk" ///< http://lv2plug.in/ns/ext/atom#Chunk
  31. #define LV2_ATOM__Double LV2_ATOM_PREFIX "Double" ///< http://lv2plug.in/ns/ext/atom#Double
  32. #define LV2_ATOM__Event LV2_ATOM_PREFIX "Event" ///< http://lv2plug.in/ns/ext/atom#Event
  33. #define LV2_ATOM__Float LV2_ATOM_PREFIX "Float" ///< http://lv2plug.in/ns/ext/atom#Float
  34. #define LV2_ATOM__Int LV2_ATOM_PREFIX "Int" ///< http://lv2plug.in/ns/ext/atom#Int
  35. #define LV2_ATOM__Literal LV2_ATOM_PREFIX "Literal" ///< http://lv2plug.in/ns/ext/atom#Literal
  36. #define LV2_ATOM__Long LV2_ATOM_PREFIX "Long" ///< http://lv2plug.in/ns/ext/atom#Long
  37. #define LV2_ATOM__Number LV2_ATOM_PREFIX "Number" ///< http://lv2plug.in/ns/ext/atom#Number
  38. #define LV2_ATOM__Object LV2_ATOM_PREFIX "Object" ///< http://lv2plug.in/ns/ext/atom#Object
  39. #define LV2_ATOM__Path LV2_ATOM_PREFIX "Path" ///< http://lv2plug.in/ns/ext/atom#Path
  40. #define LV2_ATOM__Property LV2_ATOM_PREFIX "Property" ///< http://lv2plug.in/ns/ext/atom#Property
  41. #define LV2_ATOM__Resource LV2_ATOM_PREFIX "Resource" ///< http://lv2plug.in/ns/ext/atom#Resource
  42. #define LV2_ATOM__Sequence LV2_ATOM_PREFIX "Sequence" ///< http://lv2plug.in/ns/ext/atom#Sequence
  43. #define LV2_ATOM__Sound LV2_ATOM_PREFIX "Sound" ///< http://lv2plug.in/ns/ext/atom#Sound
  44. #define LV2_ATOM__String LV2_ATOM_PREFIX "String" ///< http://lv2plug.in/ns/ext/atom#String
  45. #define LV2_ATOM__Tuple LV2_ATOM_PREFIX "Tuple" ///< http://lv2plug.in/ns/ext/atom#Tuple
  46. #define LV2_ATOM__URI LV2_ATOM_PREFIX "URI" ///< http://lv2plug.in/ns/ext/atom#URI
  47. #define LV2_ATOM__URID LV2_ATOM_PREFIX "URID" ///< http://lv2plug.in/ns/ext/atom#URID
  48. #define LV2_ATOM__Vector LV2_ATOM_PREFIX "Vector" ///< http://lv2plug.in/ns/ext/atom#Vector
  49. #define LV2_ATOM__atomTransfer LV2_ATOM_PREFIX "atomTransfer" ///< http://lv2plug.in/ns/ext/atom#atomTransfer
  50. #define LV2_ATOM__beatTime LV2_ATOM_PREFIX "beatTime" ///< http://lv2plug.in/ns/ext/atom#beatTime
  51. #define LV2_ATOM__bufferType LV2_ATOM_PREFIX "bufferType" ///< http://lv2plug.in/ns/ext/atom#bufferType
  52. #define LV2_ATOM__childType LV2_ATOM_PREFIX "childType" ///< http://lv2plug.in/ns/ext/atom#childType
  53. #define LV2_ATOM__eventTransfer LV2_ATOM_PREFIX "eventTransfer" ///< http://lv2plug.in/ns/ext/atom#eventTransfer
  54. #define LV2_ATOM__frameTime LV2_ATOM_PREFIX "frameTime" ///< http://lv2plug.in/ns/ext/atom#frameTime
  55. #define LV2_ATOM__supports LV2_ATOM_PREFIX "supports" ///< http://lv2plug.in/ns/ext/atom#supports
  56. #define LV2_ATOM__timeUnit LV2_ATOM_PREFIX "timeUnit" ///< http://lv2plug.in/ns/ext/atom#timeUnit
  57. #define LV2_ATOM_REFERENCE_TYPE 0 ///< The special type for a reference atom
  58. #ifdef __cplusplus
  59. extern "C" {
  60. #endif
  61. /** @cond */
  62. /** This expression will fail to compile if double does not fit in 64 bits. */
  63. typedef char lv2_atom_assert_double_fits_in_64_bits[
  64. ((sizeof(double) <= sizeof(uint64_t)) * 2) - 1];
  65. /** @endcond */
  66. /**
  67. Return a pointer to the contents of an Atom. The "contents" of an atom
  68. is the data past the complete type-specific header.
  69. @param type The type of the atom, e.g. LV2_Atom_String.
  70. @param atom A variable-sized atom.
  71. */
  72. #define LV2_ATOM_CONTENTS(type, atom) \
  73. ((uint8_t*)(atom) + sizeof(type))
  74. /**
  75. Const version of LV2_ATOM_CONTENTS.
  76. */
  77. #define LV2_ATOM_CONTENTS_CONST(type, atom) \
  78. ((const uint8_t*)(atom) + sizeof(type))
  79. /**
  80. Return a pointer to the body of an Atom. The "body" of an atom is the
  81. data just past the LV2_Atom head (i.e. the same offset for all types).
  82. */
  83. #define LV2_ATOM_BODY(atom) LV2_ATOM_CONTENTS(LV2_Atom, atom)
  84. /**
  85. Const version of LV2_ATOM_BODY.
  86. */
  87. #define LV2_ATOM_BODY_CONST(atom) LV2_ATOM_CONTENTS_CONST(LV2_Atom, atom)
  88. /** The header of an atom:Atom. */
  89. typedef struct {
  90. uint32_t size; /**< Size in bytes, not including type and size. */
  91. uint32_t type; /**< Type of this atom (mapped URI). */
  92. } LV2_Atom;
  93. /** An atom:Int or atom:Bool. May be cast to LV2_Atom. */
  94. typedef struct {
  95. LV2_Atom atom; /**< Atom header. */
  96. int32_t body; /**< Integer value. */
  97. } LV2_Atom_Int;
  98. /** An atom:Long. May be cast to LV2_Atom. */
  99. typedef struct {
  100. LV2_Atom atom; /**< Atom header. */
  101. int64_t body; /**< Integer value. */
  102. } LV2_Atom_Long;
  103. /** An atom:Float. May be cast to LV2_Atom. */
  104. typedef struct {
  105. LV2_Atom atom; /**< Atom header. */
  106. float body; /**< Floating point value. */
  107. } LV2_Atom_Float;
  108. /** An atom:Double. May be cast to LV2_Atom. */
  109. typedef struct {
  110. LV2_Atom atom; /**< Atom header. */
  111. double body; /**< Floating point value. */
  112. } LV2_Atom_Double;
  113. /** An atom:Bool. May be cast to LV2_Atom. */
  114. typedef LV2_Atom_Int LV2_Atom_Bool;
  115. /** An atom:URID. May be cast to LV2_Atom. */
  116. typedef struct {
  117. LV2_Atom atom; /**< Atom header. */
  118. uint32_t body; /**< URID. */
  119. } LV2_Atom_URID;
  120. /** An atom:String. May be cast to LV2_Atom. */
  121. typedef struct {
  122. LV2_Atom atom; /**< Atom header. */
  123. /* Contents (a null-terminated UTF-8 string) follow here. */
  124. } LV2_Atom_String;
  125. /** The body of an atom:Literal. */
  126. typedef struct {
  127. uint32_t datatype; /**< Datatype URID. */
  128. uint32_t lang; /**< Language URID. */
  129. /* Contents (a null-terminated UTF-8 string) follow here. */
  130. } LV2_Atom_Literal_Body;
  131. /** An atom:Literal. May be cast to LV2_Atom. */
  132. typedef struct {
  133. LV2_Atom atom; /**< Atom header. */
  134. LV2_Atom_Literal_Body body; /**< Body. */
  135. } LV2_Atom_Literal;
  136. /** An atom:Tuple. May be cast to LV2_Atom. */
  137. typedef struct {
  138. LV2_Atom atom; /**< Atom header. */
  139. /* Contents (a series of complete atoms) follow here. */
  140. } LV2_Atom_Tuple;
  141. /** The body of an atom:Vector. */
  142. typedef struct {
  143. uint32_t child_size; /**< The size of each element in the vector. */
  144. uint32_t child_type; /**< The type of each element in the vector. */
  145. /* Contents (a series of packed atom bodies) follow here. */
  146. } LV2_Atom_Vector_Body;
  147. /** An atom:Vector. May be cast to LV2_Atom. */
  148. typedef struct {
  149. LV2_Atom atom; /**< Atom header. */
  150. LV2_Atom_Vector_Body body; /**< Body. */
  151. } LV2_Atom_Vector;
  152. /** The body of an atom:Property (e.g. in an atom:Object). */
  153. typedef struct {
  154. uint32_t key; /**< Key (predicate) (mapped URI). */
  155. uint32_t context; /**< Context URID (may be, and generally is, 0). */
  156. LV2_Atom value; /**< Value atom header. */
  157. /* Value atom body follows here. */
  158. } LV2_Atom_Property_Body;
  159. /** An atom:Property. May be cast to LV2_Atom. */
  160. typedef struct {
  161. LV2_Atom atom; /**< Atom header. */
  162. LV2_Atom_Property_Body body; /**< Body. */
  163. } LV2_Atom_Property;
  164. /** The body of an atom:Object. May be cast to LV2_Atom. */
  165. typedef struct {
  166. uint32_t id; /**< URID, or 0 for blank. */
  167. uint32_t otype; /**< Type URID (same as rdf:type, for fast dispatch). */
  168. /* Contents (a series of property bodies) follow here. */
  169. } LV2_Atom_Object_Body;
  170. /** An atom:Object. May be cast to LV2_Atom. */
  171. typedef struct {
  172. LV2_Atom atom; /**< Atom header. */
  173. LV2_Atom_Object_Body body; /**< Body. */
  174. } LV2_Atom_Object;
  175. /** The header of an atom:Event. Note this type is NOT an LV2_Atom. */
  176. typedef struct {
  177. /** Time stamp. Which type is valid is determined by context. */
  178. union {
  179. int64_t frames; /**< Time in audio frames. */
  180. double beats; /**< Time in beats. */
  181. } time;
  182. LV2_Atom body; /**< Event body atom header. */
  183. /* Body atom contents follow here. */
  184. } LV2_Atom_Event;
  185. /**
  186. The body of an atom:Sequence (a sequence of events).
  187. The unit field is either a URID that described an appropriate time stamp
  188. type, or may be 0 where a default stamp type is known. For
  189. LV2_Descriptor::run(), the default stamp type is audio frames.
  190. The contents of a sequence is a series of LV2_Atom_Event, each aligned
  191. to 64-bits, e.g.:
  192. <pre>
  193. | Event 1 (size 6) | Event 2
  194. | | | | | | | | |
  195. | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
  196. |FRAMES |SUBFRMS|TYPE |SIZE |DATADATADATAPAD|FRAMES |SUBFRMS|...
  197. </pre>
  198. */
  199. typedef struct {
  200. uint32_t unit; /**< URID of unit of event time stamps. */
  201. uint32_t pad; /**< Currently unused. */
  202. /* Contents (a series of events) follow here. */
  203. } LV2_Atom_Sequence_Body;
  204. /** An atom:Sequence. */
  205. typedef struct {
  206. LV2_Atom atom; /**< Atom header. */
  207. LV2_Atom_Sequence_Body body; /**< Body. */
  208. } LV2_Atom_Sequence;
  209. /**
  210. @}
  211. */
  212. #ifdef __cplusplus
  213. } /* extern "C" */
  214. #endif
  215. #endif /* LV2_ATOM_H */