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.

1540 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://portalmod.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(lilv_uri_to_path(binary));
  487. if (const char* const bundle = lilvPlugin.get_bundle_uri().as_string())
  488. rdfDescriptor->Bundle = carla_strdup(lilv_uri_to_path(bundle));
  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. 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::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. lilv_node_free(unitUnitNode);
  886. }
  887. // FIXME
  888. if (LilvNode* const unitNameNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.unit_name.me))
  889. {
  890. if (const char* const unitName = lilv_node_as_string(unitNameNode))
  891. {
  892. rdfPort->Unit.Hints |= LV2_PORT_UNIT_NAME;
  893. rdfPort->Unit.Name = carla_strdup(unitName);
  894. }
  895. lilv_node_free(unitNameNode);
  896. }
  897. if (LilvNode* const unitRenderNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.unit_render.me))
  898. {
  899. if (const char* const unitRender = lilv_node_as_string(unitRenderNode))
  900. {
  901. rdfPort->Unit.Hints |= LV2_PORT_UNIT_RENDER;
  902. rdfPort->Unit.Render = carla_strdup(unitRender);
  903. }
  904. lilv_node_free(unitRenderNode);
  905. }
  906. if (LilvNode* const unitSymbolNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.unit_symbol.me))
  907. {
  908. if (const char* const unitSymbol = lilv_node_as_string(unitSymbolNode))
  909. {
  910. rdfPort->Unit.Hints |= LV2_PORT_UNIT_SYMBOL;
  911. rdfPort->Unit.Symbol = carla_strdup(unitSymbol);
  912. }
  913. lilv_node_free(unitSymbolNode);
  914. }
  915. }
  916. // -----------------------------------------------------------
  917. // Set Port Minimum Size
  918. {
  919. if (LilvNode* const minimumSizeNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.rz_minSize.me))
  920. {
  921. const int minimumSize(lilv_node_as_int(minimumSizeNode));
  922. if (minimumSize > 0)
  923. rdfPort->MinimumSize = static_cast<uint32_t>(minimumSize);
  924. else
  925. carla_safe_assert_int("minimumSize > 0", __FILE__, __LINE__, minimumSize);
  926. lilv_node_free(minimumSizeNode);
  927. }
  928. }
  929. // -----------------------------------------------------------
  930. // Set Port Scale Points
  931. {
  932. Lilv::ScalePoints lilvScalePoints(lilvPort.get_scale_points());
  933. if (lilvScalePoints.size() > 0)
  934. {
  935. rdfPort->ScalePointCount = lilvScalePoints.size();
  936. rdfPort->ScalePoints = new LV2_RDF_PortScalePoint[rdfPort->ScalePointCount];
  937. uint32_t h = 0;
  938. LILV_FOREACH(scale_points, it, lilvScalePoints)
  939. {
  940. CARLA_SAFE_ASSERT_BREAK(h < rdfPort->ScalePointCount);
  941. Lilv::ScalePoint lilvScalePoint(lilvScalePoints.get(it));
  942. LV2_RDF_PortScalePoint* const rdfScalePoint(&rdfPort->ScalePoints[h++]);
  943. if (const char* const label = Lilv::Node(lilvScalePoint.get_label()).as_string())
  944. rdfScalePoint->Label = carla_strdup(label);
  945. rdfScalePoint->Value = Lilv::Node(lilvScalePoint.get_value()).as_float();
  946. }
  947. }
  948. lilv_nodes_free(const_cast<LilvNodes*>(lilvScalePoints.me));
  949. }
  950. }
  951. }
  952. // -------------------------------------------------------------------
  953. // Set Plugin Presets
  954. if (loadPresets)
  955. {
  956. Lilv::Nodes presetNodes(lilvPlugin.get_related(lv2World.preset_preset));
  957. if (presetNodes.size() > 0)
  958. {
  959. // create a list of preset URIs (for checking appliesTo, sorting and unique-ness)
  960. // FIXME - check appliesTo?
  961. #ifdef USE_QT
  962. QStringList presetListURIs;
  963. LILV_FOREACH(nodes, it, presetNodes)
  964. {
  965. Lilv::Node presetNode(presetNodes.get(it));
  966. QString presetURI(presetNode.as_uri());
  967. if (! (presetURI.trimmed().isEmpty() || presetListURIs.contains(presetURI)))
  968. presetListURIs.append(presetURI);
  969. }
  970. presetListURIs.sort();
  971. rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.count());
  972. #else
  973. juce::StringArray presetListURIs;
  974. LILV_FOREACH(nodes, it, presetNodes)
  975. {
  976. Lilv::Node presetNode(presetNodes.get(it));
  977. juce::String presetURI(presetNode.as_uri());
  978. if (presetURI.trim().isNotEmpty())
  979. presetListURIs.addIfNotAlreadyThere(presetURI);
  980. }
  981. presetListURIs.sortNatural();
  982. rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.size());
  983. #endif
  984. // create presets with unique URIs
  985. rdfDescriptor->Presets = new LV2_RDF_Preset[rdfDescriptor->PresetCount];
  986. // set preset data
  987. LILV_FOREACH(nodes, it, presetNodes)
  988. {
  989. Lilv::Node presetNode(presetNodes.get(it));
  990. if (lv2World.load_resource(presetNode) == -1)
  991. continue;
  992. if (const char* const presetURI = presetNode.as_uri())
  993. {
  994. #ifdef USE_QT
  995. const int index(presetListURIs.indexOf(QString(presetURI)));
  996. #else
  997. const int index(presetListURIs.indexOf(juce::String(presetURI)));
  998. #endif
  999. CARLA_SAFE_ASSERT_CONTINUE(index >= 0);
  1000. LV2_RDF_Preset* const rdfPreset(&rdfDescriptor->Presets[index]);
  1001. // ---------------------------------------------------
  1002. // Set Preset Information
  1003. {
  1004. rdfPreset->URI = carla_strdup(presetURI);
  1005. Lilv::Nodes presetLabelNodes(lv2World.find_nodes(presetNode, lv2World.rdfs_label, nullptr));
  1006. if (presetLabelNodes.size() > 0)
  1007. {
  1008. if (const char* const label = presetLabelNodes.get_first().as_string())
  1009. rdfPreset->Label = carla_strdup(label);
  1010. }
  1011. lilv_nodes_free(const_cast<LilvNodes*>(presetLabelNodes.me));
  1012. }
  1013. }
  1014. }
  1015. }
  1016. lilv_nodes_free(const_cast<LilvNodes*>(presetNodes.me));
  1017. }
  1018. // -------------------------------------------------------------------
  1019. // Set Plugin Features
  1020. {
  1021. Lilv::Nodes lilvFeatureNodes(lilvPlugin.get_supported_features());
  1022. if (lilvFeatureNodes.size() > 0)
  1023. {
  1024. Lilv::Nodes lilvFeatureNodesR(lilvPlugin.get_required_features());
  1025. rdfDescriptor->FeatureCount = lilvFeatureNodes.size();
  1026. rdfDescriptor->Features = new LV2_RDF_Feature[rdfDescriptor->FeatureCount];
  1027. uint32_t h = 0;
  1028. LILV_FOREACH(nodes, it, lilvFeatureNodes)
  1029. {
  1030. CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->FeatureCount);
  1031. Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(it));
  1032. LV2_RDF_Feature* const rdfFeature(&rdfDescriptor->Features[h++]);
  1033. rdfFeature->Type = lilvFeatureNodesR.contains(lilvFeatureNode) ? LV2_FEATURE_REQUIRED : LV2_FEATURE_OPTIONAL;
  1034. if (const char* const featureURI = lilvFeatureNode.as_uri())
  1035. rdfFeature->URI = carla_strdup(featureURI);
  1036. else
  1037. rdfFeature->URI = nullptr;
  1038. }
  1039. lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodesR.me));
  1040. }
  1041. lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodes.me));
  1042. }
  1043. // -------------------------------------------------------------------
  1044. // Set Plugin Extensions
  1045. {
  1046. Lilv::Nodes lilvExtensionDataNodes(lilvPlugin.get_extension_data());
  1047. if (lilvExtensionDataNodes.size() > 0)
  1048. {
  1049. rdfDescriptor->ExtensionCount = lilvExtensionDataNodes.size();
  1050. rdfDescriptor->Extensions = new LV2_URI[rdfDescriptor->ExtensionCount];
  1051. uint32_t h = 0;
  1052. LILV_FOREACH(nodes, it, lilvExtensionDataNodes)
  1053. {
  1054. CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->ExtensionCount);
  1055. Lilv::Node lilvExtensionDataNode(lilvExtensionDataNodes.get(it));
  1056. LV2_URI* const rdfExtension(&rdfDescriptor->Extensions[h++]);
  1057. if (lilvExtensionDataNode.is_uri())
  1058. {
  1059. if (const char* const extURI = lilvExtensionDataNode.as_uri())
  1060. {
  1061. *rdfExtension = carla_strdup(extURI);
  1062. continue;
  1063. }
  1064. }
  1065. *rdfExtension = nullptr;
  1066. }
  1067. for (uint32_t x=h; x < rdfDescriptor->ExtensionCount; ++x)
  1068. rdfDescriptor->Extensions[x] = nullptr;
  1069. }
  1070. lilv_nodes_free(const_cast<LilvNodes*>(lilvExtensionDataNodes.me));
  1071. }
  1072. // -------------------------------------------------------------------
  1073. // Set Plugin UIs
  1074. {
  1075. const bool hasMODGui(lilvPlugin.get_modgui_resources_directory().as_uri() != nullptr);
  1076. Lilv::UIs lilvUIs(lilvPlugin.get_uis());
  1077. if (lilvUIs.size() > 0 || hasMODGui)
  1078. {
  1079. rdfDescriptor->UICount = lilvUIs.size() + (hasMODGui ? 1 : 0);
  1080. rdfDescriptor->UIs = new LV2_RDF_UI[rdfDescriptor->UICount];
  1081. uint32_t h = 0;
  1082. LILV_FOREACH(uis, it, lilvUIs)
  1083. {
  1084. CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->UICount);
  1085. Lilv::UI lilvUI(lilvUIs.get(it));
  1086. LV2_RDF_UI* const rdfUI(&rdfDescriptor->UIs[h++]);
  1087. // -------------------------------------------------------
  1088. // Set UI Type
  1089. /**/ if (lilvUI.is_a(lv2World.ui_gtk2))
  1090. rdfUI->Type = LV2_UI_GTK2;
  1091. else if (lilvUI.is_a(lv2World.ui_gtk3))
  1092. rdfUI->Type = LV2_UI_GTK3;
  1093. else if (lilvUI.is_a(lv2World.ui_qt4))
  1094. rdfUI->Type = LV2_UI_QT4;
  1095. else if (lilvUI.is_a(lv2World.ui_qt5))
  1096. rdfUI->Type = LV2_UI_QT5;
  1097. else if (lilvUI.is_a(lv2World.ui_cocoa))
  1098. rdfUI->Type = LV2_UI_COCOA;
  1099. else if (lilvUI.is_a(lv2World.ui_windows))
  1100. rdfUI->Type = LV2_UI_WINDOWS;
  1101. else if (lilvUI.is_a(lv2World.ui_x11))
  1102. rdfUI->Type = LV2_UI_X11;
  1103. else if (lilvUI.is_a(lv2World.ui_external))
  1104. rdfUI->Type = LV2_UI_EXTERNAL;
  1105. else if (lilvUI.is_a(lv2World.ui_externalOld))
  1106. rdfUI->Type = LV2_UI_OLD_EXTERNAL;
  1107. else if (lilvUI.is_a(lv2World.ui_externalOld2))
  1108. pass();
  1109. else
  1110. carla_stderr("lv2_rdf_new(\"%s\") - UI '%s' is of unknown type", uri, lilvUI.get_uri().as_uri());
  1111. // -------------------------------------------------------
  1112. // Set UI Information
  1113. {
  1114. if (const char* const uiURI = lilvUI.get_uri().as_uri())
  1115. rdfUI->URI = carla_strdup(uiURI);
  1116. if (const char* const uiBinary = lilvUI.get_binary_uri().as_string())
  1117. rdfUI->Binary = carla_strdup(lilv_uri_to_path(uiBinary));
  1118. if (const char* const uiBundle = lilvUI.get_bundle_uri().as_string())
  1119. rdfUI->Bundle = carla_strdup(lilv_uri_to_path(uiBundle));
  1120. }
  1121. // -------------------------------------------------------
  1122. // Set UI Features
  1123. {
  1124. Lilv::Nodes lilvFeatureNodes(lilvUI.get_supported_features());
  1125. if (lilvFeatureNodes.size() > 0)
  1126. {
  1127. Lilv::Nodes lilvFeatureNodesR(lilvUI.get_required_features());
  1128. rdfUI->FeatureCount = lilvFeatureNodes.size();
  1129. rdfUI->Features = new LV2_RDF_Feature[rdfUI->FeatureCount];
  1130. uint32_t h2 = 0;
  1131. LILV_FOREACH(nodes, it2, lilvFeatureNodes)
  1132. {
  1133. CARLA_SAFE_ASSERT_BREAK(h2 < rdfUI->FeatureCount);
  1134. Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(it2));
  1135. LV2_RDF_Feature* const rdfFeature(&rdfUI->Features[h2++]);
  1136. rdfFeature->Type = lilvFeatureNodesR.contains(lilvFeatureNode) ? LV2_FEATURE_REQUIRED : LV2_FEATURE_OPTIONAL;
  1137. if (const char* const featureURI = lilvFeatureNode.as_uri())
  1138. rdfFeature->URI = carla_strdup(featureURI);
  1139. else
  1140. rdfFeature->URI = nullptr;
  1141. }
  1142. lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodesR.me));
  1143. }
  1144. lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodes.me));
  1145. }
  1146. // -------------------------------------------------------
  1147. // Set UI Extensions
  1148. {
  1149. Lilv::Nodes lilvExtensionDataNodes(lilvUI.get_extension_data());
  1150. if (lilvExtensionDataNodes.size() > 0)
  1151. {
  1152. rdfUI->ExtensionCount = lilvExtensionDataNodes.size();
  1153. rdfUI->Extensions = new LV2_URI[rdfUI->ExtensionCount];
  1154. uint32_t h2 = 0;
  1155. LILV_FOREACH(nodes, it2, lilvExtensionDataNodes)
  1156. {
  1157. CARLA_SAFE_ASSERT_BREAK(h2 < rdfUI->ExtensionCount);
  1158. Lilv::Node lilvExtensionDataNode(lilvExtensionDataNodes.get(it2));
  1159. LV2_URI* const rdfExtension(&rdfUI->Extensions[h2++]);
  1160. if (lilvExtensionDataNode.is_uri())
  1161. {
  1162. if (const char* const extURI = lilvExtensionDataNode.as_uri())
  1163. {
  1164. *rdfExtension = carla_strdup(extURI);
  1165. continue;
  1166. }
  1167. }
  1168. *rdfExtension = nullptr;
  1169. }
  1170. for (uint32_t x2=h2; x2 < rdfUI->ExtensionCount; ++x2)
  1171. rdfUI->Extensions[x2] = nullptr;
  1172. }
  1173. lilv_nodes_free(const_cast<LilvNodes*>(lilvExtensionDataNodes.me));
  1174. }
  1175. }
  1176. for (; hasMODGui;)
  1177. {
  1178. CARLA_SAFE_ASSERT_BREAK(h == rdfDescriptor->UICount-1);
  1179. LV2_RDF_UI* const rdfUI(&rdfDescriptor->UIs[h++]);
  1180. // -------------------------------------------------------
  1181. // Set UI Type
  1182. rdfUI->Type = LV2_UI_MOD;
  1183. // -------------------------------------------------------
  1184. // Set UI Information
  1185. if (const char* const resDir = lilvPlugin.get_modgui_resources_directory().as_uri())
  1186. rdfUI->URI = carla_strdup(lilv_uri_to_path(resDir));
  1187. if (rdfDescriptor->Bundle != nullptr)
  1188. rdfUI->Bundle = carla_strdup(rdfDescriptor->Bundle);
  1189. break;
  1190. }
  1191. }
  1192. lilv_nodes_free(const_cast<LilvNodes*>(lilvUIs.me));
  1193. }
  1194. return rdfDescriptor;
  1195. }
  1196. // -----------------------------------------------------------------------
  1197. // Check if we support a plugin port
  1198. static inline
  1199. bool is_lv2_port_supported(const LV2_Property types) noexcept
  1200. {
  1201. if (LV2_IS_PORT_CONTROL(types))
  1202. return true;
  1203. if (LV2_IS_PORT_AUDIO(types))
  1204. return true;
  1205. if (LV2_IS_PORT_CV(types))
  1206. return true;
  1207. if (LV2_IS_PORT_ATOM_SEQUENCE(types))
  1208. return true;
  1209. if (LV2_IS_PORT_EVENT(types))
  1210. return true;
  1211. if (LV2_IS_PORT_MIDI_LL(types))
  1212. return true;
  1213. return false;
  1214. }
  1215. // -----------------------------------------------------------------------
  1216. // Check if we support a plugin feature
  1217. static inline
  1218. bool is_lv2_feature_supported(const LV2_URI uri) noexcept
  1219. {
  1220. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', false);
  1221. if (std::strcmp(uri, LV2_BUF_SIZE__boundedBlockLength) == 0)
  1222. return true;
  1223. if (std::strcmp(uri, LV2_BUF_SIZE__fixedBlockLength) == 0)
  1224. return true;
  1225. if (std::strcmp(uri, LV2_BUF_SIZE__powerOf2BlockLength) == 0)
  1226. return true;
  1227. if (std::strcmp(uri, LV2_CORE__hardRTCapable) == 0)
  1228. return true;
  1229. if (std::strcmp(uri, LV2_CORE__inPlaceBroken) == 0)
  1230. return true;
  1231. if (std::strcmp(uri, LV2_CORE__isLive) == 0)
  1232. return true;
  1233. if (std::strcmp(uri, LV2_EVENT_URI) == 0)
  1234. return true;
  1235. if (std::strcmp(uri, LV2_LOG__log) == 0)
  1236. return true;
  1237. if (std::strcmp(uri, LV2_OPTIONS__options) == 0)
  1238. return true;
  1239. if (std::strcmp(uri, LV2_PROGRAMS__Host) == 0)
  1240. return true;
  1241. if (std::strcmp(uri, LV2_RESIZE_PORT__resize) == 0)
  1242. return true;
  1243. if (std::strcmp(uri, LV2_RTSAFE_MEMORY_POOL__Pool) == 0)
  1244. return true;
  1245. if (std::strcmp(uri, LV2_RTSAFE_MEMORY_POOL_DEPRECATED_URI) == 0)
  1246. return true;
  1247. if (std::strcmp(uri, LV2_STATE__makePath) == 0)
  1248. return true;
  1249. if (std::strcmp(uri, LV2_STATE__mapPath) == 0)
  1250. return true;
  1251. if (std::strcmp(uri, LV2_PORT_PROPS__supportsStrictBounds) == 0)
  1252. return true;
  1253. if (std::strcmp(uri, LV2_URI_MAP_URI) == 0)
  1254. return true;
  1255. if (std::strcmp(uri, LV2_URID__map) == 0)
  1256. return true;
  1257. if (std::strcmp(uri, LV2_URID__unmap) == 0)
  1258. return true;
  1259. if (std::strcmp(uri, LV2_WORKER__schedule) == 0)
  1260. return true;
  1261. return false;
  1262. }
  1263. // -----------------------------------------------------------------------
  1264. // Check if we support a plugin or UI feature
  1265. static inline
  1266. bool is_lv2_ui_feature_supported(const LV2_URI uri) noexcept
  1267. {
  1268. CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', false);
  1269. if (is_lv2_feature_supported(uri))
  1270. return true;
  1271. #ifndef BUILD_BRIDGE_UI
  1272. if (std::strcmp(uri, LV2_DATA_ACCESS_URI) == 0)
  1273. return true;
  1274. if (std::strcmp(uri, LV2_INSTANCE_ACCESS_URI) == 0)
  1275. return true;
  1276. #endif
  1277. if (std::strcmp(uri, LV2_UI__fixedSize) == 0)
  1278. return true;
  1279. if (std::strcmp(uri, LV2_UI__idleInterface) == 0)
  1280. return true;
  1281. if (std::strcmp(uri, LV2_UI__makeResident) == 0)
  1282. return true;
  1283. if (std::strcmp(uri, LV2_UI__noUserResize) == 0)
  1284. return true;
  1285. if (std::strcmp(uri, LV2_UI__parent) == 0)
  1286. return true;
  1287. if (std::strcmp(uri, LV2_UI__portMap) == 0)
  1288. return true;
  1289. if (std::strcmp(uri, LV2_UI__portSubscribe) == 0)
  1290. return true;
  1291. if (std::strcmp(uri, LV2_UI__resize) == 0)
  1292. return true;
  1293. if (std::strcmp(uri, LV2_UI__touch) == 0)
  1294. return true;
  1295. if (std::strcmp(uri, LV2_EXTERNAL_UI__Widget) == 0)
  1296. return true;
  1297. if (std::strcmp(uri, LV2_EXTERNAL_UI_DEPRECATED_URI) == 0)
  1298. return true;
  1299. return false;
  1300. }
  1301. // -----------------------------------------------------------------------
  1302. #endif // CARLA_LV2_UTILS_HPP_INCLUDED