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