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.

620 lines
19KB

  1. /*
  2. Copyright 2008-2012 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. @file forge.h An API for constructing LV2 atoms.
  16. This file provides an API for constructing Atoms which makes it relatively
  17. simple to build nested atoms of arbitrary complexity without requiring
  18. dynamic memory allocation.
  19. The API is based on successively appending the appropriate pieces to build a
  20. complete Atom. The size of containers is automatically updated. Functions
  21. that begin a container return (via their frame argument) a stack frame which
  22. must be popped when the container is finished.
  23. All output is written to a user-provided buffer or sink function. This
  24. makes it popssible to create create atoms on the stack, on the heap, in LV2
  25. port buffers, in a ringbuffer, or elsewhere, all using the same API.
  26. This entire API is realtime safe if used with a buffer or a realtime safe
  27. sink, except lv2_atom_forge_init() which is only realtime safe if the URI
  28. map function is.
  29. Note these functions are all static inline, do not take their address.
  30. This header is non-normative, it is provided for convenience.
  31. */
  32. #ifndef LV2_ATOM_FORGE_H
  33. #define LV2_ATOM_FORGE_H
  34. #include <assert.h>
  35. #include "atom.h"
  36. #include "atom-util.h"
  37. #include "urid.h"
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #else
  41. # include <stdbool.h>
  42. #endif
  43. /** Handle for LV2_Atom_Forge_Sink. */
  44. typedef void* LV2_Atom_Forge_Sink_Handle;
  45. /** A reference to a chunk of written output. */
  46. typedef intptr_t LV2_Atom_Forge_Ref;
  47. /** Sink function for writing output. See lv2_atom_forge_set_sink(). */
  48. typedef LV2_Atom_Forge_Ref
  49. (*LV2_Atom_Forge_Sink)(LV2_Atom_Forge_Sink_Handle handle,
  50. const void* buf,
  51. uint32_t size);
  52. /** Function for resolving a reference. See lv2_atom_forge_set_sink(). */
  53. typedef LV2_Atom*
  54. (*LV2_Atom_Forge_Deref_Func)(LV2_Atom_Forge_Sink_Handle handle,
  55. LV2_Atom_Forge_Ref ref);
  56. /** A stack frame used for keeping track of nested Atom containers. */
  57. typedef struct _LV2_Atom_Forge_Frame {
  58. struct _LV2_Atom_Forge_Frame* parent;
  59. LV2_Atom_Forge_Ref ref;
  60. } LV2_Atom_Forge_Frame;
  61. /** A "forge" for creating atoms by appending to a buffer. */
  62. typedef struct {
  63. uint8_t* buf;
  64. uint32_t offset;
  65. uint32_t size;
  66. LV2_Atom_Forge_Sink sink;
  67. LV2_Atom_Forge_Deref_Func deref;
  68. LV2_Atom_Forge_Sink_Handle handle;
  69. LV2_Atom_Forge_Frame* stack;
  70. LV2_URID Blank;
  71. LV2_URID Bool;
  72. LV2_URID Chunk;
  73. LV2_URID Double;
  74. LV2_URID Float;
  75. LV2_URID Int;
  76. LV2_URID Long;
  77. LV2_URID Literal;
  78. LV2_URID Path;
  79. LV2_URID Property;
  80. LV2_URID Resource;
  81. LV2_URID Sequence;
  82. LV2_URID String;
  83. LV2_URID Tuple;
  84. LV2_URID URI;
  85. LV2_URID URID;
  86. LV2_URID Vector;
  87. } LV2_Atom_Forge;
  88. static inline void
  89. lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size);
  90. /**
  91. Initialise @p forge.
  92. URIs will be mapped using @p map and stored, a reference to @p map itself is
  93. not held.
  94. */
  95. static inline void
  96. lv2_atom_forge_init(LV2_Atom_Forge* forge, LV2_URID_Map* map)
  97. {
  98. lv2_atom_forge_set_buffer(forge, NULL, 0);
  99. forge->Blank = map->map(map->handle, LV2_ATOM__Blank);
  100. forge->Bool = map->map(map->handle, LV2_ATOM__Bool);
  101. forge->Chunk = map->map(map->handle, LV2_ATOM__Chunk);
  102. forge->Double = map->map(map->handle, LV2_ATOM__Double);
  103. forge->Float = map->map(map->handle, LV2_ATOM__Float);
  104. forge->Int = map->map(map->handle, LV2_ATOM__Int);
  105. forge->Long = map->map(map->handle, LV2_ATOM__Long);
  106. forge->Literal = map->map(map->handle, LV2_ATOM__Literal);
  107. forge->Path = map->map(map->handle, LV2_ATOM__Path);
  108. forge->Property = map->map(map->handle, LV2_ATOM__Property);
  109. forge->Resource = map->map(map->handle, LV2_ATOM__Resource);
  110. forge->Sequence = map->map(map->handle, LV2_ATOM__Sequence);
  111. forge->String = map->map(map->handle, LV2_ATOM__String);
  112. forge->Tuple = map->map(map->handle, LV2_ATOM__Tuple);
  113. forge->URI = map->map(map->handle, LV2_ATOM__URI);
  114. forge->URID = map->map(map->handle, LV2_ATOM__URID);
  115. forge->Vector = map->map(map->handle, LV2_ATOM__Vector);
  116. }
  117. static inline LV2_Atom*
  118. lv2_atom_forge_deref(LV2_Atom_Forge* forge, LV2_Atom_Forge_Ref ref)
  119. {
  120. if (forge->buf) {
  121. return (LV2_Atom*)ref;
  122. } else {
  123. return forge->deref(forge->handle, ref);
  124. }
  125. }
  126. /**
  127. @name Object Stack
  128. @{
  129. */
  130. /**
  131. Push a stack frame.
  132. This is done automatically by container functions (which take a stack frame
  133. pointer), but may be called by the user to push the top level container when
  134. writing to an existing Atom.
  135. */
  136. static inline LV2_Atom_Forge_Ref
  137. lv2_atom_forge_push(LV2_Atom_Forge* forge,
  138. LV2_Atom_Forge_Frame* frame,
  139. LV2_Atom_Forge_Ref ref)
  140. {
  141. frame->parent = forge->stack;
  142. frame->ref = ref;
  143. forge->stack = frame;
  144. return ref;
  145. }
  146. /** Pop a stack frame. This must be called when a container is finished. */
  147. static inline void
  148. lv2_atom_forge_pop(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame)
  149. {
  150. assert(frame == forge->stack);
  151. forge->stack = frame->parent;
  152. }
  153. /** Return true iff the top of the stack has the given type. */
  154. static inline bool
  155. lv2_atom_forge_top_is(LV2_Atom_Forge* forge, uint32_t type)
  156. {
  157. return forge->stack &&
  158. lv2_atom_forge_deref(forge, forge->stack->ref)->type == type;
  159. }
  160. /**
  161. @}
  162. @name Output Configuration
  163. @{
  164. */
  165. /** Set the output buffer where @p forge will write atoms. */
  166. static inline void
  167. lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size)
  168. {
  169. forge->buf = buf;
  170. forge->size = size;
  171. forge->offset = 0;
  172. forge->deref = NULL;
  173. forge->sink = NULL;
  174. forge->handle = NULL;
  175. forge->stack = NULL;
  176. }
  177. /**
  178. Set the sink function where @p forge will write output.
  179. The return value of forge functions is an LV2_Atom_Forge_Ref which is an
  180. integer type safe to use as a pointer but is otherwise opaque. The sink
  181. function must return a ref that can be dereferenced to access as least
  182. sizeof(LV2_Atom) bytes of the written data, so sizes can be updated. For
  183. ringbuffers, this should be possible as long as the size of the buffer is a
  184. multiple of sizeof(LV2_Atom), since atoms are always aligned.
  185. Note that 0 is an invalid reference, so if you are using a buffer offset be
  186. sure to offset it such that 0 is never a valid reference. You will get
  187. confusing errors otherwise.
  188. */
  189. static inline void
  190. lv2_atom_forge_set_sink(LV2_Atom_Forge* forge,
  191. LV2_Atom_Forge_Sink sink,
  192. LV2_Atom_Forge_Deref_Func deref,
  193. LV2_Atom_Forge_Sink_Handle handle)
  194. {
  195. forge->buf = NULL;
  196. forge->size = forge->offset = 0;
  197. forge->deref = deref;
  198. forge->sink = sink;
  199. forge->handle = handle;
  200. forge->stack = NULL;
  201. }
  202. /**
  203. @}
  204. @name Low Level Output
  205. @{
  206. */
  207. /**
  208. Write raw output. This is used internally, but is also useful for writing
  209. atom types not explicitly supported by the forge API. Note the caller is
  210. responsible for ensuring the output is approriately padded.
  211. */
  212. static inline LV2_Atom_Forge_Ref
  213. lv2_atom_forge_raw(LV2_Atom_Forge* forge, const void* data, uint32_t size)
  214. {
  215. LV2_Atom_Forge_Ref out = 0;
  216. if (forge->sink) {
  217. out = forge->sink(forge->handle, data, size);
  218. } else {
  219. out = (LV2_Atom_Forge_Ref)forge->buf + forge->offset;
  220. uint8_t* mem = forge->buf + forge->offset;
  221. if (forge->offset + size > forge->size) {
  222. return 0;
  223. }
  224. forge->offset += size;
  225. memcpy(mem, data, size);
  226. }
  227. for (LV2_Atom_Forge_Frame* f = forge->stack; f; f = f->parent) {
  228. lv2_atom_forge_deref(forge, f->ref)->size += size;
  229. }
  230. return out;
  231. }
  232. /** Pad output accordingly so next write is 64-bit aligned. */
  233. static inline void
  234. lv2_atom_forge_pad(LV2_Atom_Forge* forge, uint32_t written)
  235. {
  236. const uint64_t pad = 0;
  237. const uint32_t pad_size = lv2_atom_pad_size(written) - written;
  238. lv2_atom_forge_raw(forge, &pad, pad_size);
  239. }
  240. /** Write raw output, padding to 64-bits as necessary. */
  241. static inline LV2_Atom_Forge_Ref
  242. lv2_atom_forge_write(LV2_Atom_Forge* forge, const void* data, uint32_t size)
  243. {
  244. LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, data, size);
  245. if (out) {
  246. lv2_atom_forge_pad(forge, size);
  247. }
  248. return out;
  249. }
  250. /** Write a null-terminated string body. */
  251. static inline LV2_Atom_Forge_Ref
  252. lv2_atom_forge_string_body(LV2_Atom_Forge* forge,
  253. const char* str,
  254. uint32_t len)
  255. {
  256. LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, str, len);
  257. if (out && (out = lv2_atom_forge_raw(forge, "", 1))) {
  258. lv2_atom_forge_pad(forge, len + 1);
  259. }
  260. return out;
  261. }
  262. /**
  263. @}
  264. @name Atom Output
  265. @{
  266. */
  267. /** Write an atom:Atom header. */
  268. static inline LV2_Atom_Forge_Ref
  269. lv2_atom_forge_atom(LV2_Atom_Forge* forge, uint32_t size, uint32_t type)
  270. {
  271. const LV2_Atom a = { size, type };
  272. return lv2_atom_forge_raw(forge, &a, sizeof(a));
  273. }
  274. /** Write a primitive (fixed-size) atom. */
  275. static inline LV2_Atom_Forge_Ref
  276. lv2_atom_forge_primitive(LV2_Atom_Forge* forge, const LV2_Atom* a)
  277. {
  278. if (lv2_atom_forge_top_is(forge, forge->Vector)) {
  279. return lv2_atom_forge_raw(forge, LV2_ATOM_BODY(a), a->size);
  280. } else {
  281. return lv2_atom_forge_write(forge, a, sizeof(LV2_Atom) + a->size);
  282. }
  283. }
  284. /** Write an atom:Int. */
  285. static inline LV2_Atom_Forge_Ref
  286. lv2_atom_forge_int(LV2_Atom_Forge* forge, int32_t val)
  287. {
  288. const LV2_Atom_Int a = { { sizeof(val), forge->Int }, val };
  289. return lv2_atom_forge_primitive(forge, &a.atom);
  290. }
  291. /** Write an atom:Long. */
  292. static inline LV2_Atom_Forge_Ref
  293. lv2_atom_forge_long(LV2_Atom_Forge* forge, int64_t val)
  294. {
  295. const LV2_Atom_Long a = { { sizeof(val), forge->Long }, val };
  296. return lv2_atom_forge_primitive(forge, &a.atom);
  297. }
  298. /** Write an atom:Float. */
  299. static inline LV2_Atom_Forge_Ref
  300. lv2_atom_forge_float(LV2_Atom_Forge* forge, float val)
  301. {
  302. const LV2_Atom_Float a = { { sizeof(val), forge->Float }, val };
  303. return lv2_atom_forge_primitive(forge, &a.atom);
  304. }
  305. /** Write an atom:Double. */
  306. static inline LV2_Atom_Forge_Ref
  307. lv2_atom_forge_double(LV2_Atom_Forge* forge, double val)
  308. {
  309. const LV2_Atom_Double a = { { sizeof(val), forge->Double }, val };
  310. return lv2_atom_forge_primitive(forge, &a.atom);
  311. }
  312. /** Write an atom:Bool. */
  313. static inline LV2_Atom_Forge_Ref
  314. lv2_atom_forge_bool(LV2_Atom_Forge* forge, bool val)
  315. {
  316. const LV2_Atom_Bool a = { { sizeof(int32_t), forge->Bool }, val ? 1 : 0 };
  317. return lv2_atom_forge_primitive(forge, &a.atom);
  318. }
  319. /** Write an atom:URID. */
  320. static inline LV2_Atom_Forge_Ref
  321. lv2_atom_forge_urid(LV2_Atom_Forge* forge, LV2_URID id)
  322. {
  323. const LV2_Atom_URID a = { { sizeof(id), forge->URID }, id };
  324. return lv2_atom_forge_primitive(forge, &a.atom);
  325. }
  326. /** Write an atom compatible with atom:String. Used internally. */
  327. static inline LV2_Atom_Forge_Ref
  328. lv2_atom_forge_typed_string(LV2_Atom_Forge* forge,
  329. uint32_t type,
  330. const char* str,
  331. uint32_t len)
  332. {
  333. const LV2_Atom_String a = { { len + 1, type } };
  334. LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a));
  335. if (out) {
  336. if (!lv2_atom_forge_string_body(forge, str, len)) {
  337. LV2_Atom* atom = lv2_atom_forge_deref(forge, out);
  338. atom->size = atom->type = 0;
  339. out = 0;
  340. }
  341. }
  342. return out;
  343. }
  344. /** Write an atom:String. Note that @p str need not be NULL terminated. */
  345. static inline LV2_Atom_Forge_Ref
  346. lv2_atom_forge_string(LV2_Atom_Forge* forge, const char* str, uint32_t len)
  347. {
  348. return lv2_atom_forge_typed_string(forge, forge->String, str, len);
  349. }
  350. /**
  351. Write an atom:URI. Note that @p uri need not be NULL terminated.
  352. This does not map the URI, but writes the complete URI string. To write
  353. a mapped URI, use lv2_atom_forge_urid().
  354. */
  355. static inline LV2_Atom_Forge_Ref
  356. lv2_atom_forge_uri(LV2_Atom_Forge* forge, const char* uri, uint32_t len)
  357. {
  358. return lv2_atom_forge_typed_string(forge, forge->URI, uri, len);
  359. }
  360. /** Write an atom:Path. Note that @p path need not be NULL terminated. */
  361. static inline LV2_Atom_Forge_Ref
  362. lv2_atom_forge_path(LV2_Atom_Forge* forge, const char* path, uint32_t len)
  363. {
  364. return lv2_atom_forge_typed_string(forge, forge->Path, path, len);
  365. }
  366. /** Write an atom:Literal. */
  367. static inline LV2_Atom_Forge_Ref
  368. lv2_atom_forge_literal(LV2_Atom_Forge* forge,
  369. const char* str,
  370. uint32_t len,
  371. uint32_t datatype,
  372. uint32_t lang)
  373. {
  374. const LV2_Atom_Literal a = {
  375. { (uint32_t)(sizeof(LV2_Atom_Literal) - sizeof(LV2_Atom) + len + 1),
  376. forge->Literal },
  377. { datatype,
  378. lang }
  379. };
  380. LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a));
  381. if (out) {
  382. if (!lv2_atom_forge_string_body(forge, str, len)) {
  383. LV2_Atom* atom = lv2_atom_forge_deref(forge, out);
  384. atom->size = atom->type = 0;
  385. out = 0;
  386. }
  387. }
  388. return out;
  389. }
  390. /** Start an atom:Vector. */
  391. static inline LV2_Atom_Forge_Ref
  392. lv2_atom_forge_vector_head(LV2_Atom_Forge* forge,
  393. LV2_Atom_Forge_Frame* frame,
  394. uint32_t child_size,
  395. uint32_t child_type)
  396. {
  397. const LV2_Atom_Vector a = {
  398. { sizeof(LV2_Atom_Vector_Body), forge->Vector },
  399. { child_size, child_type }
  400. };
  401. return lv2_atom_forge_push(
  402. forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
  403. }
  404. /** Write a complete atom:Vector. */
  405. static inline LV2_Atom_Forge_Ref
  406. lv2_atom_forge_vector(LV2_Atom_Forge* forge,
  407. uint32_t child_size,
  408. uint32_t child_type,
  409. uint32_t n_elems,
  410. const void* elems)
  411. {
  412. const LV2_Atom_Vector a = {
  413. { (uint32_t)(sizeof(LV2_Atom_Vector_Body) + n_elems * child_size),
  414. forge->Vector },
  415. { child_size, child_type }
  416. };
  417. LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
  418. if (out) {
  419. lv2_atom_forge_write(forge, elems, child_size * n_elems);
  420. }
  421. return out;
  422. }
  423. /**
  424. Write the header of an atom:Tuple.
  425. The passed frame will be initialised to represent this tuple. To complete
  426. the tuple, write a sequence of atoms, then pop the frame with
  427. lv2_atom_forge_pop().
  428. For example:
  429. @code
  430. // Write tuple (1, 2.0)
  431. LV2_Atom_Forge_Frame frame;
  432. LV2_Atom* tup = (LV2_Atom*)lv2_atom_forge_tuple(forge, &frame);
  433. lv2_atom_forge_int32(forge, 1);
  434. lv2_atom_forge_float(forge, 2.0);
  435. lv2_atom_forge_pop(forge, &frame);
  436. @endcode
  437. */
  438. static inline LV2_Atom_Forge_Ref
  439. lv2_atom_forge_tuple(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame)
  440. {
  441. const LV2_Atom_Tuple a = { { 0, forge->Tuple } };
  442. return lv2_atom_forge_push(
  443. forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
  444. }
  445. /**
  446. Write the header of an atom:Resource.
  447. The passed frame will be initialised to represent this object. To complete
  448. the object, write a sequence of properties, then pop the frame with
  449. lv2_atom_forge_pop().
  450. For example:
  451. @code
  452. LV2_URID eg_Cat = map("http://example.org/Cat");
  453. LV2_URID eg_name = map("http://example.org/name");
  454. // Write object header
  455. LV2_Atom_Forge_Frame frame;
  456. lv2_atom_forge_resource(forge, &frame, 1, eg_Cat);
  457. // Write property: eg:name = "Hobbes"
  458. lv2_atom_forge_property_head(forge, eg_name, 0);
  459. lv2_atom_forge_string(forge, "Hobbes", strlen("Hobbes"));
  460. // Finish object
  461. lv2_atom_forge_pop(forge, &frame);
  462. @endcode
  463. */
  464. static inline LV2_Atom_Forge_Ref
  465. lv2_atom_forge_resource(LV2_Atom_Forge* forge,
  466. LV2_Atom_Forge_Frame* frame,
  467. LV2_URID id,
  468. LV2_URID otype)
  469. {
  470. const LV2_Atom_Object a = {
  471. { sizeof(LV2_Atom_Object) - sizeof(LV2_Atom), forge->Resource },
  472. { id, otype }
  473. };
  474. LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
  475. return lv2_atom_forge_push(forge, frame, out);
  476. }
  477. /**
  478. The same as lv2_atom_forge_resource(), but for object:Blank.
  479. */
  480. static inline LV2_Atom_Forge_Ref
  481. lv2_atom_forge_blank(LV2_Atom_Forge* forge,
  482. LV2_Atom_Forge_Frame* frame,
  483. uint32_t id,
  484. LV2_URID otype)
  485. {
  486. const LV2_Atom_Object a = {
  487. { sizeof(LV2_Atom_Object) - sizeof(LV2_Atom), forge->Blank },
  488. { id, otype }
  489. };
  490. LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
  491. return lv2_atom_forge_push(forge, frame, out);
  492. }
  493. /**
  494. Write the header for a property body (likely in an Object).
  495. See lv2_atom_forge_resource() documentation for an example.
  496. */
  497. static inline LV2_Atom_Forge_Ref
  498. lv2_atom_forge_property_head(LV2_Atom_Forge* forge,
  499. LV2_URID key,
  500. LV2_URID context)
  501. {
  502. const LV2_Atom_Property_Body a = { key, context, { 0, 0 } };
  503. return lv2_atom_forge_write(forge, &a, 2 * sizeof(uint32_t));
  504. }
  505. /**
  506. Write the header for a Sequence.
  507. */
  508. static inline LV2_Atom_Forge_Ref
  509. lv2_atom_forge_sequence_head(LV2_Atom_Forge* forge,
  510. LV2_Atom_Forge_Frame* frame,
  511. uint32_t unit)
  512. {
  513. const LV2_Atom_Sequence a = {
  514. { sizeof(LV2_Atom_Sequence) - sizeof(LV2_Atom), forge->Sequence },
  515. { unit, 0 }
  516. };
  517. LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
  518. return lv2_atom_forge_push(forge, frame, out);
  519. }
  520. /**
  521. Write the time stamp header of an Event (in a Sequence) in audio frames.
  522. After this, call the appropriate forge method(s) to write the body. Note
  523. the returned reference is to an LV2_Event which is NOT an Atom.
  524. */
  525. static inline LV2_Atom_Forge_Ref
  526. lv2_atom_forge_frame_time(LV2_Atom_Forge* forge, int64_t frames)
  527. {
  528. return lv2_atom_forge_write(forge, &frames, sizeof(frames));
  529. }
  530. /**
  531. Write the time stamp header of an Event (in a Sequence) in beats. After
  532. this, call the appropriate forge method(s) to write the body. Note the
  533. returned reference is to an LV2_Event which is NOT an Atom.
  534. */
  535. static inline LV2_Atom_Forge_Ref
  536. lv2_atom_forge_beat_time(LV2_Atom_Forge* forge, double beats)
  537. {
  538. return lv2_atom_forge_write(forge, &beats, sizeof(beats));
  539. }
  540. /**
  541. @}
  542. */
  543. #ifdef __cplusplus
  544. } /* extern "C" */
  545. #endif
  546. #endif /* LV2_ATOM_FORGE_H */