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.

1511 lines
63KB

  1. /*
  2. * Carla LV2 utils
  3. * Copyright (C) 2011-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_LV2_UTILS_HPP_INCLUDED
  18. #define CARLA_LV2_UTILS_HPP_INCLUDED
  19. #include "CarlaUtils.hpp"
  20. #ifndef nullptr
  21. # undef NULL
  22. # define NULL nullptr
  23. #endif
  24. // disable -Wdocumentation for LV2 headers
  25. #if defined(__clang__)
  26. # pragma clang diagnostic push
  27. # pragma clang diagnostic ignored "-Wdocumentation"
  28. #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
  29. # pragma GCC diagnostic push
  30. # pragma GCC diagnostic ignored "-Wdocumentation"
  31. #endif
  32. #include "lv2/lv2.h"
  33. #include "lv2/atom.h"
  34. #include "lv2/atom-forge.h"
  35. #include "lv2/atom-helpers.h"
  36. #include "lv2/atom-util.h"
  37. #include "lv2/buf-size.h"
  38. #include "lv2/data-access.h"
  39. // dynmanifest
  40. #include "lv2/event.h"
  41. #include "lv2/event-helpers.h"
  42. #include "lv2/instance-access.h"
  43. #include "lv2/log.h"
  44. // logger
  45. #include "lv2/midi.h"
  46. // morph
  47. #include "lv2/options.h"
  48. #include "lv2/parameters.h"
  49. #include "lv2/patch.h"
  50. #include "lv2/port-groups.h"
  51. #include "lv2/port-props.h"
  52. #include "lv2/presets.h"
  53. #include "lv2/resize-port.h"
  54. #include "lv2/state.h"
  55. #include "lv2/time.h"
  56. #include "lv2/ui.h"
  57. #include "lv2/units.h"
  58. #include "lv2/uri-map.h"
  59. #include "lv2/urid.h"
  60. #include "lv2/worker.h"
  61. #include "lv2/lv2-miditype.h"
  62. #include "lv2/lv2-midifunctions.h"
  63. #include "lv2/lv2_external_ui.h"
  64. #include "lv2/lv2_programs.h"
  65. #include "lv2/lv2_rtmempool.h"
  66. #include "lilv/lilvmm.hpp"
  67. #include "sratom/sratom.h"
  68. // enable -Wdocumentation again
  69. #if defined(__clang__)
  70. # pragma clang diagnostic pop
  71. #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
  72. # pragma GCC diagnostic pop
  73. #endif
  74. #include "lv2_rdf.hpp"
  75. #ifdef USE_QT
  76. # include <QtCore/QStringList>
  77. #else
  78. # include "juce_core.h"
  79. #endif
  80. // -----------------------------------------------------------------------
  81. // Define namespaces and missing prefixes
  82. #define NS_dct "http://purl.org/dc/terms/"
  83. #define NS_doap "http://usefulinc.com/ns/doap#"
  84. #define NS_rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  85. #define NS_rdfs "http://www.w3.org/2000/01/rdf-schema#"
  86. #define NS_llmm "http://ll-plugins.nongnu.org/lv2/ext/midimap#"
  87. #define LV2_MIDI_Map__CC "http://ll-plugins.nongnu.org/lv2/namespace#CC"
  88. #define LV2_MIDI_Map__NRPN "http://ll-plugins.nongnu.org/lv2/namespace#NRPN"
  89. #define LV2_MIDI_LL__MidiPort "http://ll-plugins.nongnu.org/lv2/ext/MidiPort"
  90. #define LV2_UI__Qt5UI LV2_UI_PREFIX "Qt5UI"
  91. #define LV2_UI__makeResident LV2_UI_PREFIX "makeResident"
  92. // -----------------------------------------------------------------------
  93. // Custom Atom types
  94. struct LV2_Atom_MidiEvent {
  95. LV2_Atom_Event event;
  96. uint8_t data[4];
  97. };
  98. // -----------------------------------------------------------------------
  99. // Our LV2 World class
  100. class Lv2WorldClass : public Lilv::World
  101. {
  102. public:
  103. // Base Types
  104. Lilv::Node port;
  105. Lilv::Node symbol;
  106. Lilv::Node designation;
  107. Lilv::Node freeWheeling;
  108. Lilv::Node reportsLatency;
  109. // Plugin Types
  110. Lilv::Node class_allpass;
  111. Lilv::Node class_amplifier;
  112. Lilv::Node class_analyzer;
  113. Lilv::Node class_bandpass;
  114. Lilv::Node class_chorus;
  115. Lilv::Node class_comb;
  116. Lilv::Node class_compressor;
  117. Lilv::Node class_constant;
  118. Lilv::Node class_converter;
  119. Lilv::Node class_delay;
  120. Lilv::Node class_distortion;
  121. Lilv::Node class_dynamics;
  122. Lilv::Node class_eq;
  123. Lilv::Node class_envelope;
  124. Lilv::Node class_expander;
  125. Lilv::Node class_filter;
  126. Lilv::Node class_flanger;
  127. Lilv::Node class_function;
  128. Lilv::Node class_gate;
  129. Lilv::Node class_generator;
  130. Lilv::Node class_highpass;
  131. Lilv::Node class_instrument;
  132. Lilv::Node class_limiter;
  133. Lilv::Node class_lowpass;
  134. Lilv::Node class_mixer;
  135. Lilv::Node class_modulator;
  136. Lilv::Node class_multiEQ;
  137. Lilv::Node class_oscillator;
  138. Lilv::Node class_paraEQ;
  139. Lilv::Node class_phaser;
  140. Lilv::Node class_pitch;
  141. Lilv::Node class_reverb;
  142. Lilv::Node class_simulator;
  143. Lilv::Node class_spatial;
  144. Lilv::Node class_spectral;
  145. Lilv::Node class_utility;
  146. Lilv::Node class_waveshaper;
  147. // Port Types
  148. Lilv::Node port_input;
  149. Lilv::Node port_output;
  150. Lilv::Node port_control;
  151. Lilv::Node port_audio;
  152. Lilv::Node port_cv;
  153. Lilv::Node port_atom;
  154. Lilv::Node port_event;
  155. Lilv::Node port_midi;
  156. // Port Properties
  157. Lilv::Node pprop_optional;
  158. Lilv::Node pprop_enumeration;
  159. Lilv::Node pprop_integer;
  160. Lilv::Node pprop_sampleRate;
  161. Lilv::Node pprop_toggled;
  162. Lilv::Node pprop_artifacts;
  163. Lilv::Node pprop_continuousCV;
  164. Lilv::Node pprop_discreteCV;
  165. Lilv::Node pprop_expensive;
  166. Lilv::Node pprop_strictBounds;
  167. Lilv::Node pprop_logarithmic;
  168. Lilv::Node pprop_notAutomatic;
  169. Lilv::Node pprop_notOnGUI;
  170. Lilv::Node pprop_trigger;
  171. // Unit Hints
  172. Lilv::Node unit_name;
  173. Lilv::Node unit_render;
  174. Lilv::Node unit_symbol;
  175. Lilv::Node unit_unit;
  176. // UI Types
  177. Lilv::Node ui_gtk2;
  178. Lilv::Node ui_gtk3;
  179. Lilv::Node ui_qt4;
  180. Lilv::Node ui_qt5;
  181. Lilv::Node ui_cocoa;
  182. Lilv::Node ui_windows;
  183. Lilv::Node ui_x11;
  184. Lilv::Node ui_external;
  185. Lilv::Node ui_externalOld;
  186. Lilv::Node ui_externalOld2;
  187. // Misc
  188. Lilv::Node atom_bufferType;
  189. Lilv::Node atom_sequence;
  190. Lilv::Node atom_supports;
  191. Lilv::Node preset_preset;
  192. Lilv::Node state_state;
  193. Lilv::Node value_default;
  194. Lilv::Node value_minimum;
  195. Lilv::Node value_maximum;
  196. Lilv::Node rz_asLargeAs;
  197. Lilv::Node rz_minSize;
  198. // Port Data Types
  199. Lilv::Node midi_event;
  200. Lilv::Node patch_message;
  201. Lilv::Node time_position;
  202. // MIDI CC
  203. Lilv::Node mm_defaultControl;
  204. Lilv::Node mm_controlType;
  205. Lilv::Node mm_controlNumber;
  206. // Other
  207. Lilv::Node dct_replaces;
  208. Lilv::Node doap_license;
  209. Lilv::Node rdf_type;
  210. Lilv::Node rdfs_label;
  211. bool needsInit;
  212. // -------------------------------------------------------------------
  213. Lv2WorldClass()
  214. : Lilv::World(),
  215. port (new_uri(LV2_CORE__port)),
  216. symbol (new_uri(LV2_CORE__symbol)),
  217. designation (new_uri(LV2_CORE__designation)),
  218. freeWheeling (new_uri(LV2_CORE__freeWheeling)),
  219. reportsLatency (new_uri(LV2_CORE__reportsLatency)),
  220. class_allpass (new_uri(LV2_CORE__AllpassPlugin)),
  221. class_amplifier (new_uri(LV2_CORE__AmplifierPlugin)),
  222. class_analyzer (new_uri(LV2_CORE__AnalyserPlugin)),
  223. class_bandpass (new_uri(LV2_CORE__BandpassPlugin)),
  224. class_chorus (new_uri(LV2_CORE__ChorusPlugin)),
  225. class_comb (new_uri(LV2_CORE__CombPlugin)),
  226. class_compressor (new_uri(LV2_CORE__CompressorPlugin)),
  227. class_constant (new_uri(LV2_CORE__ConstantPlugin)),
  228. class_converter (new_uri(LV2_CORE__ConverterPlugin)),
  229. class_delay (new_uri(LV2_CORE__DelayPlugin)),
  230. class_distortion (new_uri(LV2_CORE__DistortionPlugin)),
  231. class_dynamics (new_uri(LV2_CORE__DynamicsPlugin)),
  232. class_eq (new_uri(LV2_CORE__EQPlugin)),
  233. class_envelope (new_uri(LV2_CORE__EnvelopePlugin)),
  234. class_expander (new_uri(LV2_CORE__ExpanderPlugin)),
  235. class_filter (new_uri(LV2_CORE__FilterPlugin)),
  236. class_flanger (new_uri(LV2_CORE__FlangerPlugin)),
  237. class_function (new_uri(LV2_CORE__FunctionPlugin)),
  238. class_gate (new_uri(LV2_CORE__GatePlugin)),
  239. class_generator (new_uri(LV2_CORE__GeneratorPlugin)),
  240. class_highpass (new_uri(LV2_CORE__HighpassPlugin)),
  241. class_instrument (new_uri(LV2_CORE__InstrumentPlugin)),
  242. class_limiter (new_uri(LV2_CORE__LimiterPlugin)),
  243. class_lowpass (new_uri(LV2_CORE__LowpassPlugin)),
  244. class_mixer (new_uri(LV2_CORE__MixerPlugin)),
  245. class_modulator (new_uri(LV2_CORE__ModulatorPlugin)),
  246. class_multiEQ (new_uri(LV2_CORE__MultiEQPlugin)),
  247. class_oscillator (new_uri(LV2_CORE__OscillatorPlugin)),
  248. class_paraEQ (new_uri(LV2_CORE__ParaEQPlugin)),
  249. class_phaser (new_uri(LV2_CORE__PhaserPlugin)),
  250. class_pitch (new_uri(LV2_CORE__PitchPlugin)),
  251. class_reverb (new_uri(LV2_CORE__ReverbPlugin)),
  252. class_simulator (new_uri(LV2_CORE__SimulatorPlugin)),
  253. class_spatial (new_uri(LV2_CORE__SpatialPlugin)),
  254. class_spectral (new_uri(LV2_CORE__SpectralPlugin)),
  255. class_utility (new_uri(LV2_CORE__UtilityPlugin)),
  256. class_waveshaper (new_uri(LV2_CORE__WaveshaperPlugin)),
  257. port_input (new_uri(LV2_CORE__InputPort)),
  258. port_output (new_uri(LV2_CORE__OutputPort)),
  259. port_control (new_uri(LV2_CORE__ControlPort)),
  260. port_audio (new_uri(LV2_CORE__AudioPort)),
  261. port_cv (new_uri(LV2_CORE__CVPort)),
  262. port_atom (new_uri(LV2_ATOM__AtomPort)),
  263. port_event (new_uri(LV2_EVENT__EventPort)),
  264. port_midi (new_uri(LV2_MIDI_LL__MidiPort)),
  265. pprop_optional (new_uri(LV2_CORE__connectionOptional)),
  266. pprop_enumeration (new_uri(LV2_CORE__enumeration)),
  267. pprop_integer (new_uri(LV2_CORE__integer)),
  268. pprop_sampleRate (new_uri(LV2_CORE__sampleRate)),
  269. pprop_toggled (new_uri(LV2_CORE__toggled)),
  270. pprop_artifacts (new_uri(LV2_PORT_PROPS__causesArtifacts)),
  271. pprop_continuousCV (new_uri(LV2_PORT_PROPS__continuousCV)),
  272. pprop_discreteCV (new_uri(LV2_PORT_PROPS__discreteCV)),
  273. pprop_expensive (new_uri(LV2_PORT_PROPS__expensive)),
  274. pprop_strictBounds (new_uri(LV2_PORT_PROPS__hasStrictBounds)),
  275. pprop_logarithmic (new_uri(LV2_PORT_PROPS__logarithmic)),
  276. pprop_notAutomatic (new_uri(LV2_PORT_PROPS__notAutomatic)),
  277. pprop_notOnGUI (new_uri(LV2_PORT_PROPS__notOnGUI)),
  278. pprop_trigger (new_uri(LV2_PORT_PROPS__trigger)),
  279. unit_name (new_uri(LV2_UNITS__name)),
  280. unit_render (new_uri(LV2_UNITS__render)),
  281. unit_symbol (new_uri(LV2_UNITS__symbol)),
  282. unit_unit (new_uri(LV2_UNITS__unit)),
  283. ui_gtk2 (new_uri(LV2_UI__GtkUI)),
  284. ui_gtk3 (new_uri(LV2_UI__Gtk3UI)),
  285. ui_qt4 (new_uri(LV2_UI__Qt4UI)),
  286. ui_qt5 (new_uri(LV2_UI__Qt5UI)),
  287. ui_cocoa (new_uri(LV2_UI__CocoaUI)),
  288. ui_windows (new_uri(LV2_UI__WindowsUI)),
  289. ui_x11 (new_uri(LV2_UI__X11UI)),
  290. ui_external (new_uri(LV2_EXTERNAL_UI__Widget)),
  291. ui_externalOld (new_uri(LV2_EXTERNAL_UI_DEPRECATED_URI)),
  292. ui_externalOld2 (new_uri("http://nedko.arnaudov.name/lv2/external_ui/")),
  293. atom_bufferType (new_uri(LV2_ATOM__bufferType)),
  294. atom_sequence (new_uri(LV2_ATOM__Sequence)),
  295. atom_supports (new_uri(LV2_ATOM__supports)),
  296. preset_preset (new_uri(LV2_PRESETS__Preset)),
  297. state_state (new_uri(LV2_STATE__state)),
  298. value_default (new_uri(LV2_CORE__default)),
  299. value_minimum (new_uri(LV2_CORE__minimum)),
  300. value_maximum (new_uri(LV2_CORE__maximum)),
  301. rz_asLargeAs (new_uri(LV2_RESIZE_PORT__asLargeAs)),
  302. rz_minSize (new_uri(LV2_RESIZE_PORT__minimumSize)),
  303. midi_event (new_uri(LV2_MIDI__MidiEvent)),
  304. patch_message (new_uri(LV2_PATCH__Message)),
  305. time_position (new_uri(LV2_TIME__Position)),
  306. mm_defaultControl (new_uri(NS_llmm "defaultMidiController")),
  307. mm_controlType (new_uri(NS_llmm "controllerType")),
  308. mm_controlNumber (new_uri(NS_llmm "controllerNumber")),
  309. dct_replaces (new_uri(NS_dct "replaces")),
  310. doap_license (new_uri(NS_doap "license")),
  311. rdf_type (new_uri(NS_rdf "type")),
  312. rdfs_label (new_uri(NS_rdfs "label")),
  313. needsInit(true)
  314. {
  315. }
  316. static Lv2WorldClass& getInstance()
  317. {
  318. static Lv2WorldClass lv2World;
  319. return lv2World;
  320. }
  321. void initIfNeeded()
  322. {
  323. if (! needsInit)
  324. return;
  325. needsInit = false;
  326. Lilv::World::load_all();
  327. }
  328. void load_bundle(const char* const bundle)
  329. {
  330. CARLA_SAFE_ASSERT_RETURN(bundle != nullptr && bundle[0] != '\0',);
  331. needsInit = false;
  332. Lilv::World::load_bundle(Lilv::Node(new_uri(bundle)));
  333. }
  334. const LilvPlugin* getPlugin(const LV2_URI uri) const
  335. {
  336. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);
  337. CARLA_SAFE_ASSERT_RETURN(! needsInit, nullptr);
  338. const LilvPlugins* const cPlugins(lilv_world_get_all_plugins(this->me));
  339. if (cPlugins == nullptr)
  340. {
  341. carla_stderr("Lv2WorldClass::getPlugin(\"%s\") - Failed to get plugins from world", uri);
  342. return nullptr;
  343. }
  344. LilvNode* const uriNode(Lilv::World::new_uri(uri));
  345. if (uriNode == nullptr)
  346. {
  347. carla_stderr("Lv2WorldClass::getPlugin(\"%s\") - Failed to get node from uri", uri);
  348. return nullptr;
  349. }
  350. const LilvPlugin* const cPlugin(lilv_plugins_get_by_uri(cPlugins, uriNode));
  351. lilv_node_free(uriNode);
  352. if (cPlugin == nullptr)
  353. {
  354. carla_stderr("Lv2WorldClass::getPlugin(\"%s\") - Failed to get plugin", uri);
  355. return nullptr;
  356. }
  357. return cPlugin;
  358. }
  359. LilvState* getState(const LV2_URI uri, const LV2_URID_Map* const uridMap) const
  360. {
  361. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);
  362. CARLA_SAFE_ASSERT_RETURN(uridMap != nullptr, nullptr);
  363. CARLA_SAFE_ASSERT_RETURN(! needsInit, nullptr);
  364. LilvNode* const uriNode(Lilv::World::new_uri(uri));
  365. if (uriNode == nullptr)
  366. {
  367. carla_stderr("Lv2WorldClass::getState(\"%s\", %p) - Failed to get node from uri", uri, uridMap);
  368. return nullptr;
  369. }
  370. LilvState* const cState(lilv_state_new_from_world(this->me, uridMap, uriNode));
  371. lilv_node_free(uriNode);
  372. if (cState == nullptr)
  373. {
  374. carla_stderr("Lv2WorldClass::getState(\"%s\", %p) - Failed to get state", uri, uridMap);
  375. return nullptr;
  376. }
  377. return cState;
  378. }
  379. CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION
  380. };
  381. // -----------------------------------------------------------------------
  382. // Create new RDF object (using lilv)
  383. static inline
  384. const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool doInit)
  385. {
  386. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);
  387. Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());
  388. if (doInit)
  389. lv2World.initIfNeeded();
  390. const LilvPlugin* const cPlugin(lv2World.getPlugin(uri));
  391. if (cPlugin == nullptr)
  392. {
  393. // Error already printed in getPlugin()
  394. return nullptr;
  395. }
  396. Lilv::Plugin lilvPlugin(cPlugin);
  397. LV2_RDF_Descriptor* const rdfDescriptor(new LV2_RDF_Descriptor());
  398. // -------------------------------------------------------------------
  399. // Set Plugin Type
  400. {
  401. Lilv::Nodes typeNodes(lilvPlugin.get_value(lv2World.rdf_type));
  402. if (typeNodes.size() > 0)
  403. {
  404. if (typeNodes.contains(lv2World.class_allpass))
  405. rdfDescriptor->Type[0] |= LV2_PLUGIN_ALLPASS;
  406. if (typeNodes.contains(lv2World.class_amplifier))
  407. rdfDescriptor->Type[0] |= LV2_PLUGIN_AMPLIFIER;
  408. if (typeNodes.contains(lv2World.class_analyzer))
  409. rdfDescriptor->Type[1] |= LV2_PLUGIN_ANALYSER;
  410. if (typeNodes.contains(lv2World.class_bandpass))
  411. rdfDescriptor->Type[0] |= LV2_PLUGIN_BANDPASS;
  412. if (typeNodes.contains(lv2World.class_chorus))
  413. rdfDescriptor->Type[1] |= LV2_PLUGIN_CHORUS;
  414. if (typeNodes.contains(lv2World.class_comb))
  415. rdfDescriptor->Type[1] |= LV2_PLUGIN_COMB;
  416. if (typeNodes.contains(lv2World.class_compressor))
  417. rdfDescriptor->Type[0] |= LV2_PLUGIN_COMPRESSOR;
  418. if (typeNodes.contains(lv2World.class_constant))
  419. rdfDescriptor->Type[1] |= LV2_PLUGIN_CONSTANT;
  420. if (typeNodes.contains(lv2World.class_converter))
  421. rdfDescriptor->Type[1] |= LV2_PLUGIN_CONVERTER;
  422. if (typeNodes.contains(lv2World.class_delay))
  423. rdfDescriptor->Type[0] |= LV2_PLUGIN_DELAY;
  424. if (typeNodes.contains(lv2World.class_distortion))
  425. rdfDescriptor->Type[0] |= LV2_PLUGIN_DISTORTION;
  426. if (typeNodes.contains(lv2World.class_dynamics))
  427. rdfDescriptor->Type[0] |= LV2_PLUGIN_DYNAMICS;
  428. if (typeNodes.contains(lv2World.class_eq))
  429. rdfDescriptor->Type[0] |= LV2_PLUGIN_EQ;
  430. if (typeNodes.contains(lv2World.class_envelope))
  431. rdfDescriptor->Type[0] |= LV2_PLUGIN_ENVELOPE;
  432. if (typeNodes.contains(lv2World.class_expander))
  433. rdfDescriptor->Type[0] |= LV2_PLUGIN_EXPANDER;
  434. if (typeNodes.contains(lv2World.class_filter))
  435. rdfDescriptor->Type[0] |= LV2_PLUGIN_FILTER;
  436. if (typeNodes.contains(lv2World.class_flanger))
  437. rdfDescriptor->Type[1] |= LV2_PLUGIN_FLANGER;
  438. if (typeNodes.contains(lv2World.class_function))
  439. rdfDescriptor->Type[1] |= LV2_PLUGIN_FUNCTION;
  440. if (typeNodes.contains(lv2World.class_gate))
  441. rdfDescriptor->Type[0] |= LV2_PLUGIN_GATE;
  442. if (typeNodes.contains(lv2World.class_generator))
  443. rdfDescriptor->Type[1] |= LV2_PLUGIN_GENERATOR;
  444. if (typeNodes.contains(lv2World.class_highpass))
  445. rdfDescriptor->Type[0] |= LV2_PLUGIN_HIGHPASS;
  446. if (typeNodes.contains(lv2World.class_instrument))
  447. rdfDescriptor->Type[1] |= LV2_PLUGIN_INSTRUMENT;
  448. if (typeNodes.contains(lv2World.class_limiter))
  449. rdfDescriptor->Type[0] |= LV2_PLUGIN_LIMITER;
  450. if (typeNodes.contains(lv2World.class_lowpass))
  451. rdfDescriptor->Type[0] |= LV2_PLUGIN_LOWPASS;
  452. if (typeNodes.contains(lv2World.class_mixer))
  453. rdfDescriptor->Type[1] |= LV2_PLUGIN_MIXER;
  454. if (typeNodes.contains(lv2World.class_modulator))
  455. rdfDescriptor->Type[1] |= LV2_PLUGIN_MODULATOR;
  456. if (typeNodes.contains(lv2World.class_multiEQ))
  457. rdfDescriptor->Type[0] |= LV2_PLUGIN_MULTI_EQ;
  458. if (typeNodes.contains(lv2World.class_oscillator))
  459. rdfDescriptor->Type[1] |= LV2_PLUGIN_OSCILLATOR;
  460. if (typeNodes.contains(lv2World.class_paraEQ))
  461. rdfDescriptor->Type[0] |= LV2_PLUGIN_PARA_EQ;
  462. if (typeNodes.contains(lv2World.class_phaser))
  463. rdfDescriptor->Type[1] |= LV2_PLUGIN_PHASER;
  464. if (typeNodes.contains(lv2World.class_pitch))
  465. rdfDescriptor->Type[1] |= LV2_PLUGIN_PITCH;
  466. if (typeNodes.contains(lv2World.class_reverb))
  467. rdfDescriptor->Type[0] |= LV2_PLUGIN_REVERB;
  468. if (typeNodes.contains(lv2World.class_simulator))
  469. rdfDescriptor->Type[0] |= LV2_PLUGIN_SIMULATOR;
  470. if (typeNodes.contains(lv2World.class_spatial))
  471. rdfDescriptor->Type[1] |= LV2_PLUGIN_SPATIAL;
  472. if (typeNodes.contains(lv2World.class_spectral))
  473. rdfDescriptor->Type[1] |= LV2_PLUGIN_SPECTRAL;
  474. if (typeNodes.contains(lv2World.class_utility))
  475. rdfDescriptor->Type[1] |= LV2_PLUGIN_UTILITY;
  476. if (typeNodes.contains(lv2World.class_waveshaper))
  477. rdfDescriptor->Type[0] |= LV2_PLUGIN_WAVESHAPER;
  478. }
  479. lilv_nodes_free(const_cast<LilvNodes*>(typeNodes.me));
  480. }
  481. // -------------------------------------------------------------------
  482. // Set Plugin Information
  483. {
  484. rdfDescriptor->URI = carla_strdup(uri);
  485. if (const char* const name = lilvPlugin.get_name().as_string())
  486. rdfDescriptor->Name = carla_strdup(name);
  487. if (const char* const author = lilvPlugin.get_author_name().as_string())
  488. rdfDescriptor->Author = carla_strdup(author);
  489. if (const char* const binary = lilvPlugin.get_library_uri().as_string())
  490. rdfDescriptor->Binary = carla_strdup(lilv_uri_to_path(binary));
  491. if (const char* const bundle = lilvPlugin.get_bundle_uri().as_string())
  492. rdfDescriptor->Bundle = carla_strdup(lilv_uri_to_path(bundle));
  493. Lilv::Nodes licenseNodes(lilvPlugin.get_value(lv2World.doap_license));
  494. if (licenseNodes.size() > 0)
  495. {
  496. if (const char* const license = licenseNodes.get_first().as_string())
  497. rdfDescriptor->License = carla_strdup(license);
  498. }
  499. lilv_nodes_free(const_cast<LilvNodes*>(licenseNodes.me));
  500. }
  501. // -------------------------------------------------------------------
  502. // Set Plugin UniqueID
  503. {
  504. Lilv::Nodes replaceNodes(lilvPlugin.get_value(lv2World.dct_replaces));
  505. if (replaceNodes.size() > 0)
  506. {
  507. Lilv::Node replaceNode(replaceNodes.get_first());
  508. if (replaceNode.is_uri())
  509. {
  510. #ifdef USE_QT
  511. const QString replaceURI(replaceNode.as_uri());
  512. if (replaceURI.startsWith("urn:"))
  513. {
  514. const QString replaceId(replaceURI.split(":").last());
  515. bool ok;
  516. const ulong uniqueId(replaceId.toULong(&ok));
  517. if (ok && uniqueId != 0)
  518. rdfDescriptor->UniqueID = uniqueId;
  519. }
  520. #else
  521. const juce::String replaceURI(replaceNode.as_uri());
  522. if (replaceURI.startsWith("urn:"))
  523. {
  524. const int uniqueId(replaceURI.getTrailingIntValue());
  525. if (uniqueId > 0)
  526. rdfDescriptor->UniqueID = static_cast<ulong>(uniqueId);
  527. }
  528. #endif
  529. }
  530. }
  531. lilv_nodes_free(const_cast<LilvNodes*>(replaceNodes.me));
  532. }
  533. // -------------------------------------------------------------------
  534. // Set Plugin Ports
  535. if (lilvPlugin.get_num_ports() > 0)
  536. {
  537. rdfDescriptor->PortCount = lilvPlugin.get_num_ports();
  538. rdfDescriptor->Ports = new LV2_RDF_Port[rdfDescriptor->PortCount];
  539. for (uint32_t i = 0; i < rdfDescriptor->PortCount; ++i)
  540. {
  541. Lilv::Port lilvPort(lilvPlugin.get_port_by_index(i));
  542. LV2_RDF_Port* const rdfPort(&rdfDescriptor->Ports[i]);
  543. // -----------------------------------------------------------
  544. // Set Port Information
  545. {
  546. if (const char* const name = Lilv::Node(lilvPort.get_name()).as_string())
  547. rdfPort->Name = carla_strdup(name);
  548. if (const char* const symbol = Lilv::Node(lilvPort.get_symbol()).as_string())
  549. rdfPort->Symbol = carla_strdup(symbol);
  550. }
  551. // -----------------------------------------------------------
  552. // Set Port Mode and Type
  553. {
  554. // Input or Output
  555. if (lilvPort.is_a(lv2World.port_input))
  556. rdfPort->Types |= LV2_PORT_INPUT;
  557. else if (lilvPort.is_a(lv2World.port_output))
  558. rdfPort->Types |= LV2_PORT_OUTPUT;
  559. else
  560. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is not input or output", uri, rdfPort->Name);
  561. // Data Type
  562. if (lilvPort.is_a(lv2World.port_control))
  563. {
  564. rdfPort->Types |= LV2_PORT_CONTROL;
  565. }
  566. else if (lilvPort.is_a(lv2World.port_audio))
  567. {
  568. rdfPort->Types |= LV2_PORT_AUDIO;
  569. }
  570. else if (lilvPort.is_a(lv2World.port_cv))
  571. {
  572. rdfPort->Types |= LV2_PORT_CV;
  573. }
  574. else if (lilvPort.is_a(lv2World.port_atom))
  575. {
  576. rdfPort->Types |= LV2_PORT_ATOM;
  577. Lilv::Nodes bufferTypeNodes(lilvPort.get_value(lv2World.atom_bufferType));
  578. for (LilvIter* it = lilv_nodes_begin(bufferTypeNodes.me); ! lilv_nodes_is_end(bufferTypeNodes.me, it); it = lilv_nodes_next(bufferTypeNodes.me, it))
  579. {
  580. const Lilv::Node node(lilv_nodes_get(bufferTypeNodes.me, it));
  581. CARLA_SAFE_ASSERT_CONTINUE(node.is_uri());
  582. if (node.equals(lv2World.atom_sequence))
  583. rdfPort->Types |= LV2_PORT_ATOM_SEQUENCE;
  584. else
  585. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses an unknown atom buffer type '%s'", uri, rdfPort->Name, node.as_uri());
  586. }
  587. Lilv::Nodes supportNodes(lilvPort.get_value(lv2World.atom_supports));
  588. for (LilvIter* it = lilv_nodes_begin(supportNodes.me); ! lilv_nodes_is_end(supportNodes.me, it); it = lilv_nodes_next(supportNodes.me, it))
  589. {
  590. const Lilv::Node node(lilv_nodes_get(supportNodes.me, it));
  591. CARLA_SAFE_ASSERT_CONTINUE(node.is_uri());
  592. if (node.equals(lv2World.midi_event))
  593. rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
  594. else if (node.equals(lv2World.patch_message))
  595. rdfPort->Types |= LV2_PORT_DATA_PATCH_MESSAGE;
  596. else if (node.equals(lv2World.time_position))
  597. rdfPort->Types |= LV2_PORT_DATA_TIME_POSITION;
  598. #if 0
  599. // something new we don't support yet?
  600. else if (std::strstr(node.as_uri(), "lv2plug.in/") != nullptr)
  601. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of atom type but has unsupported data '%s'", uri, rdfPort->Name, node.as_uri());
  602. #endif
  603. }
  604. lilv_nodes_free(const_cast<LilvNodes*>(bufferTypeNodes.me));
  605. lilv_nodes_free(const_cast<LilvNodes*>(supportNodes.me));
  606. }
  607. else if (lilvPort.is_a(lv2World.port_event))
  608. {
  609. rdfPort->Types |= LV2_PORT_EVENT;
  610. bool supported = false;
  611. if (lilvPort.supports_event(lv2World.midi_event))
  612. {
  613. rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
  614. supported = true;
  615. }
  616. if (lilvPort.supports_event(lv2World.patch_message))
  617. {
  618. rdfPort->Types |= LV2_PORT_DATA_PATCH_MESSAGE;
  619. supported = true;
  620. }
  621. if (lilvPort.supports_event(lv2World.time_position))
  622. {
  623. rdfPort->Types |= LV2_PORT_DATA_TIME_POSITION;
  624. supported = true;
  625. }
  626. if (! supported)
  627. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of event type but has unsupported data", uri, rdfPort->Name);
  628. }
  629. else if (lilvPort.is_a(lv2World.port_midi))
  630. {
  631. rdfPort->Types |= LV2_PORT_MIDI_LL;
  632. rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
  633. }
  634. else
  635. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of unkown data type", uri, rdfPort->Name);
  636. }
  637. // -----------------------------------------------------------
  638. // Set Port Properties
  639. {
  640. if (lilvPort.has_property(lv2World.pprop_optional))
  641. rdfPort->Properties |= LV2_PORT_OPTIONAL;
  642. if (lilvPort.has_property(lv2World.pprop_enumeration))
  643. rdfPort->Properties |= LV2_PORT_ENUMERATION;
  644. if (lilvPort.has_property(lv2World.pprop_integer))
  645. rdfPort->Properties |= LV2_PORT_INTEGER;
  646. if (lilvPort.has_property(lv2World.pprop_sampleRate))
  647. rdfPort->Properties |= LV2_PORT_SAMPLE_RATE;
  648. if (lilvPort.has_property(lv2World.pprop_toggled))
  649. rdfPort->Properties |= LV2_PORT_TOGGLED;
  650. if (lilvPort.has_property(lv2World.pprop_artifacts))
  651. rdfPort->Properties |= LV2_PORT_CAUSES_ARTIFACTS;
  652. if (lilvPort.has_property(lv2World.pprop_continuousCV))
  653. rdfPort->Properties |= LV2_PORT_CONTINUOUS_CV;
  654. if (lilvPort.has_property(lv2World.pprop_discreteCV))
  655. rdfPort->Properties |= LV2_PORT_DISCRETE_CV;
  656. if (lilvPort.has_property(lv2World.pprop_expensive))
  657. rdfPort->Properties |= LV2_PORT_EXPENSIVE;
  658. if (lilvPort.has_property(lv2World.pprop_strictBounds))
  659. rdfPort->Properties |= LV2_PORT_STRICT_BOUNDS;
  660. if (lilvPort.has_property(lv2World.pprop_logarithmic))
  661. rdfPort->Properties |= LV2_PORT_LOGARITHMIC;
  662. if (lilvPort.has_property(lv2World.pprop_notAutomatic))
  663. rdfPort->Properties |= LV2_PORT_NOT_AUTOMATIC;
  664. if (lilvPort.has_property(lv2World.pprop_notOnGUI))
  665. rdfPort->Properties |= LV2_PORT_NOT_ON_GUI;
  666. if (lilvPort.has_property(lv2World.pprop_trigger))
  667. rdfPort->Properties |= LV2_PORT_TRIGGER;
  668. if (lilvPort.has_property(lv2World.reportsLatency))
  669. rdfPort->Designation = LV2_PORT_DESIGNATION_LATENCY;
  670. // no port properties set, check if using old/invalid ones
  671. if (rdfPort->Properties == 0x0)
  672. {
  673. static const Lilv::Node oldPropArtifacts(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#causesArtifacts"));
  674. static const Lilv::Node oldPropContinuousCV(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#continuousCV"));
  675. static const Lilv::Node oldPropDiscreteCV(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#discreteCV"));
  676. static const Lilv::Node oldPropExpensive(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#expensive"));
  677. static const Lilv::Node oldPropStrictBounds(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#hasStrictBounds"));
  678. static const Lilv::Node oldPropLogarithmic(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#logarithmic"));
  679. static const Lilv::Node oldPropNotAutomatic(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#notAutomatic"));
  680. static const Lilv::Node oldPropNotOnGUI(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#notOnGUI"));
  681. static const Lilv::Node oldPropTrigger(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#trigger"));
  682. if (lilvPort.has_property(oldPropArtifacts))
  683. {
  684. rdfPort->Properties |= LV2_PORT_CAUSES_ARTIFACTS;
  685. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'causesArtifacts'", uri, rdfPort->Name);
  686. }
  687. if (lilvPort.has_property(oldPropContinuousCV))
  688. {
  689. rdfPort->Properties |= LV2_PORT_CONTINUOUS_CV;
  690. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'continuousCV'", uri, rdfPort->Name);
  691. }
  692. if (lilvPort.has_property(oldPropDiscreteCV))
  693. {
  694. rdfPort->Properties |= LV2_PORT_DISCRETE_CV;
  695. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'discreteCV'", uri, rdfPort->Name);
  696. }
  697. if (lilvPort.has_property(oldPropExpensive))
  698. {
  699. rdfPort->Properties |= LV2_PORT_EXPENSIVE;
  700. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'expensive'", uri, rdfPort->Name);
  701. }
  702. if (lilvPort.has_property(oldPropStrictBounds))
  703. {
  704. rdfPort->Properties |= LV2_PORT_STRICT_BOUNDS;
  705. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'hasStrictBounds'", uri, rdfPort->Name);
  706. }
  707. if (lilvPort.has_property(oldPropLogarithmic))
  708. {
  709. rdfPort->Properties |= LV2_PORT_LOGARITHMIC;
  710. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'logarithmic'", uri, rdfPort->Name);
  711. }
  712. if (lilvPort.has_property(oldPropNotAutomatic))
  713. {
  714. rdfPort->Properties |= LV2_PORT_NOT_AUTOMATIC;
  715. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'notAutomatic'", uri, rdfPort->Name);
  716. }
  717. if (lilvPort.has_property(oldPropNotOnGUI))
  718. {
  719. rdfPort->Properties |= LV2_PORT_NOT_ON_GUI;
  720. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'notOnGUI'", uri, rdfPort->Name);
  721. }
  722. if (lilvPort.has_property(oldPropTrigger))
  723. {
  724. rdfPort->Properties |= LV2_PORT_TRIGGER;
  725. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'trigger'", uri, rdfPort->Name);
  726. }
  727. }
  728. }
  729. // -----------------------------------------------------------
  730. // Set Port Designation
  731. {
  732. if (LilvNode* const designationNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.designation.me))
  733. {
  734. if (const char* const designation = lilv_node_as_string(designationNode))
  735. {
  736. if (std::strcmp(designation, LV2_CORE__control) == 0)
  737. rdfPort->Designation = LV2_PORT_DESIGNATION_CONTROL;
  738. else if (std::strcmp(designation, LV2_CORE__freeWheeling) == 0)
  739. rdfPort->Designation = LV2_PORT_DESIGNATION_FREEWHEELING;
  740. else if (std::strcmp(designation, LV2_CORE__latency) == 0)
  741. rdfPort->Designation = LV2_PORT_DESIGNATION_LATENCY;
  742. else if (std::strcmp(designation, LV2_PARAMETERS__sampleRate) == 0)
  743. rdfPort->Designation = LV2_PORT_DESIGNATION_SAMPLE_RATE;
  744. else if (std::strcmp(designation, LV2_TIME__bar) == 0)
  745. rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BAR;
  746. else if (std::strcmp(designation, LV2_TIME__barBeat) == 0)
  747. rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BAR_BEAT;
  748. else if (std::strcmp(designation, LV2_TIME__beat) == 0)
  749. rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BEAT;
  750. else if (std::strcmp(designation, LV2_TIME__beatUnit) == 0)
  751. rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BEAT_UNIT;
  752. else if (std::strcmp(designation, LV2_TIME__beatsPerBar) == 0)
  753. rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BEATS_PER_BAR;
  754. else if (std::strcmp(designation, LV2_TIME__beatsPerMinute) == 0)
  755. rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BEATS_PER_MINUTE;
  756. else if (std::strcmp(designation, LV2_TIME__frame) == 0)
  757. rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_FRAME;
  758. else if (std::strcmp(designation, LV2_TIME__framesPerSecond) == 0)
  759. rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_FRAMES_PER_SECOND;
  760. else if (std::strcmp(designation, LV2_TIME__speed) == 0)
  761. rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_SPEED;
  762. else if (std::strncmp(designation, LV2_PARAMETERS_PREFIX, std::strlen(LV2_PARAMETERS_PREFIX)) == 0)
  763. pass();
  764. else if (std::strncmp(designation, LV2_PORT_GROUPS_PREFIX, std::strlen(LV2_PORT_GROUPS_PREFIX)) == 0)
  765. pass();
  766. else
  767. carla_stderr("lv2_rdf_new(\"%s\") - got unknown port designation '%s'", uri, designation);
  768. }
  769. lilv_node_free(designationNode);
  770. }
  771. }
  772. // -----------------------------------------------------------
  773. // Set Port MIDI Map
  774. {
  775. if (LilvNode* const midiMapNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.mm_defaultControl.me))
  776. {
  777. if (lilv_node_is_blank(midiMapNode))
  778. {
  779. Lilv::Nodes midiMapTypeNodes(lv2World.find_nodes(midiMapNode, lv2World.mm_controlType, nullptr));
  780. Lilv::Nodes midiMapNumberNodes(lv2World.find_nodes(midiMapNode, lv2World.mm_controlNumber, nullptr));
  781. if (midiMapTypeNodes.size() == 1 && midiMapNumberNodes.size() == 1)
  782. {
  783. if (const char* const midiMapType = midiMapTypeNodes.get_first().as_string())
  784. {
  785. if (std::strcmp(midiMapType, LV2_MIDI_Map__CC) == 0)
  786. rdfPort->MidiMap.Type = LV2_PORT_MIDI_MAP_CC;
  787. else if (std::strcmp(midiMapType, LV2_MIDI_Map__NRPN) == 0)
  788. rdfPort->MidiMap.Type = LV2_PORT_MIDI_MAP_NRPN;
  789. else
  790. carla_stderr("lv2_rdf_new(\"%s\") - got unknown port Midi-Map type '%s'", uri, midiMapType);
  791. rdfPort->MidiMap.Number = static_cast<uint32_t>(midiMapNumberNodes.get_first().as_int());
  792. }
  793. }
  794. lilv_nodes_free(const_cast<LilvNodes*>(midiMapTypeNodes.me));
  795. lilv_nodes_free(const_cast<LilvNodes*>(midiMapNumberNodes.me));
  796. }
  797. lilv_node_free(midiMapNode);
  798. }
  799. // TODO - also check using new official MIDI API too
  800. }
  801. // -----------------------------------------------------------
  802. // Set Port Points
  803. {
  804. if (LilvNode* const defNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.value_default.me))
  805. {
  806. rdfPort->Points.Hints |= LV2_PORT_POINT_DEFAULT;
  807. rdfPort->Points.Default = lilv_node_as_float(defNode);
  808. lilv_node_free(defNode);
  809. }
  810. if (LilvNode* const minNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.value_minimum.me))
  811. {
  812. rdfPort->Points.Hints |= LV2_PORT_POINT_MINIMUM;
  813. rdfPort->Points.Minimum = lilv_node_as_float(minNode);
  814. lilv_node_free(minNode);
  815. }
  816. if (LilvNode* const maxNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.value_maximum.me))
  817. {
  818. rdfPort->Points.Hints |= LV2_PORT_POINT_MAXIMUM;
  819. rdfPort->Points.Maximum = lilv_node_as_float(maxNode);
  820. lilv_node_free(maxNode);
  821. }
  822. }
  823. // -----------------------------------------------------------
  824. // Set Port Unit
  825. {
  826. if (LilvNode* const unitUnitNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.unit_unit.me))
  827. {
  828. if (lilv_node_is_uri(unitUnitNode))
  829. {
  830. if (const char* const unitUnit = lilv_node_as_uri(unitUnitNode))
  831. {
  832. rdfPort->Unit.Hints |= LV2_PORT_UNIT_UNIT;
  833. if (std::strcmp(unitUnit, LV2_UNITS__bar) == 0)
  834. rdfPort->Unit.Unit = LV2_PORT_UNIT_BAR;
  835. else if (std::strcmp(unitUnit, LV2_UNITS__beat) == 0)
  836. rdfPort->Unit.Unit = LV2_PORT_UNIT_BEAT;
  837. else if (std::strcmp(unitUnit, LV2_UNITS__bpm) == 0)
  838. rdfPort->Unit.Unit = LV2_PORT_UNIT_BPM;
  839. else if (std::strcmp(unitUnit, LV2_UNITS__cent) == 0)
  840. rdfPort->Unit.Unit = LV2_PORT_UNIT_CENT;
  841. else if (std::strcmp(unitUnit, LV2_UNITS__cm) == 0)
  842. rdfPort->Unit.Unit = LV2_PORT_UNIT_CM;
  843. else if (std::strcmp(unitUnit, LV2_UNITS__coef) == 0)
  844. rdfPort->Unit.Unit = LV2_PORT_UNIT_COEF;
  845. else if (std::strcmp(unitUnit, LV2_UNITS__db) == 0)
  846. rdfPort->Unit.Unit = LV2_PORT_UNIT_DB;
  847. else if (std::strcmp(unitUnit, LV2_UNITS__degree) == 0)
  848. rdfPort->Unit.Unit = LV2_PORT_UNIT_DEGREE;
  849. else if (std::strcmp(unitUnit, LV2_UNITS__frame) == 0)
  850. rdfPort->Unit.Unit = LV2_PORT_UNIT_FRAME;
  851. else if (std::strcmp(unitUnit, LV2_UNITS__hz) == 0)
  852. rdfPort->Unit.Unit = LV2_PORT_UNIT_HZ;
  853. else if (std::strcmp(unitUnit, LV2_UNITS__inch) == 0)
  854. rdfPort->Unit.Unit = LV2_PORT_UNIT_INCH;
  855. else if (std::strcmp(unitUnit, LV2_UNITS__khz) == 0)
  856. rdfPort->Unit.Unit = LV2_PORT_UNIT_KHZ;
  857. else if (std::strcmp(unitUnit, LV2_UNITS__km) == 0)
  858. rdfPort->Unit.Unit = LV2_PORT_UNIT_KM;
  859. else if (std::strcmp(unitUnit, LV2_UNITS__m) == 0)
  860. rdfPort->Unit.Unit = LV2_PORT_UNIT_M;
  861. else if (std::strcmp(unitUnit, LV2_UNITS__mhz) == 0)
  862. rdfPort->Unit.Unit = LV2_PORT_UNIT_MHZ;
  863. else if (std::strcmp(unitUnit, LV2_UNITS__midiNote) == 0)
  864. rdfPort->Unit.Unit = LV2_PORT_UNIT_MIDINOTE;
  865. else if (std::strcmp(unitUnit, LV2_UNITS__mile) == 0)
  866. rdfPort->Unit.Unit = LV2_PORT_UNIT_MILE;
  867. else if (std::strcmp(unitUnit, LV2_UNITS__min) == 0)
  868. rdfPort->Unit.Unit = LV2_PORT_UNIT_MIN;
  869. else if (std::strcmp(unitUnit, LV2_UNITS__mm) == 0)
  870. rdfPort->Unit.Unit = LV2_PORT_UNIT_MM;
  871. else if (std::strcmp(unitUnit, LV2_UNITS__ms) == 0)
  872. rdfPort->Unit.Unit = LV2_PORT_UNIT_MS;
  873. else if (std::strcmp(unitUnit, LV2_UNITS__oct) == 0)
  874. rdfPort->Unit.Unit = LV2_PORT_UNIT_OCT;
  875. else if (std::strcmp(unitUnit, LV2_UNITS__pc) == 0)
  876. rdfPort->Unit.Unit = LV2_PORT_UNIT_PC;
  877. else if (std::strcmp(unitUnit, LV2_UNITS__s) == 0)
  878. rdfPort->Unit.Unit = LV2_PORT_UNIT_S;
  879. else if (std::strcmp(unitUnit, LV2_UNITS__semitone12TET) == 0)
  880. rdfPort->Unit.Unit = LV2_PORT_UNIT_SEMITONE;
  881. else
  882. carla_stderr("lv2_rdf_new(\"%s\") - got unknown unit unit '%s'", uri, unitUnit);
  883. }
  884. }
  885. lilv_node_free(unitUnitNode);
  886. }
  887. // FIXME
  888. if (LilvNode* const unitNameNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.unit_name.me))
  889. {
  890. if (const char* const unitName = lilv_node_as_string(unitNameNode))
  891. {
  892. rdfPort->Unit.Hints |= LV2_PORT_UNIT_NAME;
  893. rdfPort->Unit.Name = carla_strdup(unitName);
  894. }
  895. lilv_node_free(unitNameNode);
  896. }
  897. if (LilvNode* const unitRenderNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.unit_render.me))
  898. {
  899. if (const char* const unitRender = lilv_node_as_string(unitRenderNode))
  900. {
  901. rdfPort->Unit.Hints |= LV2_PORT_UNIT_RENDER;
  902. rdfPort->Unit.Render = carla_strdup(unitRender);
  903. }
  904. lilv_node_free(unitRenderNode);
  905. }
  906. if (LilvNode* const unitSymbolNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.unit_symbol.me))
  907. {
  908. if (const char* const unitSymbol = lilv_node_as_string(unitSymbolNode))
  909. {
  910. rdfPort->Unit.Hints |= LV2_PORT_UNIT_SYMBOL;
  911. rdfPort->Unit.Symbol = carla_strdup(unitSymbol);
  912. }
  913. lilv_node_free(unitSymbolNode);
  914. }
  915. }
  916. // -----------------------------------------------------------
  917. // Set Port Minimum Size
  918. {
  919. if (LilvNode* const minimumSizeNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.rz_minSize.me))
  920. {
  921. const int minimumSize(lilv_node_as_int(minimumSizeNode));
  922. if (minimumSize > 0)
  923. rdfPort->MinimumSize = static_cast<uint32_t>(minimumSize);
  924. else
  925. carla_safe_assert_int("minimumSize > 0", __FILE__, __LINE__, minimumSize);
  926. lilv_node_free(minimumSizeNode);
  927. }
  928. }
  929. // -----------------------------------------------------------
  930. // Set Port Scale Points
  931. {
  932. Lilv::ScalePoints lilvScalePoints(lilvPort.get_scale_points());
  933. if (lilvScalePoints.size() > 0)
  934. {
  935. rdfPort->ScalePointCount = lilvScalePoints.size();
  936. rdfPort->ScalePoints = new LV2_RDF_PortScalePoint[rdfPort->ScalePointCount];
  937. uint32_t h = 0;
  938. LILV_FOREACH(scale_points, it, lilvScalePoints)
  939. {
  940. CARLA_SAFE_ASSERT_BREAK(h < rdfPort->ScalePointCount);
  941. Lilv::ScalePoint lilvScalePoint(lilvScalePoints.get(it));
  942. LV2_RDF_PortScalePoint* const rdfScalePoint(&rdfPort->ScalePoints[h++]);
  943. if (const char* const label = Lilv::Node(lilvScalePoint.get_label()).as_string())
  944. rdfScalePoint->Label = carla_strdup(label);
  945. rdfScalePoint->Value = Lilv::Node(lilvScalePoint.get_value()).as_float();
  946. }
  947. }
  948. lilv_nodes_free(const_cast<LilvNodes*>(lilvScalePoints.me));
  949. }
  950. }
  951. }
  952. // -------------------------------------------------------------------
  953. // Set Plugin Presets
  954. if (doInit)
  955. {
  956. Lilv::Nodes presetNodes(lilvPlugin.get_related(lv2World.preset_preset));
  957. if (presetNodes.size() > 0)
  958. {
  959. // create a list of preset URIs (for checking appliesTo, sorting and unique-ness)
  960. // FIXME - check appliesTo?
  961. #ifdef USE_QT
  962. QStringList presetListURIs;
  963. LILV_FOREACH(nodes, it, presetNodes)
  964. {
  965. Lilv::Node presetNode(presetNodes.get(it));
  966. QString presetURI(presetNode.as_uri());
  967. if (! (presetURI.trimmed().isEmpty() || presetListURIs.contains(presetURI)))
  968. presetListURIs.append(presetURI);
  969. }
  970. presetListURIs.sort();
  971. rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.count());
  972. #else
  973. juce::StringArray presetListURIs;
  974. LILV_FOREACH(nodes, it, presetNodes)
  975. {
  976. Lilv::Node presetNode(presetNodes.get(it));
  977. juce::String presetURI(presetNode.as_uri());
  978. if (presetURI.trim().isNotEmpty())
  979. presetListURIs.addIfNotAlreadyThere(presetURI);
  980. }
  981. presetListURIs.sortNatural();
  982. rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.size());
  983. #endif
  984. // create presets with unique URIs
  985. rdfDescriptor->Presets = new LV2_RDF_Preset[rdfDescriptor->PresetCount];
  986. // set preset data
  987. LILV_FOREACH(nodes, it, presetNodes)
  988. {
  989. Lilv::Node presetNode(presetNodes.get(it));
  990. if (lv2World.load_resource(presetNode) == -1)
  991. continue;
  992. if (const char* const presetURI = presetNode.as_uri())
  993. {
  994. #ifdef USE_QT
  995. const int index(presetListURIs.indexOf(QString(presetURI)));
  996. #else
  997. const int index(presetListURIs.indexOf(juce::String(presetURI)));
  998. #endif
  999. CARLA_SAFE_ASSERT_CONTINUE(index >= 0);
  1000. LV2_RDF_Preset* const rdfPreset(&rdfDescriptor->Presets[index]);
  1001. // ---------------------------------------------------
  1002. // Set Preset Information
  1003. {
  1004. rdfPreset->URI = carla_strdup(presetURI);
  1005. Lilv::Nodes presetLabelNodes(lv2World.find_nodes(presetNode, lv2World.rdfs_label, nullptr));
  1006. if (presetLabelNodes.size() > 0)
  1007. {
  1008. if (const char* const label = presetLabelNodes.get_first().as_string())
  1009. rdfPreset->Label = carla_strdup(label);
  1010. }
  1011. lilv_nodes_free(const_cast<LilvNodes*>(presetLabelNodes.me));
  1012. }
  1013. }
  1014. }
  1015. }
  1016. lilv_nodes_free(const_cast<LilvNodes*>(presetNodes.me));
  1017. }
  1018. // -------------------------------------------------------------------
  1019. // Set Plugin Features
  1020. {
  1021. Lilv::Nodes lilvFeatureNodes(lilvPlugin.get_supported_features());
  1022. if (lilvFeatureNodes.size() > 0)
  1023. {
  1024. Lilv::Nodes lilvFeatureNodesR(lilvPlugin.get_required_features());
  1025. rdfDescriptor->FeatureCount = lilvFeatureNodes.size();
  1026. rdfDescriptor->Features = new LV2_RDF_Feature[rdfDescriptor->FeatureCount];
  1027. uint32_t h = 0;
  1028. LILV_FOREACH(nodes, it, lilvFeatureNodes)
  1029. {
  1030. CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->FeatureCount);
  1031. Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(it));
  1032. LV2_RDF_Feature* const rdfFeature(&rdfDescriptor->Features[h++]);
  1033. rdfFeature->Type = lilvFeatureNodesR.contains(lilvFeatureNode) ? LV2_FEATURE_REQUIRED : LV2_FEATURE_OPTIONAL;
  1034. if (const char* const featureURI = lilvFeatureNode.as_uri())
  1035. rdfFeature->URI = carla_strdup(featureURI);
  1036. else
  1037. rdfFeature->URI = nullptr;
  1038. }
  1039. lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodesR.me));
  1040. }
  1041. lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodes.me));
  1042. }
  1043. // -------------------------------------------------------------------
  1044. // Set Plugin Extensions
  1045. {
  1046. Lilv::Nodes lilvExtensionDataNodes(lilvPlugin.get_extension_data());
  1047. if (lilvExtensionDataNodes.size() > 0)
  1048. {
  1049. rdfDescriptor->ExtensionCount = lilvExtensionDataNodes.size();
  1050. rdfDescriptor->Extensions = new LV2_URI[rdfDescriptor->ExtensionCount];
  1051. uint32_t h = 0;
  1052. LILV_FOREACH(nodes, it, lilvExtensionDataNodes)
  1053. {
  1054. CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->ExtensionCount);
  1055. Lilv::Node lilvExtensionDataNode(lilvExtensionDataNodes.get(it));
  1056. LV2_URI* const rdfExtension(&rdfDescriptor->Extensions[h++]);
  1057. if (lilvExtensionDataNode.is_uri())
  1058. {
  1059. if (const char* const extURI = lilvExtensionDataNode.as_uri())
  1060. {
  1061. *rdfExtension = carla_strdup(extURI);
  1062. continue;
  1063. }
  1064. }
  1065. *rdfExtension = nullptr;
  1066. }
  1067. for (uint32_t x=h; x < rdfDescriptor->ExtensionCount; ++x)
  1068. rdfDescriptor->Extensions[x] = nullptr;
  1069. }
  1070. lilv_nodes_free(const_cast<LilvNodes*>(lilvExtensionDataNodes.me));
  1071. }
  1072. // -------------------------------------------------------------------
  1073. // Set Plugin UIs
  1074. {
  1075. Lilv::UIs lilvUIs(lilvPlugin.get_uis());
  1076. if (lilvUIs.size() > 0)
  1077. {
  1078. rdfDescriptor->UICount = lilvUIs.size();
  1079. rdfDescriptor->UIs = new LV2_RDF_UI[rdfDescriptor->UICount];
  1080. uint32_t h = 0;
  1081. LILV_FOREACH(uis, it, lilvUIs)
  1082. {
  1083. CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->UICount);
  1084. Lilv::UI lilvUI(lilvUIs.get(it));
  1085. LV2_RDF_UI* const rdfUI(&rdfDescriptor->UIs[h++]);
  1086. // -------------------------------------------------------
  1087. // Set UI Type
  1088. if (lilvUI.is_a(lv2World.ui_gtk2))
  1089. rdfUI->Type = LV2_UI_GTK2;
  1090. else if (lilvUI.is_a(lv2World.ui_gtk3))
  1091. rdfUI->Type = LV2_UI_GTK3;
  1092. else if (lilvUI.is_a(lv2World.ui_qt4))
  1093. rdfUI->Type = LV2_UI_QT4;
  1094. else if (lilvUI.is_a(lv2World.ui_qt5))
  1095. rdfUI->Type = LV2_UI_QT5;
  1096. else if (lilvUI.is_a(lv2World.ui_cocoa))
  1097. rdfUI->Type = LV2_UI_COCOA;
  1098. else if (lilvUI.is_a(lv2World.ui_windows))
  1099. rdfUI->Type = LV2_UI_WINDOWS;
  1100. else if (lilvUI.is_a(lv2World.ui_x11))
  1101. rdfUI->Type = LV2_UI_X11;
  1102. else if (lilvUI.is_a(lv2World.ui_external))
  1103. rdfUI->Type = LV2_UI_EXTERNAL;
  1104. else if (lilvUI.is_a(lv2World.ui_externalOld))
  1105. rdfUI->Type = LV2_UI_OLD_EXTERNAL;
  1106. else if (lilvUI.is_a(lv2World.ui_externalOld2))
  1107. pass();
  1108. else
  1109. carla_stderr("lv2_rdf_new(\"%s\") - UI '%s' is of unknown type", uri, lilvUI.get_uri().as_uri());
  1110. // -------------------------------------------------------
  1111. // Set UI Information
  1112. {
  1113. if (const char* const uiURI = lilvUI.get_uri().as_uri())
  1114. rdfUI->URI = carla_strdup(uiURI);
  1115. if (const char* const uiBinary = lilvUI.get_binary_uri().as_string())
  1116. rdfUI->Binary = carla_strdup(lilv_uri_to_path(uiBinary));
  1117. if (const char* const uiBundle = lilvUI.get_bundle_uri().as_string())
  1118. rdfUI->Bundle = carla_strdup(lilv_uri_to_path(uiBundle));
  1119. }
  1120. // -------------------------------------------------------
  1121. // Set UI Features
  1122. {
  1123. Lilv::Nodes lilvFeatureNodes(lilvUI.get_supported_features());
  1124. if (lilvFeatureNodes.size() > 0)
  1125. {
  1126. Lilv::Nodes lilvFeatureNodesR(lilvUI.get_required_features());
  1127. rdfUI->FeatureCount = lilvFeatureNodes.size();
  1128. rdfUI->Features = new LV2_RDF_Feature[rdfUI->FeatureCount];
  1129. uint32_t h2 = 0;
  1130. LILV_FOREACH(nodes, it2, lilvFeatureNodes)
  1131. {
  1132. CARLA_SAFE_ASSERT_BREAK(h2 < rdfUI->FeatureCount);
  1133. Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(it2));
  1134. LV2_RDF_Feature* const rdfFeature(&rdfUI->Features[h2++]);
  1135. rdfFeature->Type = lilvFeatureNodesR.contains(lilvFeatureNode) ? LV2_FEATURE_REQUIRED : LV2_FEATURE_OPTIONAL;
  1136. if (const char* const featureURI = lilvFeatureNode.as_uri())
  1137. rdfFeature->URI = carla_strdup(featureURI);
  1138. else
  1139. rdfFeature->URI = nullptr;
  1140. }
  1141. lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodesR.me));
  1142. }
  1143. lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodes.me));
  1144. }
  1145. // -------------------------------------------------------
  1146. // Set UI Extensions
  1147. {
  1148. Lilv::Nodes lilvExtensionDataNodes(lilvUI.get_extension_data());
  1149. if (lilvExtensionDataNodes.size() > 0)
  1150. {
  1151. rdfUI->ExtensionCount = lilvExtensionDataNodes.size();
  1152. rdfUI->Extensions = new LV2_URI[rdfUI->ExtensionCount];
  1153. uint32_t h2 = 0;
  1154. LILV_FOREACH(nodes, it2, lilvExtensionDataNodes)
  1155. {
  1156. CARLA_SAFE_ASSERT_BREAK(h2 < rdfUI->ExtensionCount);
  1157. Lilv::Node lilvExtensionDataNode(lilvExtensionDataNodes.get(it2));
  1158. LV2_URI* const rdfExtension(&rdfUI->Extensions[h2++]);
  1159. if (lilvExtensionDataNode.is_uri())
  1160. {
  1161. if (const char* const extURI = lilvExtensionDataNode.as_uri())
  1162. {
  1163. *rdfExtension = carla_strdup(extURI);
  1164. continue;
  1165. }
  1166. }
  1167. *rdfExtension = nullptr;
  1168. }
  1169. for (uint32_t x2=h2; x2 < rdfUI->ExtensionCount; ++x2)
  1170. rdfUI->Extensions[x2] = nullptr;
  1171. }
  1172. lilv_nodes_free(const_cast<LilvNodes*>(lilvExtensionDataNodes.me));
  1173. }
  1174. }
  1175. }
  1176. lilv_nodes_free(const_cast<LilvNodes*>(lilvUIs.me));
  1177. }
  1178. return rdfDescriptor;
  1179. }
  1180. // -----------------------------------------------------------------------
  1181. // Check if we support a plugin port
  1182. static inline
  1183. bool is_lv2_port_supported(const LV2_Property types) noexcept
  1184. {
  1185. if (LV2_IS_PORT_CONTROL(types))
  1186. return true;
  1187. if (LV2_IS_PORT_AUDIO(types))
  1188. return true;
  1189. if (LV2_IS_PORT_CV(types))
  1190. return true;
  1191. if (LV2_IS_PORT_ATOM_SEQUENCE(types))
  1192. return true;
  1193. if (LV2_IS_PORT_EVENT(types))
  1194. return true;
  1195. if (LV2_IS_PORT_MIDI_LL(types))
  1196. return true;
  1197. return false;
  1198. }
  1199. // -----------------------------------------------------------------------
  1200. // Check if we support a plugin feature
  1201. static inline
  1202. bool is_lv2_feature_supported(const LV2_URI uri) noexcept
  1203. {
  1204. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', false);
  1205. if (std::strcmp(uri, LV2_BUF_SIZE__boundedBlockLength) == 0)
  1206. return true;
  1207. if (std::strcmp(uri, LV2_BUF_SIZE__fixedBlockLength) == 0)
  1208. return true;
  1209. if (std::strcmp(uri, LV2_BUF_SIZE__powerOf2BlockLength) == 0)
  1210. return true;
  1211. if (std::strcmp(uri, LV2_CORE__hardRTCapable) == 0)
  1212. return true;
  1213. if (std::strcmp(uri, LV2_CORE__inPlaceBroken) == 0)
  1214. return true;
  1215. if (std::strcmp(uri, LV2_CORE__isLive) == 0)
  1216. return true;
  1217. if (std::strcmp(uri, LV2_EVENT_URI) == 0)
  1218. return true;
  1219. if (std::strcmp(uri, LV2_LOG__log) == 0)
  1220. return true;
  1221. if (std::strcmp(uri, LV2_OPTIONS__options) == 0)
  1222. return true;
  1223. if (std::strcmp(uri, LV2_PROGRAMS__Host) == 0)
  1224. return true;
  1225. if (std::strcmp(uri, LV2_RESIZE_PORT__resize) == 0)
  1226. return true;
  1227. if (std::strcmp(uri, LV2_RTSAFE_MEMORY_POOL__Pool) == 0)
  1228. return true;
  1229. if (std::strcmp(uri, LV2_RTSAFE_MEMORY_POOL_DEPRECATED_URI) == 0)
  1230. return true;
  1231. if (std::strcmp(uri, LV2_STATE__makePath) == 0)
  1232. return true;
  1233. if (std::strcmp(uri, LV2_STATE__mapPath) == 0)
  1234. return true;
  1235. if (std::strcmp(uri, LV2_PORT_PROPS__supportsStrictBounds) == 0)
  1236. return true;
  1237. if (std::strcmp(uri, LV2_URI_MAP_URI) == 0)
  1238. return true;
  1239. if (std::strcmp(uri, LV2_URID__map) == 0)
  1240. return true;
  1241. if (std::strcmp(uri, LV2_URID__unmap) == 0)
  1242. return true;
  1243. if (std::strcmp(uri, LV2_WORKER__schedule) == 0)
  1244. return true;
  1245. return false;
  1246. }
  1247. // -----------------------------------------------------------------------
  1248. // Check if we support a plugin or UI feature
  1249. static inline
  1250. bool is_lv2_ui_feature_supported(const LV2_URI uri) noexcept
  1251. {
  1252. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', false);
  1253. if (is_lv2_feature_supported(uri))
  1254. return true;
  1255. #ifndef BRIDGE_LV2
  1256. if (std::strcmp(uri, LV2_DATA_ACCESS_URI) == 0)
  1257. return true;
  1258. if (std::strcmp(uri, LV2_INSTANCE_ACCESS_URI) == 0)
  1259. return true;
  1260. #endif
  1261. if (std::strcmp(uri, LV2_UI__fixedSize) == 0)
  1262. return true;
  1263. if (std::strcmp(uri, LV2_UI__idleInterface) == 0)
  1264. return true;
  1265. if (std::strcmp(uri, LV2_UI__makeResident) == 0)
  1266. return true;
  1267. if (std::strcmp(uri, LV2_UI__noUserResize) == 0)
  1268. return true;
  1269. if (std::strcmp(uri, LV2_UI__parent) == 0)
  1270. return true;
  1271. if (std::strcmp(uri, LV2_UI__portMap) == 0)
  1272. return true;
  1273. if (std::strcmp(uri, LV2_UI__portSubscribe) == 0)
  1274. return true;
  1275. if (std::strcmp(uri, LV2_UI__resize) == 0)
  1276. return true;
  1277. if (std::strcmp(uri, LV2_UI__touch) == 0)
  1278. return true;
  1279. if (std::strcmp(uri, LV2_EXTERNAL_UI__Widget) == 0)
  1280. return true;
  1281. if (std::strcmp(uri, LV2_EXTERNAL_UI_DEPRECATED_URI) == 0)
  1282. return true;
  1283. return false;
  1284. }
  1285. // -----------------------------------------------------------------------
  1286. #endif // CARLA_LV2_UTILS_HPP_INCLUDED