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.

1539 lines
65KB

  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_kxstudio_properties.h"
  62. #include "lv2/lv2_programs.h"
  63. #include "lv2/lv2_rtmempool.h"
  64. #include "lilv/lilvmm.hpp"
  65. #include "sratom/sratom.h"
  66. // enable -Wdocumentation again
  67. #if defined(__clang__) && (__clang_major__ * 100 + __clang_minor__) > 300
  68. # pragma clang diagnostic pop
  69. #endif
  70. #include "lv2_rdf.hpp"
  71. #ifdef USE_QT
  72. # include <QtCore/QStringList>
  73. #else
  74. # include "juce_core.h"
  75. #endif
  76. // -----------------------------------------------------------------------
  77. // Define namespaces and missing prefixes
  78. #define NS_dct "http://purl.org/dc/terms/"
  79. #define NS_doap "http://usefulinc.com/ns/doap#"
  80. #define NS_rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  81. #define NS_rdfs "http://www.w3.org/2000/01/rdf-schema#"
  82. #define NS_llmm "http://ll-plugins.nongnu.org/lv2/ext/midimap#"
  83. #define NS_mod "http://moddevices.com/ns/modgui#"
  84. #define LV2_MIDI_Map__CC "http://ll-plugins.nongnu.org/lv2/namespace#CC"
  85. #define LV2_MIDI_Map__NRPN "http://ll-plugins.nongnu.org/lv2/namespace#NRPN"
  86. #define LV2_MIDI_LL__MidiPort "http://ll-plugins.nongnu.org/lv2/ext/MidiPort"
  87. #define LV2_UI__Qt5UI LV2_UI_PREFIX "Qt5UI"
  88. #define LV2_UI__makeResident LV2_UI_PREFIX "makeResident"
  89. // -----------------------------------------------------------------------
  90. // Custom Atom types
  91. struct LV2_Atom_MidiEvent {
  92. LV2_Atom atom; /**< Atom header. */
  93. uint8_t data[4]; /**< MIDI data (body). */
  94. };
  95. static inline
  96. uint32_t lv2_atom_total_size(const LV2_Atom_MidiEvent& midiEv)
  97. {
  98. return static_cast<uint32_t>(sizeof(LV2_Atom)) + midiEv.atom.size;
  99. }
  100. // -----------------------------------------------------------------------
  101. // Our LV2 World class
  102. class Lv2WorldClass : public Lilv::World
  103. {
  104. public:
  105. // Base Types
  106. Lilv::Node port;
  107. Lilv::Node symbol;
  108. Lilv::Node designation;
  109. Lilv::Node freeWheeling;
  110. Lilv::Node reportsLatency;
  111. // Plugin Types
  112. Lilv::Node class_allpass;
  113. Lilv::Node class_amplifier;
  114. Lilv::Node class_analyzer;
  115. Lilv::Node class_bandpass;
  116. Lilv::Node class_chorus;
  117. Lilv::Node class_comb;
  118. Lilv::Node class_compressor;
  119. Lilv::Node class_constant;
  120. Lilv::Node class_converter;
  121. Lilv::Node class_delay;
  122. Lilv::Node class_distortion;
  123. Lilv::Node class_dynamics;
  124. Lilv::Node class_eq;
  125. Lilv::Node class_envelope;
  126. Lilv::Node class_expander;
  127. Lilv::Node class_filter;
  128. Lilv::Node class_flanger;
  129. Lilv::Node class_function;
  130. Lilv::Node class_gate;
  131. Lilv::Node class_generator;
  132. Lilv::Node class_highpass;
  133. Lilv::Node class_instrument;
  134. Lilv::Node class_limiter;
  135. Lilv::Node class_lowpass;
  136. Lilv::Node class_mixer;
  137. Lilv::Node class_modulator;
  138. Lilv::Node class_multiEQ;
  139. Lilv::Node class_oscillator;
  140. Lilv::Node class_paraEQ;
  141. Lilv::Node class_phaser;
  142. Lilv::Node class_pitch;
  143. Lilv::Node class_reverb;
  144. Lilv::Node class_simulator;
  145. Lilv::Node class_spatial;
  146. Lilv::Node class_spectral;
  147. Lilv::Node class_utility;
  148. Lilv::Node class_waveshaper;
  149. // Port Types
  150. Lilv::Node port_input;
  151. Lilv::Node port_output;
  152. Lilv::Node port_control;
  153. Lilv::Node port_audio;
  154. Lilv::Node port_cv;
  155. Lilv::Node port_atom;
  156. Lilv::Node port_event;
  157. Lilv::Node port_midi;
  158. // Port Properties
  159. Lilv::Node pprop_optional;
  160. Lilv::Node pprop_enumeration;
  161. Lilv::Node pprop_integer;
  162. Lilv::Node pprop_sampleRate;
  163. Lilv::Node pprop_toggled;
  164. Lilv::Node pprop_artifacts;
  165. Lilv::Node pprop_continuousCV;
  166. Lilv::Node pprop_discreteCV;
  167. Lilv::Node pprop_expensive;
  168. Lilv::Node pprop_strictBounds;
  169. Lilv::Node pprop_logarithmic;
  170. Lilv::Node pprop_notAutomatic;
  171. Lilv::Node pprop_notOnGUI;
  172. Lilv::Node pprop_trigger;
  173. Lilv::Node pprop_nonAutomable;
  174. // Unit Hints
  175. Lilv::Node unit_name;
  176. Lilv::Node unit_render;
  177. Lilv::Node unit_symbol;
  178. Lilv::Node unit_unit;
  179. // UI Types
  180. Lilv::Node ui_gtk2;
  181. Lilv::Node ui_gtk3;
  182. Lilv::Node ui_qt4;
  183. Lilv::Node ui_qt5;
  184. Lilv::Node ui_cocoa;
  185. Lilv::Node ui_windows;
  186. Lilv::Node ui_x11;
  187. Lilv::Node ui_external;
  188. Lilv::Node ui_externalOld;
  189. Lilv::Node ui_externalOld2;
  190. // Misc
  191. Lilv::Node atom_bufferType;
  192. Lilv::Node atom_sequence;
  193. Lilv::Node atom_supports;
  194. Lilv::Node preset_preset;
  195. Lilv::Node state_state;
  196. Lilv::Node value_default;
  197. Lilv::Node value_minimum;
  198. Lilv::Node value_maximum;
  199. Lilv::Node rz_asLargeAs;
  200. Lilv::Node rz_minSize;
  201. // Port Data Types
  202. Lilv::Node midi_event;
  203. Lilv::Node patch_message;
  204. Lilv::Node time_position;
  205. // MIDI CC
  206. Lilv::Node mm_defaultControl;
  207. Lilv::Node mm_controlType;
  208. Lilv::Node mm_controlNumber;
  209. // Other
  210. Lilv::Node dct_replaces;
  211. Lilv::Node doap_license;
  212. Lilv::Node rdf_type;
  213. Lilv::Node rdfs_label;
  214. bool needsInit;
  215. // -------------------------------------------------------------------
  216. Lv2WorldClass()
  217. : Lilv::World(),
  218. port (new_uri(LV2_CORE__port)),
  219. symbol (new_uri(LV2_CORE__symbol)),
  220. designation (new_uri(LV2_CORE__designation)),
  221. freeWheeling (new_uri(LV2_CORE__freeWheeling)),
  222. reportsLatency (new_uri(LV2_CORE__reportsLatency)),
  223. class_allpass (new_uri(LV2_CORE__AllpassPlugin)),
  224. class_amplifier (new_uri(LV2_CORE__AmplifierPlugin)),
  225. class_analyzer (new_uri(LV2_CORE__AnalyserPlugin)),
  226. class_bandpass (new_uri(LV2_CORE__BandpassPlugin)),
  227. class_chorus (new_uri(LV2_CORE__ChorusPlugin)),
  228. class_comb (new_uri(LV2_CORE__CombPlugin)),
  229. class_compressor (new_uri(LV2_CORE__CompressorPlugin)),
  230. class_constant (new_uri(LV2_CORE__ConstantPlugin)),
  231. class_converter (new_uri(LV2_CORE__ConverterPlugin)),
  232. class_delay (new_uri(LV2_CORE__DelayPlugin)),
  233. class_distortion (new_uri(LV2_CORE__DistortionPlugin)),
  234. class_dynamics (new_uri(LV2_CORE__DynamicsPlugin)),
  235. class_eq (new_uri(LV2_CORE__EQPlugin)),
  236. class_envelope (new_uri(LV2_CORE__EnvelopePlugin)),
  237. class_expander (new_uri(LV2_CORE__ExpanderPlugin)),
  238. class_filter (new_uri(LV2_CORE__FilterPlugin)),
  239. class_flanger (new_uri(LV2_CORE__FlangerPlugin)),
  240. class_function (new_uri(LV2_CORE__FunctionPlugin)),
  241. class_gate (new_uri(LV2_CORE__GatePlugin)),
  242. class_generator (new_uri(LV2_CORE__GeneratorPlugin)),
  243. class_highpass (new_uri(LV2_CORE__HighpassPlugin)),
  244. class_instrument (new_uri(LV2_CORE__InstrumentPlugin)),
  245. class_limiter (new_uri(LV2_CORE__LimiterPlugin)),
  246. class_lowpass (new_uri(LV2_CORE__LowpassPlugin)),
  247. class_mixer (new_uri(LV2_CORE__MixerPlugin)),
  248. class_modulator (new_uri(LV2_CORE__ModulatorPlugin)),
  249. class_multiEQ (new_uri(LV2_CORE__MultiEQPlugin)),
  250. class_oscillator (new_uri(LV2_CORE__OscillatorPlugin)),
  251. class_paraEQ (new_uri(LV2_CORE__ParaEQPlugin)),
  252. class_phaser (new_uri(LV2_CORE__PhaserPlugin)),
  253. class_pitch (new_uri(LV2_CORE__PitchPlugin)),
  254. class_reverb (new_uri(LV2_CORE__ReverbPlugin)),
  255. class_simulator (new_uri(LV2_CORE__SimulatorPlugin)),
  256. class_spatial (new_uri(LV2_CORE__SpatialPlugin)),
  257. class_spectral (new_uri(LV2_CORE__SpectralPlugin)),
  258. class_utility (new_uri(LV2_CORE__UtilityPlugin)),
  259. class_waveshaper (new_uri(LV2_CORE__WaveshaperPlugin)),
  260. port_input (new_uri(LV2_CORE__InputPort)),
  261. port_output (new_uri(LV2_CORE__OutputPort)),
  262. port_control (new_uri(LV2_CORE__ControlPort)),
  263. port_audio (new_uri(LV2_CORE__AudioPort)),
  264. port_cv (new_uri(LV2_CORE__CVPort)),
  265. port_atom (new_uri(LV2_ATOM__AtomPort)),
  266. port_event (new_uri(LV2_EVENT__EventPort)),
  267. port_midi (new_uri(LV2_MIDI_LL__MidiPort)),
  268. pprop_optional (new_uri(LV2_CORE__connectionOptional)),
  269. pprop_enumeration (new_uri(LV2_CORE__enumeration)),
  270. pprop_integer (new_uri(LV2_CORE__integer)),
  271. pprop_sampleRate (new_uri(LV2_CORE__sampleRate)),
  272. pprop_toggled (new_uri(LV2_CORE__toggled)),
  273. pprop_artifacts (new_uri(LV2_PORT_PROPS__causesArtifacts)),
  274. pprop_continuousCV (new_uri(LV2_PORT_PROPS__continuousCV)),
  275. pprop_discreteCV (new_uri(LV2_PORT_PROPS__discreteCV)),
  276. pprop_expensive (new_uri(LV2_PORT_PROPS__expensive)),
  277. pprop_strictBounds (new_uri(LV2_PORT_PROPS__hasStrictBounds)),
  278. pprop_logarithmic (new_uri(LV2_PORT_PROPS__logarithmic)),
  279. pprop_notAutomatic (new_uri(LV2_PORT_PROPS__notAutomatic)),
  280. pprop_notOnGUI (new_uri(LV2_PORT_PROPS__notOnGUI)),
  281. pprop_trigger (new_uri(LV2_PORT_PROPS__trigger)),
  282. pprop_nonAutomable (new_uri(LV2_KXSTUDIO_PROPERTIES__NonAutomable)),
  283. unit_name (new_uri(LV2_UNITS__name)),
  284. unit_render (new_uri(LV2_UNITS__render)),
  285. unit_symbol (new_uri(LV2_UNITS__symbol)),
  286. unit_unit (new_uri(LV2_UNITS__unit)),
  287. ui_gtk2 (new_uri(LV2_UI__GtkUI)),
  288. ui_gtk3 (new_uri(LV2_UI__Gtk3UI)),
  289. ui_qt4 (new_uri(LV2_UI__Qt4UI)),
  290. ui_qt5 (new_uri(LV2_UI__Qt5UI)),
  291. ui_cocoa (new_uri(LV2_UI__CocoaUI)),
  292. ui_windows (new_uri(LV2_UI__WindowsUI)),
  293. ui_x11 (new_uri(LV2_UI__X11UI)),
  294. ui_external (new_uri(LV2_EXTERNAL_UI__Widget)),
  295. ui_externalOld (new_uri(LV2_EXTERNAL_UI_DEPRECATED_URI)),
  296. ui_externalOld2 (new_uri("http://nedko.arnaudov.name/lv2/external_ui/")),
  297. atom_bufferType (new_uri(LV2_ATOM__bufferType)),
  298. atom_sequence (new_uri(LV2_ATOM__Sequence)),
  299. atom_supports (new_uri(LV2_ATOM__supports)),
  300. preset_preset (new_uri(LV2_PRESETS__Preset)),
  301. state_state (new_uri(LV2_STATE__state)),
  302. value_default (new_uri(LV2_CORE__default)),
  303. value_minimum (new_uri(LV2_CORE__minimum)),
  304. value_maximum (new_uri(LV2_CORE__maximum)),
  305. rz_asLargeAs (new_uri(LV2_RESIZE_PORT__asLargeAs)),
  306. rz_minSize (new_uri(LV2_RESIZE_PORT__minimumSize)),
  307. midi_event (new_uri(LV2_MIDI__MidiEvent)),
  308. patch_message (new_uri(LV2_PATCH__Message)),
  309. time_position (new_uri(LV2_TIME__Position)),
  310. mm_defaultControl (new_uri(NS_llmm "defaultMidiController")),
  311. mm_controlType (new_uri(NS_llmm "controllerType")),
  312. mm_controlNumber (new_uri(NS_llmm "controllerNumber")),
  313. dct_replaces (new_uri(NS_dct "replaces")),
  314. doap_license (new_uri(NS_doap "license")),
  315. rdf_type (new_uri(NS_rdf "type")),
  316. rdfs_label (new_uri(NS_rdfs "label")),
  317. needsInit(true) {}
  318. static Lv2WorldClass& getInstance()
  319. {
  320. static Lv2WorldClass lv2World;
  321. return lv2World;
  322. }
  323. void initIfNeeded(const char* const LV2_PATH)
  324. {
  325. CARLA_SAFE_ASSERT_RETURN(LV2_PATH != nullptr,);
  326. if (! needsInit)
  327. return;
  328. needsInit = false;
  329. Lilv::World::load_all(LV2_PATH);
  330. }
  331. void load_bundle(const char* const bundle)
  332. {
  333. CARLA_SAFE_ASSERT_RETURN(bundle != nullptr && bundle[0] != '\0',);
  334. needsInit = false;
  335. Lilv::World::load_bundle(Lilv::Node(new_uri(bundle)));
  336. }
  337. uint getPluginCount() const
  338. {
  339. CARLA_SAFE_ASSERT_RETURN(! needsInit, 0);
  340. const LilvPlugins* const cPlugins(lilv_world_get_all_plugins(this->me));
  341. CARLA_SAFE_ASSERT_RETURN(cPlugins != nullptr, 0);
  342. return lilv_plugins_size(cPlugins);
  343. }
  344. const LilvPlugin* getPluginFromIndex(const uint index) const
  345. {
  346. CARLA_SAFE_ASSERT_RETURN(! needsInit, nullptr);
  347. const LilvPlugins* const cPlugins(lilv_world_get_all_plugins(this->me));
  348. CARLA_SAFE_ASSERT_RETURN(cPlugins != nullptr, nullptr);
  349. uint32_t i=0;
  350. for (LilvIter *it = lilv_plugins_begin(cPlugins); ! lilv_plugins_is_end(cPlugins, it); it = lilv_plugins_next(cPlugins, it), ++i)
  351. {
  352. if (index != i)
  353. continue;
  354. return lilv_plugins_get(cPlugins, it);
  355. }
  356. return nullptr;
  357. }
  358. const LilvPlugin* getPluginFromURI(const LV2_URI uri) const
  359. {
  360. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);
  361. CARLA_SAFE_ASSERT_RETURN(! needsInit, nullptr);
  362. const LilvPlugins* const cPlugins(lilv_world_get_all_plugins(this->me));
  363. CARLA_SAFE_ASSERT_RETURN(cPlugins != nullptr, nullptr);
  364. LilvNode* const uriNode(lilv_new_uri(this->me, uri));
  365. CARLA_SAFE_ASSERT_RETURN(uriNode != nullptr, nullptr);
  366. const LilvPlugin* const cPlugin(lilv_plugins_get_by_uri(cPlugins, uriNode));
  367. lilv_node_free(uriNode);
  368. return cPlugin;
  369. }
  370. LilvState* getStateFromURI(const LV2_URI uri, const LV2_URID_Map* const uridMap) const
  371. {
  372. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);
  373. CARLA_SAFE_ASSERT_RETURN(uridMap != nullptr, nullptr);
  374. CARLA_SAFE_ASSERT_RETURN(! needsInit, nullptr);
  375. LilvNode* const uriNode(lilv_new_uri(this->me, uri));
  376. CARLA_SAFE_ASSERT_RETURN(uriNode != nullptr, nullptr);
  377. LilvState* const cState(lilv_state_new_from_world(this->me, uridMap, uriNode));
  378. lilv_node_free(uriNode);
  379. return cState;
  380. }
  381. CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION
  382. };
  383. // -----------------------------------------------------------------------
  384. // Create new RDF object (using lilv)
  385. static inline
  386. const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool loadPresets)
  387. {
  388. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);
  389. Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());
  390. const LilvPlugin* const cPlugin(lv2World.getPluginFromURI(uri));
  391. CARLA_SAFE_ASSERT_RETURN(cPlugin != nullptr, nullptr);
  392. Lilv::Plugin lilvPlugin(cPlugin);
  393. LV2_RDF_Descriptor* const rdfDescriptor(new LV2_RDF_Descriptor());
  394. // -------------------------------------------------------------------
  395. // Set Plugin Type
  396. {
  397. Lilv::Nodes typeNodes(lilvPlugin.get_value(lv2World.rdf_type));
  398. if (typeNodes.size() > 0)
  399. {
  400. if (typeNodes.contains(lv2World.class_allpass))
  401. rdfDescriptor->Type[0] |= LV2_PLUGIN_ALLPASS;
  402. if (typeNodes.contains(lv2World.class_amplifier))
  403. rdfDescriptor->Type[0] |= LV2_PLUGIN_AMPLIFIER;
  404. if (typeNodes.contains(lv2World.class_analyzer))
  405. rdfDescriptor->Type[1] |= LV2_PLUGIN_ANALYSER;
  406. if (typeNodes.contains(lv2World.class_bandpass))
  407. rdfDescriptor->Type[0] |= LV2_PLUGIN_BANDPASS;
  408. if (typeNodes.contains(lv2World.class_chorus))
  409. rdfDescriptor->Type[1] |= LV2_PLUGIN_CHORUS;
  410. if (typeNodes.contains(lv2World.class_comb))
  411. rdfDescriptor->Type[1] |= LV2_PLUGIN_COMB;
  412. if (typeNodes.contains(lv2World.class_compressor))
  413. rdfDescriptor->Type[0] |= LV2_PLUGIN_COMPRESSOR;
  414. if (typeNodes.contains(lv2World.class_constant))
  415. rdfDescriptor->Type[1] |= LV2_PLUGIN_CONSTANT;
  416. if (typeNodes.contains(lv2World.class_converter))
  417. rdfDescriptor->Type[1] |= LV2_PLUGIN_CONVERTER;
  418. if (typeNodes.contains(lv2World.class_delay))
  419. rdfDescriptor->Type[0] |= LV2_PLUGIN_DELAY;
  420. if (typeNodes.contains(lv2World.class_distortion))
  421. rdfDescriptor->Type[0] |= LV2_PLUGIN_DISTORTION;
  422. if (typeNodes.contains(lv2World.class_dynamics))
  423. rdfDescriptor->Type[0] |= LV2_PLUGIN_DYNAMICS;
  424. if (typeNodes.contains(lv2World.class_eq))
  425. rdfDescriptor->Type[0] |= LV2_PLUGIN_EQ;
  426. if (typeNodes.contains(lv2World.class_envelope))
  427. rdfDescriptor->Type[0] |= LV2_PLUGIN_ENVELOPE;
  428. if (typeNodes.contains(lv2World.class_expander))
  429. rdfDescriptor->Type[0] |= LV2_PLUGIN_EXPANDER;
  430. if (typeNodes.contains(lv2World.class_filter))
  431. rdfDescriptor->Type[0] |= LV2_PLUGIN_FILTER;
  432. if (typeNodes.contains(lv2World.class_flanger))
  433. rdfDescriptor->Type[1] |= LV2_PLUGIN_FLANGER;
  434. if (typeNodes.contains(lv2World.class_function))
  435. rdfDescriptor->Type[1] |= LV2_PLUGIN_FUNCTION;
  436. if (typeNodes.contains(lv2World.class_gate))
  437. rdfDescriptor->Type[0] |= LV2_PLUGIN_GATE;
  438. if (typeNodes.contains(lv2World.class_generator))
  439. rdfDescriptor->Type[1] |= LV2_PLUGIN_GENERATOR;
  440. if (typeNodes.contains(lv2World.class_highpass))
  441. rdfDescriptor->Type[0] |= LV2_PLUGIN_HIGHPASS;
  442. if (typeNodes.contains(lv2World.class_instrument))
  443. rdfDescriptor->Type[1] |= LV2_PLUGIN_INSTRUMENT;
  444. if (typeNodes.contains(lv2World.class_limiter))
  445. rdfDescriptor->Type[0] |= LV2_PLUGIN_LIMITER;
  446. if (typeNodes.contains(lv2World.class_lowpass))
  447. rdfDescriptor->Type[0] |= LV2_PLUGIN_LOWPASS;
  448. if (typeNodes.contains(lv2World.class_mixer))
  449. rdfDescriptor->Type[1] |= LV2_PLUGIN_MIXER;
  450. if (typeNodes.contains(lv2World.class_modulator))
  451. rdfDescriptor->Type[1] |= LV2_PLUGIN_MODULATOR;
  452. if (typeNodes.contains(lv2World.class_multiEQ))
  453. rdfDescriptor->Type[0] |= LV2_PLUGIN_MULTI_EQ;
  454. if (typeNodes.contains(lv2World.class_oscillator))
  455. rdfDescriptor->Type[1] |= LV2_PLUGIN_OSCILLATOR;
  456. if (typeNodes.contains(lv2World.class_paraEQ))
  457. rdfDescriptor->Type[0] |= LV2_PLUGIN_PARA_EQ;
  458. if (typeNodes.contains(lv2World.class_phaser))
  459. rdfDescriptor->Type[1] |= LV2_PLUGIN_PHASER;
  460. if (typeNodes.contains(lv2World.class_pitch))
  461. rdfDescriptor->Type[1] |= LV2_PLUGIN_PITCH;
  462. if (typeNodes.contains(lv2World.class_reverb))
  463. rdfDescriptor->Type[0] |= LV2_PLUGIN_REVERB;
  464. if (typeNodes.contains(lv2World.class_simulator))
  465. rdfDescriptor->Type[0] |= LV2_PLUGIN_SIMULATOR;
  466. if (typeNodes.contains(lv2World.class_spatial))
  467. rdfDescriptor->Type[1] |= LV2_PLUGIN_SPATIAL;
  468. if (typeNodes.contains(lv2World.class_spectral))
  469. rdfDescriptor->Type[1] |= LV2_PLUGIN_SPECTRAL;
  470. if (typeNodes.contains(lv2World.class_utility))
  471. rdfDescriptor->Type[1] |= LV2_PLUGIN_UTILITY;
  472. if (typeNodes.contains(lv2World.class_waveshaper))
  473. rdfDescriptor->Type[0] |= LV2_PLUGIN_WAVESHAPER;
  474. }
  475. lilv_nodes_free(const_cast<LilvNodes*>(typeNodes.me));
  476. }
  477. // -------------------------------------------------------------------
  478. // Set Plugin Information
  479. {
  480. rdfDescriptor->URI = carla_strdup(uri);
  481. if (const char* const name = lilvPlugin.get_name().as_string())
  482. rdfDescriptor->Name = carla_strdup(name);
  483. if (const char* const author = lilvPlugin.get_author_name().as_string())
  484. rdfDescriptor->Author = carla_strdup(author);
  485. if (const char* const binary = lilvPlugin.get_library_uri().as_string())
  486. rdfDescriptor->Binary = carla_strdup_free(lilv_file_uri_parse(binary, nullptr));
  487. if (const char* const bundle = lilvPlugin.get_bundle_uri().as_string())
  488. rdfDescriptor->Bundle = carla_strdup_free(lilv_file_uri_parse(bundle, nullptr));
  489. Lilv::Nodes licenseNodes(lilvPlugin.get_value(lv2World.doap_license));
  490. if (licenseNodes.size() > 0)
  491. {
  492. if (const char* const license = licenseNodes.get_first().as_string())
  493. rdfDescriptor->License = carla_strdup(license);
  494. }
  495. lilv_nodes_free(const_cast<LilvNodes*>(licenseNodes.me));
  496. }
  497. // -------------------------------------------------------------------
  498. // Set Plugin UniqueID
  499. {
  500. Lilv::Nodes replaceNodes(lilvPlugin.get_value(lv2World.dct_replaces));
  501. if (replaceNodes.size() > 0)
  502. {
  503. Lilv::Node replaceNode(replaceNodes.get_first());
  504. if (replaceNode.is_uri())
  505. {
  506. #ifdef USE_QT
  507. const QString replaceURI(replaceNode.as_uri());
  508. if (replaceURI.startsWith("urn:"))
  509. {
  510. const QString replaceId(replaceURI.split(":").last());
  511. bool ok;
  512. const ulong uniqueId(replaceId.toULong(&ok));
  513. if (ok && uniqueId != 0)
  514. rdfDescriptor->UniqueID = uniqueId;
  515. }
  516. #else
  517. const juce::String replaceURI(replaceNode.as_uri());
  518. if (replaceURI.startsWith("urn:"))
  519. {
  520. const int uniqueId(replaceURI.getTrailingIntValue());
  521. if (uniqueId > 0)
  522. rdfDescriptor->UniqueID = static_cast<ulong>(uniqueId);
  523. }
  524. #endif
  525. }
  526. }
  527. lilv_nodes_free(const_cast<LilvNodes*>(replaceNodes.me));
  528. }
  529. // -------------------------------------------------------------------
  530. // Set Plugin Ports
  531. if (lilvPlugin.get_num_ports() > 0)
  532. {
  533. rdfDescriptor->PortCount = lilvPlugin.get_num_ports();
  534. rdfDescriptor->Ports = new LV2_RDF_Port[rdfDescriptor->PortCount];
  535. for (uint32_t i = 0; i < rdfDescriptor->PortCount; ++i)
  536. {
  537. Lilv::Port lilvPort(lilvPlugin.get_port_by_index(i));
  538. LV2_RDF_Port* const rdfPort(&rdfDescriptor->Ports[i]);
  539. // -----------------------------------------------------------
  540. // Set Port Information
  541. {
  542. if (const char* const name = Lilv::Node(lilvPort.get_name()).as_string())
  543. rdfPort->Name = carla_strdup(name);
  544. if (const char* const symbol = Lilv::Node(lilvPort.get_symbol()).as_string())
  545. rdfPort->Symbol = carla_strdup(symbol);
  546. }
  547. // -----------------------------------------------------------
  548. // Set Port Mode and Type
  549. {
  550. // Input or Output
  551. /**/ if (lilvPort.is_a(lv2World.port_input))
  552. rdfPort->Types |= LV2_PORT_INPUT;
  553. else if (lilvPort.is_a(lv2World.port_output))
  554. rdfPort->Types |= LV2_PORT_OUTPUT;
  555. else
  556. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is not input or output", uri, rdfPort->Name);
  557. // Data Type
  558. /**/ if (lilvPort.is_a(lv2World.port_control))
  559. {
  560. rdfPort->Types |= LV2_PORT_CONTROL;
  561. }
  562. else if (lilvPort.is_a(lv2World.port_audio))
  563. {
  564. rdfPort->Types |= LV2_PORT_AUDIO;
  565. }
  566. else if (lilvPort.is_a(lv2World.port_cv))
  567. {
  568. rdfPort->Types |= LV2_PORT_CV;
  569. }
  570. else if (lilvPort.is_a(lv2World.port_atom))
  571. {
  572. rdfPort->Types |= LV2_PORT_ATOM;
  573. Lilv::Nodes bufferTypeNodes(lilvPort.get_value(lv2World.atom_bufferType));
  574. for (LilvIter* it = lilv_nodes_begin(bufferTypeNodes.me); ! lilv_nodes_is_end(bufferTypeNodes.me, it); it = lilv_nodes_next(bufferTypeNodes.me, it))
  575. {
  576. const Lilv::Node node(lilv_nodes_get(bufferTypeNodes.me, it));
  577. CARLA_SAFE_ASSERT_CONTINUE(node.is_uri());
  578. if (node.equals(lv2World.atom_sequence))
  579. rdfPort->Types |= LV2_PORT_ATOM_SEQUENCE;
  580. else
  581. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses an unknown atom buffer type '%s'", uri, rdfPort->Name, node.as_uri());
  582. }
  583. Lilv::Nodes supportNodes(lilvPort.get_value(lv2World.atom_supports));
  584. for (LilvIter* it = lilv_nodes_begin(supportNodes.me); ! lilv_nodes_is_end(supportNodes.me, it); it = lilv_nodes_next(supportNodes.me, it))
  585. {
  586. const Lilv::Node node(lilv_nodes_get(supportNodes.me, it));
  587. CARLA_SAFE_ASSERT_CONTINUE(node.is_uri());
  588. /**/ if (node.equals(lv2World.midi_event))
  589. rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
  590. else if (node.equals(lv2World.patch_message))
  591. rdfPort->Types |= LV2_PORT_DATA_PATCH_MESSAGE;
  592. else if (node.equals(lv2World.time_position))
  593. rdfPort->Types |= LV2_PORT_DATA_TIME_POSITION;
  594. #if 0
  595. // something new we don't support yet?
  596. else if (std::strstr(node.as_uri(), "lv2plug.in/") != nullptr)
  597. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of atom type but has unsupported data '%s'", uri, rdfPort->Name, node.as_uri());
  598. #endif
  599. }
  600. lilv_nodes_free(const_cast<LilvNodes*>(bufferTypeNodes.me));
  601. lilv_nodes_free(const_cast<LilvNodes*>(supportNodes.me));
  602. }
  603. else if (lilvPort.is_a(lv2World.port_event))
  604. {
  605. rdfPort->Types |= LV2_PORT_EVENT;
  606. bool supported = false;
  607. if (lilvPort.supports_event(lv2World.midi_event))
  608. {
  609. rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
  610. supported = true;
  611. }
  612. if (lilvPort.supports_event(lv2World.patch_message))
  613. {
  614. rdfPort->Types |= LV2_PORT_DATA_PATCH_MESSAGE;
  615. supported = true;
  616. }
  617. if (lilvPort.supports_event(lv2World.time_position))
  618. {
  619. rdfPort->Types |= LV2_PORT_DATA_TIME_POSITION;
  620. supported = true;
  621. }
  622. if (! supported)
  623. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of event type but has unsupported data", uri, rdfPort->Name);
  624. }
  625. else if (lilvPort.is_a(lv2World.port_midi))
  626. {
  627. rdfPort->Types |= LV2_PORT_MIDI_LL;
  628. rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
  629. }
  630. else
  631. carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of unkown data type", uri, rdfPort->Name);
  632. }
  633. // -----------------------------------------------------------
  634. // Set Port Properties
  635. {
  636. if (lilvPort.has_property(lv2World.pprop_optional))
  637. rdfPort->Properties |= LV2_PORT_OPTIONAL;
  638. if (lilvPort.has_property(lv2World.pprop_enumeration))
  639. rdfPort->Properties |= LV2_PORT_ENUMERATION;
  640. if (lilvPort.has_property(lv2World.pprop_integer))
  641. rdfPort->Properties |= LV2_PORT_INTEGER;
  642. if (lilvPort.has_property(lv2World.pprop_sampleRate))
  643. rdfPort->Properties |= LV2_PORT_SAMPLE_RATE;
  644. if (lilvPort.has_property(lv2World.pprop_toggled))
  645. rdfPort->Properties |= LV2_PORT_TOGGLED;
  646. if (lilvPort.has_property(lv2World.pprop_artifacts))
  647. rdfPort->Properties |= LV2_PORT_CAUSES_ARTIFACTS;
  648. if (lilvPort.has_property(lv2World.pprop_continuousCV))
  649. rdfPort->Properties |= LV2_PORT_CONTINUOUS_CV;
  650. if (lilvPort.has_property(lv2World.pprop_discreteCV))
  651. rdfPort->Properties |= LV2_PORT_DISCRETE_CV;
  652. if (lilvPort.has_property(lv2World.pprop_expensive))
  653. rdfPort->Properties |= LV2_PORT_EXPENSIVE;
  654. if (lilvPort.has_property(lv2World.pprop_strictBounds))
  655. rdfPort->Properties |= LV2_PORT_STRICT_BOUNDS;
  656. if (lilvPort.has_property(lv2World.pprop_logarithmic))
  657. rdfPort->Properties |= LV2_PORT_LOGARITHMIC;
  658. if (lilvPort.has_property(lv2World.pprop_notAutomatic))
  659. rdfPort->Properties |= LV2_PORT_NOT_AUTOMATIC;
  660. if (lilvPort.has_property(lv2World.pprop_notOnGUI))
  661. rdfPort->Properties |= LV2_PORT_NOT_ON_GUI;
  662. if (lilvPort.has_property(lv2World.pprop_trigger))
  663. rdfPort->Properties |= LV2_PORT_TRIGGER;
  664. if (lilvPort.has_property(lv2World.pprop_nonAutomable))
  665. rdfPort->Properties |= LV2_PORT_NON_AUTOMABLE;
  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. const Lilv::Node oldPropArtifacts(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#causesArtifacts"));
  672. const Lilv::Node oldPropContinuousCV(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#continuousCV"));
  673. const Lilv::Node oldPropDiscreteCV(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#discreteCV"));
  674. const Lilv::Node oldPropExpensive(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#expensive"));
  675. const Lilv::Node oldPropStrictBounds(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#hasStrictBounds"));
  676. const Lilv::Node oldPropLogarithmic(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#logarithmic"));
  677. const Lilv::Node oldPropNotAutomatic(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#notAutomatic"));
  678. const Lilv::Node oldPropNotOnGUI(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#notOnGUI"));
  679. 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::strcmp(designation, LV2_KXSTUDIO_PROPERTIES__TimePositionTicksPerBeat) == 0)
  761. rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_TICKS_PER_BEAT;
  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. if (LilvNode* const unitNameNode = lilv_world_get(lv2World.me, unitUnitNode, lv2World.unit_name.me, nullptr))
  886. {
  887. if (const char* const unitName = lilv_node_as_string(unitNameNode))
  888. {
  889. rdfPort->Unit.Hints |= LV2_PORT_UNIT_NAME;
  890. rdfPort->Unit.Name = carla_strdup(unitName);
  891. }
  892. lilv_node_free(unitNameNode);
  893. }
  894. if (LilvNode* const unitRenderNode = lilv_world_get(lv2World.me, unitUnitNode, lv2World.unit_render.me, nullptr))
  895. {
  896. if (const char* const unitRender = lilv_node_as_string(unitRenderNode))
  897. {
  898. rdfPort->Unit.Hints |= LV2_PORT_UNIT_RENDER;
  899. rdfPort->Unit.Render = carla_strdup(unitRender);
  900. }
  901. lilv_node_free(unitRenderNode);
  902. }
  903. if (LilvNode* const unitSymbolNode = lilv_world_get(lv2World.me, unitUnitNode, lv2World.unit_symbol.me, nullptr))
  904. {
  905. if (const char* const unitSymbol = lilv_node_as_string(unitSymbolNode))
  906. {
  907. rdfPort->Unit.Hints |= LV2_PORT_UNIT_SYMBOL;
  908. rdfPort->Unit.Symbol = carla_strdup(unitSymbol);
  909. }
  910. lilv_node_free(unitSymbolNode);
  911. }
  912. lilv_node_free(unitUnitNode);
  913. }
  914. }
  915. // -----------------------------------------------------------
  916. // Set Port Minimum Size
  917. {
  918. if (LilvNode* const minimumSizeNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.rz_minSize.me))
  919. {
  920. const int minimumSize(lilv_node_as_int(minimumSizeNode));
  921. if (minimumSize > 0)
  922. rdfPort->MinimumSize = static_cast<uint32_t>(minimumSize);
  923. else
  924. carla_safe_assert_int("minimumSize > 0", __FILE__, __LINE__, minimumSize);
  925. lilv_node_free(minimumSizeNode);
  926. }
  927. }
  928. // -----------------------------------------------------------
  929. // Set Port Scale Points
  930. {
  931. Lilv::ScalePoints lilvScalePoints(lilvPort.get_scale_points());
  932. if (lilvScalePoints.size() > 0)
  933. {
  934. rdfPort->ScalePointCount = lilvScalePoints.size();
  935. rdfPort->ScalePoints = new LV2_RDF_PortScalePoint[rdfPort->ScalePointCount];
  936. uint32_t h = 0;
  937. LILV_FOREACH(scale_points, it, lilvScalePoints)
  938. {
  939. CARLA_SAFE_ASSERT_BREAK(h < rdfPort->ScalePointCount);
  940. Lilv::ScalePoint lilvScalePoint(lilvScalePoints.get(it));
  941. LV2_RDF_PortScalePoint* const rdfScalePoint(&rdfPort->ScalePoints[h++]);
  942. if (const char* const label = Lilv::Node(lilvScalePoint.get_label()).as_string())
  943. rdfScalePoint->Label = carla_strdup(label);
  944. rdfScalePoint->Value = Lilv::Node(lilvScalePoint.get_value()).as_float();
  945. }
  946. }
  947. lilv_nodes_free(const_cast<LilvNodes*>(lilvScalePoints.me));
  948. }
  949. }
  950. }
  951. // -------------------------------------------------------------------
  952. // Set Plugin Presets
  953. if (loadPresets)
  954. {
  955. Lilv::Nodes presetNodes(lilvPlugin.get_related(lv2World.preset_preset));
  956. if (presetNodes.size() > 0)
  957. {
  958. // create a list of preset URIs (for checking appliesTo, sorting and unique-ness)
  959. // FIXME - check appliesTo?
  960. #ifdef USE_QT
  961. QStringList presetListURIs;
  962. LILV_FOREACH(nodes, it, presetNodes)
  963. {
  964. Lilv::Node presetNode(presetNodes.get(it));
  965. QString presetURI(presetNode.as_uri());
  966. if (! (presetURI.trimmed().isEmpty() || presetListURIs.contains(presetURI)))
  967. presetListURIs.append(presetURI);
  968. }
  969. presetListURIs.sort();
  970. rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.count());
  971. #else
  972. juce::StringArray presetListURIs;
  973. LILV_FOREACH(nodes, it, presetNodes)
  974. {
  975. Lilv::Node presetNode(presetNodes.get(it));
  976. juce::String presetURI(presetNode.as_uri());
  977. if (presetURI.trim().isNotEmpty())
  978. presetListURIs.addIfNotAlreadyThere(presetURI);
  979. }
  980. presetListURIs.sortNatural();
  981. rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.size());
  982. #endif
  983. // create presets with unique URIs
  984. rdfDescriptor->Presets = new LV2_RDF_Preset[rdfDescriptor->PresetCount];
  985. // set preset data
  986. LILV_FOREACH(nodes, it, presetNodes)
  987. {
  988. Lilv::Node presetNode(presetNodes.get(it));
  989. if (lv2World.load_resource(presetNode) == -1)
  990. continue;
  991. if (const char* const presetURI = presetNode.as_uri())
  992. {
  993. #ifdef USE_QT
  994. const int index(presetListURIs.indexOf(QString(presetURI)));
  995. #else
  996. const int index(presetListURIs.indexOf(juce::String(presetURI)));
  997. #endif
  998. CARLA_SAFE_ASSERT_CONTINUE(index >= 0);
  999. LV2_RDF_Preset* const rdfPreset(&rdfDescriptor->Presets[index]);
  1000. // ---------------------------------------------------
  1001. // Set Preset Information
  1002. {
  1003. rdfPreset->URI = carla_strdup(presetURI);
  1004. Lilv::Nodes presetLabelNodes(lv2World.find_nodes(presetNode, lv2World.rdfs_label, nullptr));
  1005. if (presetLabelNodes.size() > 0)
  1006. {
  1007. if (const char* const label = presetLabelNodes.get_first().as_string())
  1008. rdfPreset->Label = carla_strdup(label);
  1009. }
  1010. lilv_nodes_free(const_cast<LilvNodes*>(presetLabelNodes.me));
  1011. }
  1012. }
  1013. }
  1014. }
  1015. lilv_nodes_free(const_cast<LilvNodes*>(presetNodes.me));
  1016. }
  1017. // -------------------------------------------------------------------
  1018. // Set Plugin Features
  1019. {
  1020. Lilv::Nodes lilvFeatureNodes(lilvPlugin.get_supported_features());
  1021. if (lilvFeatureNodes.size() > 0)
  1022. {
  1023. Lilv::Nodes lilvFeatureNodesR(lilvPlugin.get_required_features());
  1024. rdfDescriptor->FeatureCount = lilvFeatureNodes.size();
  1025. rdfDescriptor->Features = new LV2_RDF_Feature[rdfDescriptor->FeatureCount];
  1026. uint32_t h = 0;
  1027. LILV_FOREACH(nodes, it, lilvFeatureNodes)
  1028. {
  1029. CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->FeatureCount);
  1030. Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(it));
  1031. LV2_RDF_Feature* const rdfFeature(&rdfDescriptor->Features[h++]);
  1032. rdfFeature->Required = lilvFeatureNodesR.contains(lilvFeatureNode);
  1033. if (const char* const featureURI = lilvFeatureNode.as_uri())
  1034. rdfFeature->URI = carla_strdup(featureURI);
  1035. else
  1036. rdfFeature->URI = nullptr;
  1037. }
  1038. lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodesR.me));
  1039. }
  1040. lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodes.me));
  1041. }
  1042. // -------------------------------------------------------------------
  1043. // Set Plugin Extensions
  1044. {
  1045. Lilv::Nodes lilvExtensionDataNodes(lilvPlugin.get_extension_data());
  1046. if (lilvExtensionDataNodes.size() > 0)
  1047. {
  1048. rdfDescriptor->ExtensionCount = lilvExtensionDataNodes.size();
  1049. rdfDescriptor->Extensions = new LV2_URI[rdfDescriptor->ExtensionCount];
  1050. uint32_t h = 0;
  1051. LILV_FOREACH(nodes, it, lilvExtensionDataNodes)
  1052. {
  1053. CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->ExtensionCount);
  1054. Lilv::Node lilvExtensionDataNode(lilvExtensionDataNodes.get(it));
  1055. LV2_URI* const rdfExtension(&rdfDescriptor->Extensions[h++]);
  1056. if (lilvExtensionDataNode.is_uri())
  1057. {
  1058. if (const char* const extURI = lilvExtensionDataNode.as_uri())
  1059. {
  1060. *rdfExtension = carla_strdup(extURI);
  1061. continue;
  1062. }
  1063. }
  1064. *rdfExtension = nullptr;
  1065. }
  1066. for (uint32_t x=h; x < rdfDescriptor->ExtensionCount; ++x)
  1067. rdfDescriptor->Extensions[x] = nullptr;
  1068. }
  1069. lilv_nodes_free(const_cast<LilvNodes*>(lilvExtensionDataNodes.me));
  1070. }
  1071. // -------------------------------------------------------------------
  1072. // Set Plugin UIs
  1073. {
  1074. const bool hasMODGui(lilvPlugin.get_modgui_resources_directory().as_uri() != nullptr);
  1075. Lilv::UIs lilvUIs(lilvPlugin.get_uis());
  1076. if (lilvUIs.size() > 0 || hasMODGui)
  1077. {
  1078. rdfDescriptor->UICount = lilvUIs.size() + (hasMODGui ? 1 : 0);
  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_free(lilv_file_uri_parse(uiBinary, nullptr));
  1117. if (const char* const uiBundle = lilvUI.get_bundle_uri().as_string())
  1118. rdfUI->Bundle = carla_strdup_free(lilv_file_uri_parse(uiBundle, nullptr));
  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->Required = lilvFeatureNodesR.contains(lilvFeatureNode);
  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. for (; hasMODGui;)
  1176. {
  1177. CARLA_SAFE_ASSERT_BREAK(h == rdfDescriptor->UICount-1);
  1178. LV2_RDF_UI* const rdfUI(&rdfDescriptor->UIs[h++]);
  1179. // -------------------------------------------------------
  1180. // Set UI Type
  1181. rdfUI->Type = LV2_UI_MOD;
  1182. // -------------------------------------------------------
  1183. // Set UI Information
  1184. if (const char* const resDir = lilvPlugin.get_modgui_resources_directory().as_uri())
  1185. rdfUI->URI = carla_strdup_free(lilv_file_uri_parse(resDir, nullptr));
  1186. if (rdfDescriptor->Bundle != nullptr)
  1187. rdfUI->Bundle = carla_strdup(rdfDescriptor->Bundle);
  1188. break;
  1189. }
  1190. }
  1191. lilv_nodes_free(const_cast<LilvNodes*>(lilvUIs.me));
  1192. }
  1193. return rdfDescriptor;
  1194. }
  1195. // -----------------------------------------------------------------------
  1196. // Check if we support a plugin port
  1197. static inline
  1198. bool is_lv2_port_supported(const LV2_Property types) noexcept
  1199. {
  1200. if (LV2_IS_PORT_CONTROL(types))
  1201. return true;
  1202. if (LV2_IS_PORT_AUDIO(types))
  1203. return true;
  1204. if (LV2_IS_PORT_CV(types))
  1205. return true;
  1206. if (LV2_IS_PORT_ATOM_SEQUENCE(types))
  1207. return true;
  1208. if (LV2_IS_PORT_EVENT(types))
  1209. return true;
  1210. if (LV2_IS_PORT_MIDI_LL(types))
  1211. return true;
  1212. return false;
  1213. }
  1214. // -----------------------------------------------------------------------
  1215. // Check if we support a plugin feature
  1216. static inline
  1217. bool is_lv2_feature_supported(const LV2_URI uri) noexcept
  1218. {
  1219. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', false);
  1220. if (std::strcmp(uri, LV2_BUF_SIZE__boundedBlockLength) == 0)
  1221. return true;
  1222. if (std::strcmp(uri, LV2_BUF_SIZE__fixedBlockLength) == 0)
  1223. return true;
  1224. if (std::strcmp(uri, LV2_BUF_SIZE__powerOf2BlockLength) == 0)
  1225. return true;
  1226. if (std::strcmp(uri, LV2_CORE__hardRTCapable) == 0)
  1227. return true;
  1228. if (std::strcmp(uri, LV2_CORE__inPlaceBroken) == 0)
  1229. return true;
  1230. if (std::strcmp(uri, LV2_CORE__isLive) == 0)
  1231. return true;
  1232. if (std::strcmp(uri, LV2_EVENT_URI) == 0)
  1233. return true;
  1234. if (std::strcmp(uri, LV2_LOG__log) == 0)
  1235. return true;
  1236. if (std::strcmp(uri, LV2_OPTIONS__options) == 0)
  1237. return true;
  1238. if (std::strcmp(uri, LV2_PROGRAMS__Host) == 0)
  1239. return true;
  1240. if (std::strcmp(uri, LV2_RESIZE_PORT__resize) == 0)
  1241. return true;
  1242. if (std::strcmp(uri, LV2_RTSAFE_MEMORY_POOL__Pool) == 0)
  1243. return true;
  1244. if (std::strcmp(uri, LV2_RTSAFE_MEMORY_POOL_DEPRECATED_URI) == 0)
  1245. return true;
  1246. if (std::strcmp(uri, LV2_STATE__makePath) == 0)
  1247. return true;
  1248. if (std::strcmp(uri, LV2_STATE__mapPath) == 0)
  1249. return true;
  1250. if (std::strcmp(uri, LV2_PORT_PROPS__supportsStrictBounds) == 0)
  1251. return true;
  1252. if (std::strcmp(uri, LV2_URI_MAP_URI) == 0)
  1253. return true;
  1254. if (std::strcmp(uri, LV2_URID__map) == 0)
  1255. return true;
  1256. if (std::strcmp(uri, LV2_URID__unmap) == 0)
  1257. return true;
  1258. if (std::strcmp(uri, LV2_WORKER__schedule) == 0)
  1259. return true;
  1260. return false;
  1261. }
  1262. // -----------------------------------------------------------------------
  1263. // Check if we support a plugin or UI feature
  1264. static inline
  1265. bool is_lv2_ui_feature_supported(const LV2_URI uri) noexcept
  1266. {
  1267. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', false);
  1268. if (is_lv2_feature_supported(uri))
  1269. return true;
  1270. #ifndef BUILD_BRIDGE_UI
  1271. if (std::strcmp(uri, LV2_DATA_ACCESS_URI) == 0)
  1272. return true;
  1273. if (std::strcmp(uri, LV2_INSTANCE_ACCESS_URI) == 0)
  1274. return true;
  1275. #endif
  1276. if (std::strcmp(uri, LV2_UI__fixedSize) == 0)
  1277. return true;
  1278. if (std::strcmp(uri, LV2_UI__idleInterface) == 0)
  1279. return true;
  1280. if (std::strcmp(uri, LV2_UI__makeResident) == 0)
  1281. return true;
  1282. if (std::strcmp(uri, LV2_UI__noUserResize) == 0)
  1283. return true;
  1284. if (std::strcmp(uri, LV2_UI__parent) == 0)
  1285. return true;
  1286. if (std::strcmp(uri, LV2_UI__portMap) == 0)
  1287. return true;
  1288. if (std::strcmp(uri, LV2_UI__portSubscribe) == 0)
  1289. return true;
  1290. if (std::strcmp(uri, LV2_UI__resize) == 0)
  1291. return true;
  1292. if (std::strcmp(uri, LV2_UI__touch) == 0)
  1293. return true;
  1294. if (std::strcmp(uri, LV2_EXTERNAL_UI__Widget) == 0)
  1295. return true;
  1296. if (std::strcmp(uri, LV2_EXTERNAL_UI_DEPRECATED_URI) == 0)
  1297. return true;
  1298. return false;
  1299. }
  1300. // -----------------------------------------------------------------------
  1301. #endif // CARLA_LV2_UTILS_HPP_INCLUDED