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.

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