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.

CarlaLv2Utils.hpp 59KB

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