Collection of tools useful for audio production
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.

1724 lines
51KB

  1. /*
  2. Copyright 2007-2011 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 lilv.h API for Lilv, a lightweight LV2 host library.
  16. */
  17. #ifndef LILV_LILV_H
  18. #define LILV_LILV_H
  19. #include <stddef.h>
  20. #include <stdint.h>
  21. #include <stdio.h>
  22. #include "lv2/lv2.h"
  23. #include "lv2/urid.h"
  24. #ifdef LILV_SHARED
  25. # ifdef _WIN32
  26. # define LILV_LIB_IMPORT __declspec(dllimport)
  27. # define LILV_LIB_EXPORT __declspec(dllexport)
  28. # else
  29. # define LILV_LIB_IMPORT __attribute__((visibility("default")))
  30. # define LILV_LIB_EXPORT __attribute__((visibility("default")))
  31. # endif
  32. # ifdef LILV_INTERNAL
  33. # define LILV_API LILV_LIB_EXPORT
  34. # else
  35. # define LILV_API LILV_LIB_IMPORT
  36. # endif
  37. #else
  38. # define LILV_API
  39. #endif
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #else
  43. # include <stdbool.h>
  44. #endif
  45. #define LILV_NS_DOAP "http://usefulinc.com/ns/doap#"
  46. #define LILV_NS_FOAF "http://xmlns.com/foaf/0.1/"
  47. #define LILV_NS_LILV "http://drobilla.net/ns/lilv#"
  48. #define LILV_NS_LV2 "http://lv2plug.in/ns/lv2core#"
  49. #define LILV_NS_OWL "http://www.w3.org/2002/07/owl#"
  50. #define LILV_NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  51. #define LILV_NS_RDFS "http://www.w3.org/2000/01/rdf-schema#"
  52. #define LILV_NS_XSD "http://www.w3.org/2001/XMLSchema#"
  53. #define LILV_URI_AUDIO_PORT "http://lv2plug.in/ns/lv2core#AudioPort"
  54. #define LILV_URI_CONTROL_PORT "http://lv2plug.in/ns/lv2core#ControlPort"
  55. #define LILV_URI_EVENT_PORT "http://lv2plug.in/ns/ext/event#EventPort"
  56. #define LILV_URI_INPUT_PORT "http://lv2plug.in/ns/lv2core#InputPort"
  57. #define LILV_URI_MIDI_EVENT "http://lv2plug.in/ns/ext/midi#MidiEvent"
  58. #define LILV_URI_OUTPUT_PORT "http://lv2plug.in/ns/lv2core#OutputPort"
  59. #define LILV_URI_PORT "http://lv2plug.in/ns/lv2core#Port"
  60. typedef struct LilvPluginImpl LilvPlugin; /**< LV2 Plugin. */
  61. typedef struct LilvPluginClassImpl LilvPluginClass; /**< Plugin Class. */
  62. typedef struct LilvPortImpl LilvPort; /**< Port. */
  63. typedef struct LilvScalePointImpl LilvScalePoint; /**< Scale Point. */
  64. typedef struct LilvUIImpl LilvUI; /**< Plugin UI. */
  65. typedef struct LilvNodeImpl LilvNode; /**< Typed Value. */
  66. typedef struct LilvWorldImpl LilvWorld; /**< Lilv World. */
  67. typedef struct LilvInstanceImpl LilvInstance; /**< Plugin instance. */
  68. typedef struct LilvStateImpl LilvState; /**< Plugin state. */
  69. typedef void LilvIter; /**< Collection iterator */
  70. typedef void LilvPluginClasses; /**< set<PluginClass>. */
  71. typedef void LilvPlugins; /**< set<Plugin>. */
  72. typedef void LilvScalePoints; /**< set<ScalePoint>. */
  73. typedef void LilvUIs; /**< set<UI>. */
  74. typedef void LilvNodes; /**< set<Node>. */
  75. /**
  76. @defgroup lilv Lilv
  77. Lilv is a simple yet powerful C API for using LV2 plugins.
  78. For more information about LV2, see <http://lv2plug.in>.
  79. For more information about Lilv, see <http://drobilla.net/software/lilv>.
  80. @{
  81. */
  82. /**
  83. @name Node
  84. @{
  85. */
  86. /**
  87. Convert a file URI string to a local path string.
  88. For example, "file://foo/bar/baz.ttl" returns "/foo/bar/baz.ttl".
  89. Return value is shared and must not be deleted by caller.
  90. @return @a uri converted to a path, or NULL on failure (URI is not local).
  91. */
  92. LILV_API
  93. const char*
  94. lilv_uri_to_path(const char* uri);
  95. /**
  96. Create a new URI value.
  97. Returned value must be freed by caller with lilv_node_free.
  98. */
  99. LILV_API
  100. LilvNode*
  101. lilv_new_uri(LilvWorld* world, const char* uri);
  102. /**
  103. Create a new string value (with no language).
  104. Returned value must be freed by caller with lilv_node_free.
  105. */
  106. LILV_API
  107. LilvNode*
  108. lilv_new_string(LilvWorld* world, const char* str);
  109. /**
  110. Create a new integer value.
  111. Returned value must be freed by caller with lilv_node_free.
  112. */
  113. LILV_API
  114. LilvNode*
  115. lilv_new_int(LilvWorld* world, int val);
  116. /**
  117. Create a new floating point value.
  118. Returned value must be freed by caller with lilv_node_free.
  119. */
  120. LILV_API
  121. LilvNode*
  122. lilv_new_float(LilvWorld* world, float val);
  123. /**
  124. Create a new boolean value.
  125. Returned value must be freed by caller with lilv_node_free.
  126. */
  127. LILV_API
  128. LilvNode*
  129. lilv_new_bool(LilvWorld* world, bool val);
  130. /**
  131. Free a LilvNode.
  132. It is safe to call this function on NULL.
  133. */
  134. LILV_API
  135. void
  136. lilv_node_free(LilvNode* val);
  137. /**
  138. Duplicate a LilvNode.
  139. */
  140. LILV_API
  141. LilvNode*
  142. lilv_node_duplicate(const LilvNode* val);
  143. /**
  144. Return whether two values are equivalent.
  145. */
  146. LILV_API
  147. bool
  148. lilv_node_equals(const LilvNode* value, const LilvNode* other);
  149. /**
  150. Return this value as a Turtle/SPARQL token.
  151. Returned value must be freed by caller with free().
  152. <table>
  153. <caption>Example Turtle Tokens</caption>
  154. <tr><th>URI</th><td>&lt;http://example.org/foo &gt;</td></tr>
  155. <tr><th>QName</td><td>doap:name</td></tr>
  156. <tr><th>String</td><td>"this is a string"</td></tr>
  157. <tr><th>Float</td><td>1.0</td></tr>
  158. <tr><th>Integer</td><td>1</td></tr>
  159. <tr><th>Boolean</td><td>true</td></tr>
  160. </table>
  161. */
  162. LILV_API
  163. char*
  164. lilv_node_get_turtle_token(const LilvNode* value);
  165. /**
  166. Return whether the value is a URI (resource).
  167. */
  168. LILV_API
  169. bool
  170. lilv_node_is_uri(const LilvNode* value);
  171. /**
  172. Return this value as a URI string, e.g. "http://example.org/foo".
  173. Valid to call only if lilv_node_is_uri(@a value) returns true.
  174. Returned value is owned by @a value and must not be freed by caller.
  175. */
  176. LILV_API
  177. const char*
  178. lilv_node_as_uri(const LilvNode* value);
  179. /**
  180. Return whether the value is a blank node (resource with no URI).
  181. */
  182. LILV_API
  183. bool
  184. lilv_node_is_blank(const LilvNode* value);
  185. /**
  186. Return this value as a blank node identifier, e.g. "genid03".
  187. Valid to call only if lilv_node_is_blank(@a value) returns true.
  188. Returned value is owned by @a value and must not be freed by caller.
  189. */
  190. LILV_API
  191. const char*
  192. lilv_node_as_blank(const LilvNode* value);
  193. /**
  194. Return whether this value is a literal (i.e. not a URI).
  195. Returns true if @a value is a string or numeric value.
  196. */
  197. LILV_API
  198. bool
  199. lilv_node_is_literal(const LilvNode* value);
  200. /**
  201. Return whether this value is a string literal.
  202. Returns true if @a value is a string value (and not numeric).
  203. */
  204. LILV_API
  205. bool
  206. lilv_node_is_string(const LilvNode* value);
  207. /**
  208. Return @a value as a string.
  209. */
  210. LILV_API
  211. const char*
  212. lilv_node_as_string(const LilvNode* value);
  213. /**
  214. Return whether this value is a decimal literal.
  215. */
  216. LILV_API
  217. bool
  218. lilv_node_is_float(const LilvNode* value);
  219. /**
  220. Return @a value as a float.
  221. Valid to call only if lilv_node_is_float(@a value) or
  222. lilv_node_is_int(@a value) returns true.
  223. */
  224. LILV_API
  225. float
  226. lilv_node_as_float(const LilvNode* value);
  227. /**
  228. Return whether this value is an integer literal.
  229. */
  230. LILV_API
  231. bool
  232. lilv_node_is_int(const LilvNode* value);
  233. /**
  234. Return @a value as an integer.
  235. Valid to call only if lilv_node_is_int(@a value) returns true.
  236. */
  237. LILV_API
  238. int
  239. lilv_node_as_int(const LilvNode* value);
  240. /**
  241. Return whether this value is a boolean.
  242. */
  243. LILV_API
  244. bool
  245. lilv_node_is_bool(const LilvNode* value);
  246. /**
  247. Return @a value as a bool.
  248. Valid to call only if lilv_node_is_bool(@a value) returns true.
  249. */
  250. LILV_API
  251. bool
  252. lilv_node_as_bool(const LilvNode* value);
  253. /**
  254. @}
  255. @name Collections
  256. Lilv has several collection types for holding various types of value:
  257. <ul>
  258. <li>LilvPlugins (function prefix "lilv_plugins_")</li>
  259. <li>LilvPluginClasses (function prefix "lilv_plugin_classes_")</li>
  260. <li>LilvScalePoints (function prefix "lilv_scale_points_")</li>
  261. <li>LilvNodes (function prefix "lilv_nodes_")</li>
  262. <li>LilvUIs (function prefix "lilv_uis_")</li>
  263. </ul>
  264. Each collection type supports a similar basic API (except LilvPlugins which
  265. is internal and thus lacks a free function):
  266. <ul>
  267. <li>void PREFIX_free (coll)</li>
  268. <li>unsigned PREFIX_size (coll)</li>
  269. <li>LilvIter* PREFIX_begin (coll)</li>
  270. </ul>
  271. @{
  272. */
  273. /* Collections */
  274. /**
  275. Iterate over each element of a collection.
  276. @code
  277. LILV_FOREACH(plugin_classes, i, classes) {
  278. LilvPluginClass c = lilv_plugin_classes_get(classes, i);
  279. // ...
  280. }
  281. @endcode
  282. */
  283. #define LILV_FOREACH(colltype, iter, collection) \
  284. for (LilvIter* (iter) = lilv_ ## colltype ## _begin(collection); \
  285. !lilv_ ## colltype ## _is_end(collection, iter); \
  286. (iter) = lilv_ ## colltype ## _next(collection, iter))
  287. /* LilvPluginClasses */
  288. LILV_API
  289. void
  290. lilv_plugin_classes_free(LilvPluginClasses* collection);
  291. LILV_API
  292. unsigned
  293. lilv_plugin_classes_size(const LilvPluginClasses* collection);
  294. LILV_API
  295. LilvIter*
  296. lilv_plugin_classes_begin(const LilvPluginClasses* collection);
  297. LILV_API
  298. const LilvPluginClass*
  299. lilv_plugin_classes_get(const LilvPluginClasses* collection, LilvIter* i);
  300. LILV_API
  301. LilvIter*
  302. lilv_plugin_classes_next(const LilvPluginClasses* collection, LilvIter* i);
  303. LILV_API
  304. bool
  305. lilv_plugin_classes_is_end(const LilvPluginClasses* collection, LilvIter* i);
  306. /**
  307. Get a plugin class from @a classes by URI.
  308. Return value is shared (stored in @a classes) and must not be freed or
  309. modified by the caller in any way.
  310. @return NULL if no plugin class with @a uri is found in @a classes.
  311. */
  312. LILV_API
  313. const LilvPluginClass*
  314. lilv_plugin_classes_get_by_uri(const LilvPluginClasses* classes,
  315. const LilvNode* uri);
  316. /* ScalePoints */
  317. LILV_API
  318. void
  319. lilv_scale_points_free(LilvScalePoints* collection);
  320. LILV_API
  321. unsigned
  322. lilv_scale_points_size(const LilvScalePoints* collection);
  323. LILV_API
  324. LilvIter*
  325. lilv_scale_points_begin(const LilvScalePoints* collection);
  326. LILV_API
  327. const LilvScalePoint*
  328. lilv_scale_points_get(const LilvScalePoints* collection, LilvIter* i);
  329. LILV_API
  330. LilvIter*
  331. lilv_scale_points_next(const LilvScalePoints* collection, LilvIter* i);
  332. LILV_API
  333. bool
  334. lilv_scale_points_is_end(const LilvScalePoints* collection, LilvIter* i);
  335. /* UIs */
  336. LILV_API
  337. void
  338. lilv_uis_free(LilvUIs* collection);
  339. LILV_API
  340. unsigned
  341. lilv_uis_size(const LilvUIs* collection);
  342. LILV_API
  343. LilvIter*
  344. lilv_uis_begin(const LilvUIs* collection);
  345. LILV_API
  346. const LilvUI*
  347. lilv_uis_get(const LilvUIs* collection, LilvIter* i);
  348. LILV_API
  349. LilvIter*
  350. lilv_uis_next(const LilvUIs* collection, LilvIter* i);
  351. LILV_API
  352. bool
  353. lilv_uis_is_end(const LilvUIs* collection, LilvIter* i);
  354. /**
  355. Get a UI from @a uis by URI.
  356. Return value is shared (stored in @a uis) and must not be freed or
  357. modified by the caller in any way.
  358. @return NULL if no UI with @a uri is found in @a list.
  359. */
  360. LILV_API
  361. const LilvUI*
  362. lilv_uis_get_by_uri(const LilvUIs* uis,
  363. const LilvNode* uri);
  364. /* Nodes */
  365. LILV_API
  366. void
  367. lilv_nodes_free(LilvNodes* collection);
  368. LILV_API
  369. unsigned
  370. lilv_nodes_size(const LilvNodes* collection);
  371. LILV_API
  372. LilvIter*
  373. lilv_nodes_begin(const LilvNodes* collection);
  374. LILV_API
  375. const LilvNode*
  376. lilv_nodes_get(const LilvNodes* collection, LilvIter* i);
  377. LILV_API
  378. LilvIter*
  379. lilv_nodes_next(const LilvNodes* collection, LilvIter* i);
  380. LILV_API
  381. bool
  382. lilv_nodes_is_end(const LilvNodes* collection, LilvIter* i);
  383. LILV_API
  384. LilvNode*
  385. lilv_nodes_get_first(const LilvNodes* collection);
  386. /**
  387. Return whether @a values contains @a value.
  388. */
  389. LILV_API
  390. bool
  391. lilv_nodes_contains(const LilvNodes* values, const LilvNode* value);
  392. /* Plugins */
  393. LILV_API
  394. unsigned
  395. lilv_plugins_size(const LilvPlugins* collection);
  396. LILV_API
  397. LilvIter*
  398. lilv_plugins_begin(const LilvPlugins* collection);
  399. LILV_API
  400. const LilvPlugin*
  401. lilv_plugins_get(const LilvPlugins* collection, LilvIter* i);
  402. LILV_API
  403. LilvIter*
  404. lilv_plugins_next(const LilvPlugins* collection, LilvIter* i);
  405. LILV_API
  406. bool
  407. lilv_plugins_is_end(const LilvPlugins* collection, LilvIter* i);
  408. /**
  409. Get a plugin from @a plugins by URI.
  410. Return value is shared (stored in @a plugins) and must not be freed or
  411. modified by the caller in any way.
  412. @return NULL if no plugin with @a uri is found in @a plugins.
  413. */
  414. LILV_API
  415. const LilvPlugin*
  416. lilv_plugins_get_by_uri(const LilvPlugins* plugins,
  417. const LilvNode* uri);
  418. /**
  419. @}
  420. @name World
  421. The "world" represents all Lilv state, and is used to discover/load/cache
  422. LV2 data (plugins, UIs, and extensions).
  423. Normal hosts which just need to load plugins by URI should simply use
  424. @ref lilv_world_load_all to discover/load the system's LV2 resources.
  425. @{
  426. */
  427. /**
  428. Initialize a new, empty world.
  429. If initialization fails, NULL is returned.
  430. */
  431. LILV_API
  432. LilvWorld*
  433. lilv_world_new(void);
  434. /**
  435. Enable/disable language filtering.
  436. Language filtering applies to any functions that return (a) value(s).
  437. With filtering enabled, Lilv will automatically return the best value(s)
  438. for the current LANG. With filtering disabled, all matching values will
  439. be returned regardless of language tag. Filtering is enabled by default.
  440. */
  441. #define LILV_OPTION_FILTER_LANG "http://drobilla.net/ns/lilv#filter-lang"
  442. /**
  443. Enable/disable dynamic manifest support.
  444. Dynamic manifest data will only be loaded if this option is true.
  445. */
  446. #define LILV_OPTION_DYN_MANIFEST "http://drobilla.net/ns/lilv#dyn-manifest"
  447. /**
  448. Set an option option for @a world.
  449. Currently recognized options:
  450. @ref LILV_OPTION_FILTER_LANG
  451. @ref LILV_OPTION_DYN_MANIFEST
  452. */
  453. LILV_API
  454. void
  455. lilv_world_set_option(LilvWorld* world,
  456. const char* uri,
  457. const LilvNode* value);
  458. /**
  459. Destroy the world, mwahaha.
  460. It is safe to call this function on NULL.
  461. Note that destroying @a world will destroy all the objects it contains
  462. (e.g. instances of LilvPlugin). Do not destroy the world until you are
  463. finished with all objects that came from it.
  464. */
  465. LILV_API
  466. void
  467. lilv_world_free(LilvWorld* world);
  468. /**
  469. Load all installed LV2 bundles on the system.
  470. This is the recommended way for hosts to load LV2 data. It implements the
  471. established/standard best practice for discovering all LV2 data on the
  472. system. The environment variable LV2_PATH may be used to control where
  473. this function will look for bundles.
  474. Hosts should use this function rather than explicitly load bundles, except
  475. in special circumstances (e.g. development utilities, or hosts that ship
  476. with special plugin bundles which are installed to a known location).
  477. */
  478. LILV_API
  479. void
  480. lilv_world_load_all(LilvWorld* world);
  481. /**
  482. Load a specific bundle.
  483. @a bundle_uri must be a fully qualified URI to the bundle directory,
  484. with the trailing slash, eg. file:///usr/lib/lv2/foo.lv2/
  485. Normal hosts should not need this function (use lilv_world_load_all).
  486. Hosts MUST NOT attach any long-term significance to bundle paths
  487. (e.g. in save files), since there are no guarantees they will remain
  488. unchanged between (or even during) program invocations. Plugins (among
  489. other things) MUST be identified by URIs (not paths) in save files.
  490. */
  491. LILV_API
  492. void
  493. lilv_world_load_bundle(LilvWorld* world,
  494. LilvNode* bundle_uri);
  495. /**
  496. Load all the data associated with the given @c resource.
  497. @param resource Must be a subject (i.e. a URI or a blank node).
  498. @return The number of files parsed, or -1 on error
  499. All accessible data files linked to @c resource with rdfs:seeAlso will be
  500. loaded into the world model.
  501. */
  502. LILV_API
  503. int
  504. lilv_world_load_resource(LilvWorld* world,
  505. const LilvNode* resource);
  506. /**
  507. Get the parent of all other plugin classes, lv2:Plugin.
  508. */
  509. LILV_API
  510. const LilvPluginClass*
  511. lilv_world_get_plugin_class(const LilvWorld* world);
  512. /**
  513. Return a list of all found plugin classes.
  514. Returned list is owned by world and must not be freed by the caller.
  515. */
  516. LILV_API
  517. const LilvPluginClasses*
  518. lilv_world_get_plugin_classes(const LilvWorld* world);
  519. /**
  520. Return a list of all found plugins.
  521. The returned list contains just enough references to query
  522. or instantiate plugins. The data for a particular plugin will not be
  523. loaded into memory until a call to an lilv_plugin_* function results in
  524. a query (at which time the data is cached with the LilvPlugin so future
  525. queries are very fast).
  526. The returned list and the plugins it contains are owned by @a world
  527. and must not be freed by caller.
  528. */
  529. LILV_API
  530. const LilvPlugins*
  531. lilv_world_get_all_plugins(const LilvWorld* world);
  532. /**
  533. Find nodes matching a triple pattern.
  534. Either @c subject or @c object may be NULL (i.e. a wildcard), but not both.
  535. @return All matches for the wildcard field, or NULL.
  536. */
  537. LILV_API
  538. LilvNodes*
  539. lilv_world_find_nodes(LilvWorld* world,
  540. const LilvNode* subject,
  541. const LilvNode* predicate,
  542. const LilvNode* object);
  543. /**
  544. @}
  545. @name Plugin
  546. @{
  547. */
  548. /**
  549. Check if @a plugin is valid.
  550. This is not a rigorous validator, but can be used to reject some malformed
  551. plugins that could cause bugs (e.g. plugins with missing required fields).
  552. Note that normal hosts do NOT need to use this - lilv does not
  553. load invalid plugins into plugin lists. This is included for plugin
  554. testing utilities, etc.
  555. @return true iff @a plugin is valid.
  556. */
  557. LILV_API
  558. bool
  559. lilv_plugin_verify(const LilvPlugin* plugin);
  560. /**
  561. Get the URI of @a plugin.
  562. Any serialization that refers to plugins should refer to them by this.
  563. Hosts SHOULD NOT save any filesystem paths, plugin indexes, etc. in saved
  564. files; save only the URI.
  565. The URI is a globally unique identifier for one specific plugin. Two
  566. plugins with the same URI are compatible in port signature, and should
  567. be guaranteed to work in a compatible and consistent way. If a plugin
  568. is upgraded in an incompatible way (eg if it has different ports), it
  569. MUST have a different URI than it's predecessor.
  570. @return A shared URI value which must not be modified or freed.
  571. */
  572. LILV_API
  573. const LilvNode*
  574. lilv_plugin_get_uri(const LilvPlugin* plugin);
  575. /**
  576. Get the (resolvable) URI of the plugin's "main" bundle.
  577. This returns the URI of the bundle where the plugin itself was found.
  578. Note that the data for a plugin may be spread over many bundles, that is,
  579. lilv_plugin_get_data_uris may return URIs which are not within this bundle.
  580. Typical hosts should not need to use this function.
  581. Note this always returns a fully qualified URI. If you want a local
  582. filesystem path, use lilv_uri_to_path.
  583. @return a shared string which must not be modified or freed.
  584. */
  585. LILV_API
  586. const LilvNode*
  587. lilv_plugin_get_bundle_uri(const LilvPlugin* plugin);
  588. /**
  589. Get the (resolvable) URIs of the RDF data files that define a plugin.
  590. Typical hosts should not need to use this function.
  591. Note this always returns fully qualified URIs. If you want local
  592. filesystem paths, use lilv_uri_to_path.
  593. @return a list of complete URLs eg. "file:///foo/ABundle.lv2/aplug.ttl",
  594. which is shared and must not be modified or freed.
  595. */
  596. LILV_API
  597. const LilvNodes*
  598. lilv_plugin_get_data_uris(const LilvPlugin* plugin);
  599. /**
  600. Get the (resolvable) URI of the shared library for @a plugin.
  601. Note this always returns a fully qualified URI. If you want a local
  602. filesystem path, use lilv_uri_to_path.
  603. @return a shared string which must not be modified or freed.
  604. */
  605. LILV_API
  606. const LilvNode*
  607. lilv_plugin_get_library_uri(const LilvPlugin* plugin);
  608. /**
  609. Get the name of @a plugin.
  610. This returns the name (doap:name) of the plugin. The name may be
  611. translated according to the current locale, this value MUST NOT be used
  612. as a plugin identifier (use the URI for that).
  613. Returned value must be freed by the caller.
  614. */
  615. LILV_API
  616. LilvNode*
  617. lilv_plugin_get_name(const LilvPlugin* plugin);
  618. /**
  619. Get the class this plugin belongs to (e.g. Filters).
  620. */
  621. LILV_API
  622. const LilvPluginClass*
  623. lilv_plugin_get_class(const LilvPlugin* plugin);
  624. /**
  625. Get a value associated with the plugin in a plugin's data files.
  626. @a predicate must be either a URI or a QName.
  627. Returns the ?object of all triples found of the form:
  628. <code>&lt;plugin-uri&gt; predicate ?object</code>
  629. May return NULL if the property was not found, or if object(s) is not
  630. sensibly represented as a LilvNodes (e.g. blank nodes).
  631. Return value must be freed by caller with lilv_nodes_free.
  632. */
  633. LILV_API
  634. LilvNodes*
  635. lilv_plugin_get_value(const LilvPlugin* p,
  636. const LilvNode* predicate);
  637. /**
  638. Return whether a feature is supported by a plugin.
  639. This will return true if the feature is an optional or required feature
  640. of the plugin.
  641. */
  642. LILV_API
  643. bool
  644. lilv_plugin_has_feature(const LilvPlugin* p,
  645. const LilvNode* feature_uri);
  646. /**
  647. Get the LV2 Features supported (required or optionally) by a plugin.
  648. A feature is "supported" by a plugin if it is required OR optional.
  649. Since required features have special rules the host must obey, this function
  650. probably shouldn't be used by normal hosts. Using lilv_plugin_get_optional_features
  651. and lilv_plugin_get_required_features separately is best in most cases.
  652. Returned value must be freed by caller with lilv_nodes_free.
  653. */
  654. LILV_API
  655. LilvNodes*
  656. lilv_plugin_get_supported_features(const LilvPlugin* p);
  657. /**
  658. Get the LV2 Features required by a plugin.
  659. If a feature is required by a plugin, hosts MUST NOT use the plugin if they do not
  660. understand (or are unable to support) that feature.
  661. All values returned here MUST be passed to the plugin's instantiate method
  662. (along with data, if necessary, as defined by the feature specification)
  663. or plugin instantiation will fail.
  664. Return value must be freed by caller with lilv_nodes_free.
  665. */
  666. LILV_API
  667. LilvNodes*
  668. lilv_plugin_get_required_features(const LilvPlugin* p);
  669. /**
  670. Get the LV2 Features optionally supported by a plugin.
  671. Hosts MAY ignore optional plugin features for whatever reasons. Plugins
  672. MUST operate (at least somewhat) if they are instantiated without being
  673. passed optional features.
  674. Return value must be freed by caller with lilv_nodes_free.
  675. */
  676. LILV_API
  677. LilvNodes*
  678. lilv_plugin_get_optional_features(const LilvPlugin* p);
  679. /**
  680. Return whether or not a plugin provides a specific extension data.
  681. */
  682. LILV_API
  683. bool
  684. lilv_plugin_has_extension_data(const LilvPlugin* p,
  685. const LilvNode* uri);
  686. /**
  687. Get a sequence of all extension data provided by a plugin.
  688. This can be used to find which URIs lilv_instance_get_extension_data()
  689. will return a value for without instantiating the plugin.
  690. */
  691. LILV_API
  692. LilvNodes*
  693. lilv_plugin_get_extension_data(const LilvPlugin* p);
  694. /**
  695. Get the number of ports on this plugin.
  696. */
  697. LILV_API
  698. uint32_t
  699. lilv_plugin_get_num_ports(const LilvPlugin* p);
  700. /**
  701. Get the port ranges (minimum, maximum and default values) for all ports.
  702. @a min_values, @a max_values and @a def_values must either point to an array
  703. of N floats, where N is the value returned by lilv_plugin_get_num_ports()
  704. for this plugin, or NULL. The elements of the array will be set to the
  705. the minimum, maximum and default values of the ports on this plugin,
  706. with array index corresponding to port index. If a port doesn't have a
  707. minimum, maximum or default value, or the port's type is not float, the
  708. corresponding array element will be set to NAN.
  709. This is a convenience method for the common case of getting the range of
  710. all float ports on a plugin, and may be significantly faster than
  711. repeated calls to lilv_port_get_range.
  712. */
  713. LILV_API
  714. void
  715. lilv_plugin_get_port_ranges_float(const LilvPlugin* p,
  716. float* min_values,
  717. float* max_values,
  718. float* def_values);
  719. /**
  720. Get the number of ports on this plugin that are members of some class(es).
  721. Note that this is a varargs function so ports fitting any type 'profile'
  722. desired can be found quickly. REMEMBER TO TERMINATE THE PARAMETER LIST
  723. OF THIS FUNCTION WITH NULL OR VERY NASTY THINGS WILL HAPPEN.
  724. */
  725. LILV_API
  726. uint32_t
  727. lilv_plugin_get_num_ports_of_class(const LilvPlugin* p,
  728. const LilvNode* class_1, ...);
  729. /**
  730. Return whether or not the plugin introduces (and reports) latency.
  731. The index of the latency port can be found with lilv_plugin_get_latency_port
  732. ONLY if this function returns true.
  733. */
  734. LILV_API
  735. bool
  736. lilv_plugin_has_latency(const LilvPlugin* p);
  737. /**
  738. Return the index of the plugin's latency port.
  739. It is a fatal error to call this on a plugin without checking if the port
  740. exists by first calling lilv_plugin_has_latency.
  741. Any plugin that introduces unwanted latency that should be compensated for
  742. (by hosts with the ability/need) MUST provide this port, which is a control
  743. rate output port that reports the latency for each cycle in frames.
  744. */
  745. LILV_API
  746. uint32_t
  747. lilv_plugin_get_latency_port_index(const LilvPlugin* p);
  748. /**
  749. Get a port on @a plugin by @a index.
  750. */
  751. LILV_API
  752. const LilvPort*
  753. lilv_plugin_get_port_by_index(const LilvPlugin* plugin,
  754. uint32_t index);
  755. /**
  756. Get a port on @a plugin by @a symbol.
  757. Note this function is slower than lilv_plugin_get_port_by_index,
  758. especially on plugins with a very large number of ports.
  759. */
  760. LILV_API
  761. const LilvPort*
  762. lilv_plugin_get_port_by_symbol(const LilvPlugin* plugin,
  763. const LilvNode* symbol);
  764. /**
  765. Get a port on @c plugin by its lv2:designation.
  766. The designation of a port describes the meaning, assignment, allocation or
  767. role of the port, e.g. "left channel" or "gain". If found, the port with
  768. matching @a port_class and @a designation is be returned, otherwise NULL is
  769. returned. The @a port_class can be used to distinguish the input and output
  770. ports for a particular designation.
  771. */
  772. LILV_API
  773. LilvPort*
  774. lilv_plugin_get_port_by_designation(const LilvPlugin* plugin,
  775. const LilvNode* port_class,
  776. const LilvNode* designation);
  777. /**
  778. Get the project the plugin is a part of.
  779. More information about the project can be read via lilv_world_find_nodes(),
  780. typically using properties from DOAP (e.g. doap:name).
  781. */
  782. LILV_API
  783. LilvNode*
  784. lilv_plugin_get_project(const LilvPlugin* plugin);
  785. /**
  786. Get the full name of the plugin's author.
  787. Returns NULL if author name is not present.
  788. Returned value must be freed by caller.
  789. */
  790. LILV_API
  791. LilvNode*
  792. lilv_plugin_get_author_name(const LilvPlugin* plugin);
  793. /**
  794. Get the email address of the plugin's author.
  795. Returns NULL if author email address is not present.
  796. Returned value must be freed by caller.
  797. */
  798. LILV_API
  799. LilvNode*
  800. lilv_plugin_get_author_email(const LilvPlugin* plugin);
  801. /**
  802. Get the address of the plugin author's home page.
  803. Returns NULL if author homepage is not present.
  804. Returned value must be freed by caller.
  805. */
  806. LILV_API
  807. LilvNode*
  808. lilv_plugin_get_author_homepage(const LilvPlugin* plugin);
  809. /**
  810. Return true iff @a plugin has been replaced by another plugin.
  811. The plugin will still be usable, but hosts should hide them from their
  812. user interfaces to prevent users from using deprecated plugins.
  813. */
  814. LILV_API
  815. bool
  816. lilv_plugin_is_replaced(const LilvPlugin* plugin);
  817. /**
  818. Write the Turtle description of @c plugin to @c plugin_file.
  819. This function is particularly useful for porting plugins in conjunction with
  820. an LV2 bridge such as NASPRO.
  821. */
  822. LILV_API
  823. void
  824. lilv_plugin_write_description(LilvWorld* world,
  825. const LilvPlugin* plugin,
  826. const LilvNode* base_uri,
  827. FILE* plugin_file);
  828. /**
  829. Write a manifest entry for @c plugin to @c manifest_file.
  830. This function is intended for use with lilv_plugin_write_description to
  831. write a complete description of a plugin to a bundle.
  832. */
  833. LILV_API
  834. void
  835. lilv_plugin_write_manifest_entry(LilvWorld* world,
  836. const LilvPlugin* plugin,
  837. const LilvNode* base_uri,
  838. FILE* manifest_file,
  839. const char* plugin_file_path);
  840. /**
  841. Get the resources related to @c plugin with lv2:appliesTo.
  842. Some plugin-related resources are not linked directly to the plugin with
  843. rdfs:seeAlso and thus will not be automatically loaded along with the plugin
  844. data (usually for performance reasons). All such resources of the given @c
  845. type related to @c plugin can be accessed with this function.
  846. If @c type is NULL, all such resources will be returned, regardless of type.
  847. To actually load the data for each returned resource, use
  848. lilv_world_load_resource.
  849. */
  850. LILV_API
  851. LilvNodes*
  852. lilv_plugin_get_related(const LilvPlugin* plugin, const LilvNode* type);
  853. /**
  854. @}
  855. @name Port
  856. @{
  857. */
  858. /**
  859. Port analog of lilv_plugin_get_value.
  860. */
  861. LILV_API
  862. LilvNodes*
  863. lilv_port_get_value(const LilvPlugin* plugin,
  864. const LilvPort* port,
  865. const LilvNode* predicate);
  866. /**
  867. Return the LV2 port properties of a port.
  868. */
  869. LILV_API
  870. LilvNodes*
  871. lilv_port_get_properties(const LilvPlugin* plugin,
  872. const LilvPort* port);
  873. /**
  874. Return whether a port has a certain property.
  875. */
  876. LILV_API
  877. bool
  878. lilv_port_has_property(const LilvPlugin* p,
  879. const LilvPort* port,
  880. const LilvNode* property_uri);
  881. /**
  882. Return whether a port is an event port and supports a certain event type.
  883. */
  884. LILV_API
  885. bool
  886. lilv_port_supports_event(const LilvPlugin* p,
  887. const LilvPort* port,
  888. const LilvNode* event_uri);
  889. /**
  890. Get the index of a port.
  891. The index is only valid for the life of the plugin and may change between
  892. versions. For a stable identifier, use the symbol.
  893. */
  894. LILV_API
  895. uint32_t
  896. lilv_port_get_index(const LilvPlugin* plugin,
  897. const LilvPort* port);
  898. /**
  899. Get the symbol of a port.
  900. The 'symbol' is a short string, a valid C identifier.
  901. Returned value is owned by @a port and must not be freed.
  902. */
  903. LILV_API
  904. const LilvNode*
  905. lilv_port_get_symbol(const LilvPlugin* plugin,
  906. const LilvPort* port);
  907. /**
  908. Get the name of a port.
  909. This is guaranteed to return the untranslated name (the doap:name in the
  910. data file without a language tag). Returned value must be freed by
  911. the caller.
  912. */
  913. LILV_API
  914. LilvNode*
  915. lilv_port_get_name(const LilvPlugin* plugin,
  916. const LilvPort* port);
  917. /**
  918. Get all the classes of a port.
  919. This can be used to determine if a port is an input, output, audio,
  920. control, midi, etc, etc, though it's simpler to use lilv_port_is_a.
  921. The returned list does not include lv2:Port, which is implied.
  922. Returned value is shared and must not be destroyed by caller.
  923. */
  924. LILV_API
  925. const LilvNodes*
  926. lilv_port_get_classes(const LilvPlugin* plugin,
  927. const LilvPort* port);
  928. /**
  929. Determine if a port is of a given class (input, output, audio, etc).
  930. For convenience/performance/extensibility reasons, hosts are expected to
  931. create a LilvNode for each port class they "care about". Well-known type
  932. URI strings are defined (e.g. LILV_URI_INPUT_PORT) for convenience, but
  933. this function is designed so that Lilv is usable with any port types
  934. without requiring explicit support in Lilv.
  935. */
  936. LILV_API
  937. bool
  938. lilv_port_is_a(const LilvPlugin* plugin,
  939. const LilvPort* port,
  940. const LilvNode* port_class);
  941. /**
  942. Get the default, minimum, and maximum values of a port.
  943. @a def, @a min, and @a max are outputs, pass pointers to uninitialized
  944. LilvNode* variables. These will be set to point at new values (which must
  945. be freed by the caller using lilv_node_free), or NULL if the value does not
  946. exist.
  947. */
  948. LILV_API
  949. void
  950. lilv_port_get_range(const LilvPlugin* plugin,
  951. const LilvPort* port,
  952. LilvNode** deflt,
  953. LilvNode** min,
  954. LilvNode** max);
  955. /**
  956. Get the scale points (enumeration values) of a port.
  957. This returns a collection of 'interesting' named values of a port
  958. (e.g. appropriate entries for a UI selector associated with this port).
  959. Returned value may be NULL if @a port has no scale points, otherwise it
  960. must be freed by caller with lilv_scale_points_free.
  961. */
  962. LILV_API
  963. LilvScalePoints*
  964. lilv_port_get_scale_points(const LilvPlugin* plugin,
  965. const LilvPort* port);
  966. /**
  967. @}
  968. @name Plugin State
  969. @{
  970. */
  971. /**
  972. Load a state snapshot from @c world's RDF model.
  973. @param subject The subject of the state description (e.g. a preset URI).
  974. @return A new LilvState which must be freed with lilv_state_free().
  975. */
  976. LILV_API
  977. LilvState*
  978. lilv_state_new_from_world(LilvWorld* world,
  979. LV2_URID_Map* map,
  980. const LilvNode* subject);
  981. /**
  982. Load a state snapshot from a file.
  983. @param subject The subject of the state description (e.g. a preset URI).
  984. @param path The path of the file containing the state description.
  985. @return A new LilvState which must be freed with lilv_state_free().
  986. If @c subject is NULL, it is taken to be the URI of the file (i.e.
  987. "<>" in Turtle).
  988. This function parses the file separately to create the state, it does not
  989. parse the file into the world model, i.e. the returned state is the only
  990. new memory consumed once this function returns.
  991. */
  992. LILV_API
  993. LilvState*
  994. lilv_state_new_from_file(LilvWorld* world,
  995. LV2_URID_Map* map,
  996. const LilvNode* subject,
  997. const char* path);
  998. /**
  999. Load a state snapshot from a string made by lilv_state_to_string().
  1000. */
  1001. LILV_API
  1002. LilvState*
  1003. lilv_state_new_from_string(LilvWorld* world,
  1004. LV2_URID_Map* map,
  1005. const char* str);
  1006. /**
  1007. Function to get a port value.
  1008. @param port_symbol The symbol of the port.
  1009. @param user_data The user_data passed to lilv_state_new_from_instance().
  1010. @param size (Output) The size of the returned value.
  1011. @param type (Output) The URID of the type of the returned value.
  1012. @return A pointer to the port value.
  1013. This function MUST set @p size and @p type appropriately.
  1014. */
  1015. typedef const void* (*LilvGetPortValueFunc)(const char* port_symbol,
  1016. void* user_data,
  1017. uint32_t* size,
  1018. uint32_t* type);
  1019. /**
  1020. Create a new state snapshot from a plugin instance.
  1021. @param plugin The plugin this state applies to.
  1022. @param instance An instance of @c plugin.
  1023. @param file_dir Directory of files created by the plugin earlier (or NULL).
  1024. This is for hosts that support file creation at any time with state
  1025. state:makePath. These files will be copied as necessary to @c copy_dir and
  1026. not be referred to directly in state (a temporary directory is appropriate).
  1027. @param copy_dir Directory of copies of files in @c file_dir (or NULL). This
  1028. directory will have the same structure as @c file_dir but with possibly
  1029. modified file names to distinguish different revisions. If you only care
  1030. about saving one state snapshot, it can be the same as @c save_dir. Plugin
  1031. state will refer to files in this directory.
  1032. @param save_dir Directory of files created by plugin during save (or NULL).
  1033. If the state will be saved, this should be the bundle directory later passed
  1034. to lilv_state_save.
  1035. @param link_dir Directory of links to external files (or NULL). A link will
  1036. be made in this directory to any external files referred to in plugin state.
  1037. In turn, links will be created in the save directory to these links (e.g.
  1038. save_dir/file => link_dir/file => /foo/bar/file). This allows many state
  1039. snapshots to share a single link to an external file, so archival
  1040. (e.g. with tar -h) will not create several copies of the file. If this is
  1041. not required, it can be the same as save_dir.
  1042. @param flags Bitwise OR of LV2_State_Flags values.
  1043. @param features Features to pass LV2_State_Interface.save().
  1044. @return A new LilvState which must be freed with lilv_state_free().
  1045. This function may be called simultaneously with any instance function
  1046. (except discovery functions) unless the threading class of that function
  1047. explicitly disallows this.
  1048. To support advanced file functionality, there are several directory
  1049. parameters. Simple hosts that only wish to save a single plugins state once
  1050. may simply use the same directory for all of them (or pass NULL to not
  1051. support files at all). The multiple parameters are necessary to support
  1052. saving an instances state many times while avoiding any duplication of data.
  1053. If supported (via state:makePath passed to LV2_Descriptor::instantiate()),
  1054. @c file_dir should be the directory where any files created by the plugin
  1055. (not during save time, e.g. during instantiation) are stored. These files
  1056. will be copied to preserve their state at this time.plugin-created files are stored.
  1057. Lilv will assume any files within this directory (recursively) are created
  1058. by the plugin and all other files are immutable. Note that this function
  1059. does not save the state, use lilv_state_save() for that.
  1060. See <a href="http://lv2plug.in/ns/ext/state/state.h">state.h</a> from the
  1061. LV2 State extension for details on the @c flags and @c features parameters.
  1062. */
  1063. LILV_API
  1064. LilvState*
  1065. lilv_state_new_from_instance(const LilvPlugin* plugin,
  1066. LilvInstance* instance,
  1067. LV2_URID_Map* map,
  1068. const char* file_dir,
  1069. const char* copy_dir,
  1070. const char* link_dir,
  1071. const char* save_dir,
  1072. LilvGetPortValueFunc get_value,
  1073. void* user_data,
  1074. uint32_t flags,
  1075. const LV2_Feature *const * features);
  1076. /**
  1077. Free @c state.
  1078. */
  1079. LILV_API
  1080. void
  1081. lilv_state_free(LilvState* state);
  1082. /**
  1083. Return true iff @c a is equivalent to @c b.
  1084. */
  1085. LILV_API
  1086. bool
  1087. lilv_state_equals(const LilvState* a, const LilvState* b);
  1088. /**
  1089. Return the number of properties in @c state.
  1090. */
  1091. LILV_API
  1092. unsigned
  1093. lilv_state_get_num_properties(const LilvState* state);
  1094. /**
  1095. Get the URI of the plugin @c state applies to.
  1096. */
  1097. LILV_API
  1098. const LilvNode*
  1099. lilv_state_get_plugin_uri(const LilvState* state);
  1100. /**
  1101. Get the label of @c state.
  1102. */
  1103. LILV_API
  1104. const char*
  1105. lilv_state_get_label(const LilvState* state);
  1106. /**
  1107. Set the label of @c state.
  1108. */
  1109. LILV_API
  1110. void
  1111. lilv_state_set_label(LilvState* state,
  1112. const char* label);
  1113. /**
  1114. Function to set a port value.
  1115. @param port_symbol The symbol of the port.
  1116. @param user_data The user_data passed to lilv_state_restore().
  1117. @param size The size of @p value.
  1118. @param type The URID of the type of @p value.
  1119. @param value A pointer to the port value.
  1120. */
  1121. typedef void (*LilvSetPortValueFunc)(const char* port_symbol,
  1122. void* user_data,
  1123. const void* value,
  1124. uint32_t size,
  1125. uint32_t type);
  1126. /**
  1127. Restore a plugin instance from a state snapshot.
  1128. @param state The state to restore, which must apply to the correct plugin.
  1129. @param instance An instance of the plugin @c state applies to.
  1130. @param set_value A function to set a port value (may be NULL).
  1131. @param flags Bitwise OR of LV2_State_Flags values.
  1132. @param features Features to pass LV2_State_Interface.restore().
  1133. This will set all the properties of @c instance to the values stored in @c
  1134. state. If @c set_value is provided, it will be called (with the given @c
  1135. user_data) to restore each port value, otherwise the host must restore the
  1136. port values itself (using lilv_state_get_port_value) in order to completely
  1137. restore @c state.
  1138. If the state has properties, this function is in the "instantiation"
  1139. threading class, i.e. it MUST NOT be called simultaneously with any function
  1140. on the same plugin instance. If the state has no properties, only port
  1141. values are set via @c set_value.
  1142. See <a href="http://lv2plug.in/ns/ext/state/state.h">state.h</a> from the
  1143. LV2 State extension for details on the @c flags and @c features parameters.
  1144. */
  1145. LILV_API
  1146. void
  1147. lilv_state_restore(const LilvState* state,
  1148. LilvInstance* instance,
  1149. LilvSetPortValueFunc set_value,
  1150. void* user_data,
  1151. uint32_t flags,
  1152. const LV2_Feature *const * features);
  1153. /**
  1154. Save state to a file.
  1155. @param unmap URID unmapper.
  1156. @param state State to save.
  1157. @param uri URI of state, may be NULL.
  1158. @param dir Path of the bundle directory to save into.
  1159. @param filename Path of the state file relative to @c dir.
  1160. The format of state on disk is compatible with that defined in the LV2
  1161. preset extension, i.e. this function may be used to save presets which can
  1162. be loaded by any host.
  1163. If @c uri is NULL, the preset URI will be a file URI, but the bundle
  1164. can safely be moved (i.e. the state file will use "<>" as the subject).
  1165. */
  1166. LILV_API
  1167. int
  1168. lilv_state_save(LilvWorld* world,
  1169. LV2_URID_Map* map,
  1170. LV2_URID_Unmap* unmap,
  1171. const LilvState* state,
  1172. const char* uri,
  1173. const char* dir,
  1174. const char* filename);
  1175. /**
  1176. Save state to a string. This function does not use the filesystem.
  1177. */
  1178. LILV_API
  1179. char*
  1180. lilv_state_to_string(LilvWorld* world,
  1181. LV2_URID_Map* map,
  1182. LV2_URID_Unmap* unmap,
  1183. const LilvState* state,
  1184. const char* uri,
  1185. const char* base_uri);
  1186. /**
  1187. @}
  1188. @name Scale Point
  1189. @{
  1190. */
  1191. /**
  1192. Get the label of this scale point (enumeration value)
  1193. Returned value is owned by @a point and must not be freed.
  1194. */
  1195. LILV_API
  1196. const LilvNode*
  1197. lilv_scale_point_get_label(const LilvScalePoint* point);
  1198. /**
  1199. Get the value of this scale point (enumeration value)
  1200. Returned value is owned by @a point and must not be freed.
  1201. */
  1202. LILV_API
  1203. const LilvNode*
  1204. lilv_scale_point_get_value(const LilvScalePoint* point);
  1205. /**
  1206. @}
  1207. @name Plugin Class
  1208. @{
  1209. */
  1210. /**
  1211. Get the URI of this class' superclass.
  1212. Returned value is owned by @a plugin_class and must not be freed by caller.
  1213. Returned value may be NULL, if class has no parent.
  1214. */
  1215. LILV_API
  1216. const LilvNode*
  1217. lilv_plugin_class_get_parent_uri(const LilvPluginClass* plugin_class);
  1218. /**
  1219. Get the URI of this plugin class.
  1220. Returned value is owned by @a plugin_class and must not be freed by caller.
  1221. */
  1222. LILV_API
  1223. const LilvNode*
  1224. lilv_plugin_class_get_uri(const LilvPluginClass* plugin_class);
  1225. /**
  1226. Get the label of this plugin class, ie "Oscillators".
  1227. Returned value is owned by @a plugin_class and must not be freed by caller.
  1228. */
  1229. LILV_API
  1230. const LilvNode*
  1231. lilv_plugin_class_get_label(const LilvPluginClass* plugin_class);
  1232. /**
  1233. Get the subclasses of this plugin class.
  1234. Returned value must be freed by caller with lilv_plugin_classes_free.
  1235. */
  1236. LILV_API
  1237. LilvPluginClasses*
  1238. lilv_plugin_class_get_children(const LilvPluginClass* plugin_class);
  1239. /**
  1240. @}
  1241. @name Plugin Instance
  1242. @{
  1243. */
  1244. /**
  1245. @cond 0
  1246. */
  1247. /* Instance of a plugin.
  1248. This is exposed in the ABI to allow inlining of performance critical
  1249. functions like lilv_instance_run (simple wrappers of functions in lv2.h).
  1250. This is for performance reasons, user code should not use this definition
  1251. in any way (which is why it is not machine documented).
  1252. Truly private implementation details are hidden via @a ref pimpl.
  1253. */
  1254. struct LilvInstanceImpl {
  1255. const LV2_Descriptor* lv2_descriptor;
  1256. LV2_Handle lv2_handle;
  1257. void* pimpl;
  1258. };
  1259. /**
  1260. @endcond
  1261. */
  1262. /**
  1263. Instantiate a plugin.
  1264. The returned value is a lightweight handle for an LV2 plugin instance,
  1265. it does not refer to @a plugin, or any other Lilv state. The caller must
  1266. eventually free it with lilv_instance_free.
  1267. @a features is a NULL-terminated array of features the host supports.
  1268. NULL may be passed if the host supports no additional features.
  1269. @return NULL if instantiation failed.
  1270. */
  1271. LILV_API
  1272. LilvInstance*
  1273. lilv_plugin_instantiate(const LilvPlugin* plugin,
  1274. double sample_rate,
  1275. const LV2_Feature*const* features);
  1276. /**
  1277. Free a plugin instance.
  1278. It is safe to call this function on NULL.
  1279. @a instance is invalid after this call.
  1280. */
  1281. LILV_API
  1282. void
  1283. lilv_instance_free(LilvInstance* instance);
  1284. #ifndef LILV_INTERNAL
  1285. /**
  1286. Get the URI of the plugin which @a instance is an instance of.
  1287. Returned string is shared and must not be modified or deleted.
  1288. */
  1289. static inline const char*
  1290. lilv_instance_get_uri(const LilvInstance* instance)
  1291. {
  1292. return instance->lv2_descriptor->URI;
  1293. }
  1294. /**
  1295. Connect a port to a data location.
  1296. This may be called regardless of whether the plugin is activated,
  1297. activation and deactivation does not destroy port connections.
  1298. */
  1299. static inline void
  1300. lilv_instance_connect_port(LilvInstance* instance,
  1301. uint32_t port_index,
  1302. void* data_location)
  1303. {
  1304. instance->lv2_descriptor->connect_port
  1305. (instance->lv2_handle, port_index, data_location);
  1306. }
  1307. /**
  1308. Activate a plugin instance.
  1309. This resets all state information in the plugin, except for port data
  1310. locations (as set by lilv_instance_connect_port). This MUST be called
  1311. before calling lilv_instance_run.
  1312. */
  1313. static inline void
  1314. lilv_instance_activate(LilvInstance* instance)
  1315. {
  1316. if (instance->lv2_descriptor->activate)
  1317. instance->lv2_descriptor->activate(instance->lv2_handle);
  1318. }
  1319. /**
  1320. Run @a instance for @a sample_count frames.
  1321. If the hint lv2:hardRTCapable is set for this plugin, this function is
  1322. guaranteed not to block.
  1323. */
  1324. static inline void
  1325. lilv_instance_run(LilvInstance* instance,
  1326. uint32_t sample_count)
  1327. {
  1328. instance->lv2_descriptor->run(instance->lv2_handle, sample_count);
  1329. }
  1330. /**
  1331. Deactivate a plugin instance.
  1332. Note that to run the plugin after this you must activate it, which will
  1333. reset all state information (except port connections).
  1334. */
  1335. static inline void
  1336. lilv_instance_deactivate(LilvInstance* instance)
  1337. {
  1338. if (instance->lv2_descriptor->deactivate)
  1339. instance->lv2_descriptor->deactivate(instance->lv2_handle);
  1340. }
  1341. /**
  1342. Get extension data from the plugin instance.
  1343. The type and semantics of the data returned is specific to the particular
  1344. extension, though in all cases it is shared and must not be deleted.
  1345. */
  1346. static inline const void*
  1347. lilv_instance_get_extension_data(const LilvInstance* instance,
  1348. const char* uri)
  1349. {
  1350. if (instance->lv2_descriptor->extension_data)
  1351. return instance->lv2_descriptor->extension_data(uri);
  1352. else
  1353. return NULL;
  1354. }
  1355. /**
  1356. Get the LV2_Descriptor of the plugin instance.
  1357. Normally hosts should not need to access the LV2_Descriptor directly,
  1358. use the lilv_instance_* functions.
  1359. The returned descriptor is shared and must not be deleted.
  1360. */
  1361. static inline const LV2_Descriptor*
  1362. lilv_instance_get_descriptor(const LilvInstance* instance)
  1363. {
  1364. return instance->lv2_descriptor;
  1365. }
  1366. /**
  1367. Get the LV2_Handle of the plugin instance.
  1368. Normally hosts should not need to access the LV2_Handle directly,
  1369. use the lilv_instance_* functions.
  1370. The returned handle is shared and must not be deleted.
  1371. */
  1372. static inline LV2_Handle
  1373. lilv_instance_get_handle(const LilvInstance* instance)
  1374. {
  1375. return instance->lv2_handle;
  1376. }
  1377. #endif /* LILV_INTERNAL */
  1378. /**
  1379. @}
  1380. @name Plugin UI
  1381. @{
  1382. */
  1383. /**
  1384. Get all UIs for @a plugin.
  1385. Returned value must be freed by caller using lilv_uis_free.
  1386. */
  1387. LILV_API
  1388. LilvUIs*
  1389. lilv_plugin_get_uis(const LilvPlugin* plugin);
  1390. /**
  1391. Get the URI of a Plugin UI.
  1392. @param ui The Plugin UI
  1393. @return a shared value which must not be modified or freed.
  1394. */
  1395. LILV_API
  1396. const LilvNode*
  1397. lilv_ui_get_uri(const LilvUI* ui);
  1398. /**
  1399. Get the types (URIs of RDF classes) of a Plugin UI.
  1400. @param ui The Plugin UI
  1401. @return a shared value which must not be modified or freed.
  1402. Note that in most cases lilv_ui_is_supported should be used which finds the
  1403. UI type, avoding the need to use this function (and type specific logic).
  1404. */
  1405. LILV_API
  1406. const LilvNodes*
  1407. lilv_ui_get_classes(const LilvUI* ui);
  1408. /**
  1409. Check whether a plugin UI has a given type.
  1410. @param ui The Plugin UI
  1411. @param class_uri The URI of the LV2 UI type to check this UI against
  1412. */
  1413. LILV_API
  1414. bool
  1415. lilv_ui_is_a(const LilvUI* ui, const LilvNode* class_uri);
  1416. /**
  1417. Function to determine whether a UI type is supported.
  1418. This is provided by the user and must return non-zero iff using a UI of type
  1419. @c ui_type_uri in a container of type @c container_type_uri is supported.
  1420. */
  1421. typedef unsigned (*LilvUISupportedFunc)(const char* container_type_uri,
  1422. const char* ui_type_uri);
  1423. /**
  1424. Return true iff a Plugin UI is supported as a given widget type.
  1425. @param ui The Plugin UI
  1426. @param supported_func User provided supported predicate.
  1427. @param container_type The widget type to host the UI within.
  1428. @param ui_type (Output) If non-NULL, set to the native type of the UI
  1429. which is owned by @c ui and must not be freed by the caller.
  1430. @return The embedding quality level returned by @c supported_func.
  1431. */
  1432. LILV_API
  1433. unsigned
  1434. lilv_ui_is_supported(const LilvUI* ui,
  1435. LilvUISupportedFunc supported_func,
  1436. const LilvNode* container_type,
  1437. const LilvNode** ui_type);
  1438. /**
  1439. Get the URI for a Plugin UI's bundle.
  1440. @param ui The Plugin UI
  1441. @return a shared value which must not be modified or freed.
  1442. */
  1443. LILV_API
  1444. const LilvNode*
  1445. lilv_ui_get_bundle_uri(const LilvUI* ui);
  1446. /**
  1447. Get the URI for a Plugin UI's shared library.
  1448. @param ui The Plugin UI
  1449. @return a shared value which must not be modified or freed.
  1450. */
  1451. LILV_API
  1452. const LilvNode*
  1453. lilv_ui_get_binary_uri(const LilvUI* ui);
  1454. /**
  1455. Custom calls
  1456. */
  1457. LILV_API
  1458. LilvNodes*
  1459. lilv_ui_get_supported_features(const LilvUI* ui);
  1460. LILV_API
  1461. LilvNodes*
  1462. lilv_ui_get_required_features(const LilvUI* ui);
  1463. LILV_API
  1464. LilvNodes*
  1465. lilv_ui_get_optional_features(const LilvUI* ui);
  1466. LILV_API
  1467. LilvNodes*
  1468. lilv_ui_get_extension_data(const LilvUI* ui);
  1469. /**
  1470. @}
  1471. @}
  1472. */
  1473. #ifdef __cplusplus
  1474. } /* extern "C" */
  1475. #endif
  1476. #endif /* LILV_LILV_H */