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.

1519 lines
64KB

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