|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613 |
- /*
- * Carla LV2 utils
- * Copyright (C) 2011-2016 Filipe Coelho <falktx@falktx.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * For a full copy of the GNU General Public License see the doc/GPL.txt file.
- */
-
- #ifndef CARLA_LV2_UTILS_HPP_INCLUDED
- #define CARLA_LV2_UTILS_HPP_INCLUDED
-
- #include "CarlaUtils.hpp"
-
- #ifndef nullptr
- # undef NULL
- # define NULL nullptr
- #endif
-
- // disable -Wdocumentation for LV2 headers
- #if defined(__clang__) && (__clang_major__ * 100 + __clang_minor__) > 300
- # pragma clang diagnostic push
- # pragma clang diagnostic ignored "-Wdocumentation"
- #endif
-
- #include "lv2/lv2.h"
- #include "lv2/atom.h"
- #include "lv2/atom-forge.h"
- #include "lv2/atom-helpers.h"
- #include "lv2/atom-util.h"
- #include "lv2/buf-size.h"
- #include "lv2/data-access.h"
- // dynmanifest
- #include "lv2/event.h"
- #include "lv2/event-helpers.h"
- #include "lv2/instance-access.h"
- #include "lv2/log.h"
- // logger
- #include "lv2/midi.h"
- // morph
- #include "lv2/options.h"
- #include "lv2/parameters.h"
- #include "lv2/patch.h"
- #include "lv2/port-groups.h"
- #include "lv2/port-props.h"
- #include "lv2/presets.h"
- #include "lv2/resize-port.h"
- #include "lv2/state.h"
- #include "lv2/time.h"
- #include "lv2/ui.h"
- #include "lv2/units.h"
- #include "lv2/uri-map.h"
- #include "lv2/urid.h"
- #include "lv2/worker.h"
-
- #include "lv2/lv2-miditype.h"
- #include "lv2/lv2-midifunctions.h"
- #include "lv2/lv2_external_ui.h"
- #include "lv2/lv2_kxstudio_properties.h"
- #include "lv2/lv2_programs.h"
- #include "lv2/lv2_rtmempool.h"
-
- #include "lilv/lilvmm.hpp"
- #include "sratom/sratom.h"
-
- // enable -Wdocumentation again
- #if defined(__clang__) && (__clang_major__ * 100 + __clang_minor__) > 300
- # pragma clang diagnostic pop
- #endif
-
- #include "lv2_rdf.hpp"
-
- #ifdef USE_QT
- # include <QtCore/QStringList>
- #else
- # include "juce_core/juce_core.h"
- #endif
-
- // used for scalepoint sorting
- #include <map>
- typedef std::map<double,const LilvScalePoint*> LilvScalePointMap;
-
- // -----------------------------------------------------------------------
- // Define namespaces and missing prefixes
-
- #define NS_dct "http://purl.org/dc/terms/"
- #define NS_doap "http://usefulinc.com/ns/doap#"
- #define NS_rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- #define NS_rdfs "http://www.w3.org/2000/01/rdf-schema#"
- #define NS_llmm "http://ll-plugins.nongnu.org/lv2/ext/midimap#"
- #define NS_mod "http://moddevices.com/ns/modgui#"
-
- #define LV2_MIDI_Map__CC "http://ll-plugins.nongnu.org/lv2/namespace#CC"
- #define LV2_MIDI_Map__NRPN "http://ll-plugins.nongnu.org/lv2/namespace#NRPN"
-
- #define LV2_MIDI_LL__MidiPort "http://ll-plugins.nongnu.org/lv2/ext/MidiPort"
-
- #define LV2_UI__makeResident LV2_UI_PREFIX "makeResident"
- #define LV2_UI__makeSONameResident LV2_UI_PREFIX "makeSONameResident"
-
- // -----------------------------------------------------------------------
- // Custom Atom types
-
- struct LV2_Atom_MidiEvent {
- LV2_Atom atom; /**< Atom header. */
- uint8_t data[4]; /**< MIDI data (body). */
- };
-
- static inline
- uint32_t lv2_atom_total_size(const LV2_Atom_MidiEvent& midiEv)
- {
- return static_cast<uint32_t>(sizeof(LV2_Atom)) + midiEv.atom.size;
- }
-
- // -----------------------------------------------------------------------
- // Our LV2 World class
-
- class Lv2WorldClass : public Lilv::World
- {
- public:
- // Base Types
- Lilv::Node port;
- Lilv::Node symbol;
- Lilv::Node designation;
- Lilv::Node freeWheeling;
- Lilv::Node reportsLatency;
-
- // Plugin Types
- Lilv::Node class_allpass;
- Lilv::Node class_amplifier;
- Lilv::Node class_analyzer;
- Lilv::Node class_bandpass;
- Lilv::Node class_chorus;
- Lilv::Node class_comb;
- Lilv::Node class_compressor;
- Lilv::Node class_constant;
- Lilv::Node class_converter;
- Lilv::Node class_delay;
- Lilv::Node class_distortion;
- Lilv::Node class_dynamics;
- Lilv::Node class_eq;
- Lilv::Node class_envelope;
- Lilv::Node class_expander;
- Lilv::Node class_filter;
- Lilv::Node class_flanger;
- Lilv::Node class_function;
- Lilv::Node class_gate;
- Lilv::Node class_generator;
- Lilv::Node class_highpass;
- Lilv::Node class_instrument;
- Lilv::Node class_limiter;
- Lilv::Node class_lowpass;
- Lilv::Node class_mixer;
- Lilv::Node class_modulator;
- Lilv::Node class_multiEQ;
- Lilv::Node class_oscillator;
- Lilv::Node class_paraEQ;
- Lilv::Node class_phaser;
- Lilv::Node class_pitch;
- Lilv::Node class_reverb;
- Lilv::Node class_simulator;
- Lilv::Node class_spatial;
- Lilv::Node class_spectral;
- Lilv::Node class_utility;
- Lilv::Node class_waveshaper;
-
- // Port Types
- Lilv::Node port_input;
- Lilv::Node port_output;
- Lilv::Node port_control;
- Lilv::Node port_audio;
- Lilv::Node port_cv;
- Lilv::Node port_atom;
- Lilv::Node port_event;
- Lilv::Node port_midi;
-
- // Port Properties
- Lilv::Node pprop_optional;
- Lilv::Node pprop_enumeration;
- Lilv::Node pprop_integer;
- Lilv::Node pprop_sampleRate;
- Lilv::Node pprop_toggled;
- Lilv::Node pprop_artifacts;
- Lilv::Node pprop_continuousCV;
- Lilv::Node pprop_discreteCV;
- Lilv::Node pprop_expensive;
- Lilv::Node pprop_strictBounds;
- Lilv::Node pprop_logarithmic;
- Lilv::Node pprop_notAutomatic;
- Lilv::Node pprop_notOnGUI;
- Lilv::Node pprop_trigger;
- Lilv::Node pprop_nonAutomable;
-
- // Unit Hints
- Lilv::Node unit_name;
- Lilv::Node unit_render;
- Lilv::Node unit_symbol;
- Lilv::Node unit_unit;
-
- // UI Types
- Lilv::Node ui_gtk2;
- Lilv::Node ui_gtk3;
- Lilv::Node ui_qt4;
- Lilv::Node ui_qt5;
- Lilv::Node ui_cocoa;
- Lilv::Node ui_windows;
- Lilv::Node ui_x11;
- Lilv::Node ui_external;
- Lilv::Node ui_externalOld;
- Lilv::Node ui_externalOld2;
-
- // Misc
- Lilv::Node atom_bufferType;
- Lilv::Node atom_sequence;
- Lilv::Node atom_supports;
-
- Lilv::Node preset_preset;
-
- Lilv::Node state_state;
-
- Lilv::Node value_default;
- Lilv::Node value_minimum;
- Lilv::Node value_maximum;
-
- Lilv::Node rz_asLargeAs;
- Lilv::Node rz_minSize;
-
- // Port Data Types
- Lilv::Node midi_event;
- Lilv::Node patch_message;
- Lilv::Node time_position;
-
- // MIDI CC
- Lilv::Node mm_defaultControl;
- Lilv::Node mm_controlType;
- Lilv::Node mm_controlNumber;
-
- // Other
- Lilv::Node dct_replaces;
- Lilv::Node doap_license;
- Lilv::Node rdf_type;
- Lilv::Node rdfs_label;
-
- bool needsInit;
-
- const LilvPlugins* allPlugins;
- const LilvPlugin** cachedPlugins;
- uint pluginCount;
-
- // -------------------------------------------------------------------
-
- Lv2WorldClass()
- : Lilv::World(),
- port (new_uri(LV2_CORE__port)),
- symbol (new_uri(LV2_CORE__symbol)),
- designation (new_uri(LV2_CORE__designation)),
- freeWheeling (new_uri(LV2_CORE__freeWheeling)),
- reportsLatency (new_uri(LV2_CORE__reportsLatency)),
-
- class_allpass (new_uri(LV2_CORE__AllpassPlugin)),
- class_amplifier (new_uri(LV2_CORE__AmplifierPlugin)),
- class_analyzer (new_uri(LV2_CORE__AnalyserPlugin)),
- class_bandpass (new_uri(LV2_CORE__BandpassPlugin)),
- class_chorus (new_uri(LV2_CORE__ChorusPlugin)),
- class_comb (new_uri(LV2_CORE__CombPlugin)),
- class_compressor (new_uri(LV2_CORE__CompressorPlugin)),
- class_constant (new_uri(LV2_CORE__ConstantPlugin)),
- class_converter (new_uri(LV2_CORE__ConverterPlugin)),
- class_delay (new_uri(LV2_CORE__DelayPlugin)),
- class_distortion (new_uri(LV2_CORE__DistortionPlugin)),
- class_dynamics (new_uri(LV2_CORE__DynamicsPlugin)),
- class_eq (new_uri(LV2_CORE__EQPlugin)),
- class_envelope (new_uri(LV2_CORE__EnvelopePlugin)),
- class_expander (new_uri(LV2_CORE__ExpanderPlugin)),
- class_filter (new_uri(LV2_CORE__FilterPlugin)),
- class_flanger (new_uri(LV2_CORE__FlangerPlugin)),
- class_function (new_uri(LV2_CORE__FunctionPlugin)),
- class_gate (new_uri(LV2_CORE__GatePlugin)),
- class_generator (new_uri(LV2_CORE__GeneratorPlugin)),
- class_highpass (new_uri(LV2_CORE__HighpassPlugin)),
- class_instrument (new_uri(LV2_CORE__InstrumentPlugin)),
- class_limiter (new_uri(LV2_CORE__LimiterPlugin)),
- class_lowpass (new_uri(LV2_CORE__LowpassPlugin)),
- class_mixer (new_uri(LV2_CORE__MixerPlugin)),
- class_modulator (new_uri(LV2_CORE__ModulatorPlugin)),
- class_multiEQ (new_uri(LV2_CORE__MultiEQPlugin)),
- class_oscillator (new_uri(LV2_CORE__OscillatorPlugin)),
- class_paraEQ (new_uri(LV2_CORE__ParaEQPlugin)),
- class_phaser (new_uri(LV2_CORE__PhaserPlugin)),
- class_pitch (new_uri(LV2_CORE__PitchPlugin)),
- class_reverb (new_uri(LV2_CORE__ReverbPlugin)),
- class_simulator (new_uri(LV2_CORE__SimulatorPlugin)),
- class_spatial (new_uri(LV2_CORE__SpatialPlugin)),
- class_spectral (new_uri(LV2_CORE__SpectralPlugin)),
- class_utility (new_uri(LV2_CORE__UtilityPlugin)),
- class_waveshaper (new_uri(LV2_CORE__WaveshaperPlugin)),
-
- port_input (new_uri(LV2_CORE__InputPort)),
- port_output (new_uri(LV2_CORE__OutputPort)),
- port_control (new_uri(LV2_CORE__ControlPort)),
- port_audio (new_uri(LV2_CORE__AudioPort)),
- port_cv (new_uri(LV2_CORE__CVPort)),
- port_atom (new_uri(LV2_ATOM__AtomPort)),
- port_event (new_uri(LV2_EVENT__EventPort)),
- port_midi (new_uri(LV2_MIDI_LL__MidiPort)),
-
- pprop_optional (new_uri(LV2_CORE__connectionOptional)),
- pprop_enumeration (new_uri(LV2_CORE__enumeration)),
- pprop_integer (new_uri(LV2_CORE__integer)),
- pprop_sampleRate (new_uri(LV2_CORE__sampleRate)),
- pprop_toggled (new_uri(LV2_CORE__toggled)),
- pprop_artifacts (new_uri(LV2_PORT_PROPS__causesArtifacts)),
- pprop_continuousCV (new_uri(LV2_PORT_PROPS__continuousCV)),
- pprop_discreteCV (new_uri(LV2_PORT_PROPS__discreteCV)),
- pprop_expensive (new_uri(LV2_PORT_PROPS__expensive)),
- pprop_strictBounds (new_uri(LV2_PORT_PROPS__hasStrictBounds)),
- pprop_logarithmic (new_uri(LV2_PORT_PROPS__logarithmic)),
- pprop_notAutomatic (new_uri(LV2_PORT_PROPS__notAutomatic)),
- pprop_notOnGUI (new_uri(LV2_PORT_PROPS__notOnGUI)),
- pprop_trigger (new_uri(LV2_PORT_PROPS__trigger)),
- pprop_nonAutomable (new_uri(LV2_KXSTUDIO_PROPERTIES__NonAutomable)),
-
- unit_name (new_uri(LV2_UNITS__name)),
- unit_render (new_uri(LV2_UNITS__render)),
- unit_symbol (new_uri(LV2_UNITS__symbol)),
- unit_unit (new_uri(LV2_UNITS__unit)),
-
- ui_gtk2 (new_uri(LV2_UI__GtkUI)),
- ui_gtk3 (new_uri(LV2_UI__Gtk3UI)),
- ui_qt4 (new_uri(LV2_UI__Qt4UI)),
- ui_qt5 (new_uri(LV2_UI__Qt5UI)),
- ui_cocoa (new_uri(LV2_UI__CocoaUI)),
- ui_windows (new_uri(LV2_UI__WindowsUI)),
- ui_x11 (new_uri(LV2_UI__X11UI)),
- ui_external (new_uri(LV2_EXTERNAL_UI__Widget)),
- ui_externalOld (new_uri(LV2_EXTERNAL_UI_DEPRECATED_URI)),
- ui_externalOld2 (new_uri("http://nedko.arnaudov.name/lv2/external_ui/")),
-
- atom_bufferType (new_uri(LV2_ATOM__bufferType)),
- atom_sequence (new_uri(LV2_ATOM__Sequence)),
- atom_supports (new_uri(LV2_ATOM__supports)),
-
- preset_preset (new_uri(LV2_PRESETS__Preset)),
-
- state_state (new_uri(LV2_STATE__state)),
-
- value_default (new_uri(LV2_CORE__default)),
- value_minimum (new_uri(LV2_CORE__minimum)),
- value_maximum (new_uri(LV2_CORE__maximum)),
-
- rz_asLargeAs (new_uri(LV2_RESIZE_PORT__asLargeAs)),
- rz_minSize (new_uri(LV2_RESIZE_PORT__minimumSize)),
-
- midi_event (new_uri(LV2_MIDI__MidiEvent)),
- patch_message (new_uri(LV2_PATCH__Message)),
- time_position (new_uri(LV2_TIME__Position)),
-
- mm_defaultControl (new_uri(NS_llmm "defaultMidiController")),
- mm_controlType (new_uri(NS_llmm "controllerType")),
- mm_controlNumber (new_uri(NS_llmm "controllerNumber")),
-
- dct_replaces (new_uri(NS_dct "replaces")),
- doap_license (new_uri(NS_doap "license")),
- rdf_type (new_uri(NS_rdf "type")),
- rdfs_label (new_uri(NS_rdfs "label")),
-
- needsInit(true),
- allPlugins(nullptr),
- cachedPlugins(nullptr),
- pluginCount(0) {}
-
- ~Lv2WorldClass() override
- {
- pluginCount = 0;
- allPlugins = nullptr;
-
- if (cachedPlugins != nullptr)
- {
- delete[] cachedPlugins;
- cachedPlugins = nullptr;
- }
- }
-
- // FIXME - remove this
- static Lv2WorldClass& getInstance()
- {
- static Lv2WorldClass lv2World;
- return lv2World;
- }
-
- void initIfNeeded(const char* const LV2_PATH)
- {
- CARLA_SAFE_ASSERT_RETURN(LV2_PATH != nullptr,);
-
- if (! needsInit)
- return;
-
- needsInit = false;
-
- Lilv::World::load_all(LV2_PATH);
-
- allPlugins = lilv_world_get_all_plugins(this->me);
- CARLA_SAFE_ASSERT_RETURN(allPlugins != nullptr,);
-
- if ((pluginCount = lilv_plugins_size(allPlugins)))
- {
- cachedPlugins = new const LilvPlugin*[pluginCount+1];
- carla_zeroPointers(cachedPlugins, pluginCount+1);
-
- int i = 0;
- for (LilvIter* it = lilv_plugins_begin(allPlugins); ! lilv_plugins_is_end(allPlugins, it); it = lilv_plugins_next(allPlugins, it))
- cachedPlugins[i++] = lilv_plugins_get(allPlugins, it);
- }
- }
-
- void load_bundle(const char* const bundle)
- {
- CARLA_SAFE_ASSERT_RETURN(bundle != nullptr && bundle[0] != '\0',);
- CARLA_SAFE_ASSERT_RETURN(needsInit,);
-
- needsInit = false;
- Lilv::World::load_bundle(Lilv::Node(new_uri(bundle)));
-
- allPlugins = lilv_world_get_all_plugins(this->me);
- CARLA_SAFE_ASSERT_RETURN(allPlugins != nullptr,);
-
- if ((pluginCount = lilv_plugins_size(allPlugins)))
- {
- cachedPlugins = new const LilvPlugin*[pluginCount+1];
- carla_zeroPointers(cachedPlugins, pluginCount+1);
-
- int i = 0;
- for (LilvIter* it = lilv_plugins_begin(allPlugins); ! lilv_plugins_is_end(allPlugins, it); it = lilv_plugins_next(allPlugins, it))
- cachedPlugins[i++] = lilv_plugins_get(allPlugins, it);
- }
- }
-
- uint getPluginCount() const
- {
- CARLA_SAFE_ASSERT_RETURN(! needsInit, 0);
-
- return pluginCount;
- }
-
- const LilvPlugin* getPluginFromIndex(const uint index) const
- {
- CARLA_SAFE_ASSERT_RETURN(! needsInit, nullptr);
- CARLA_SAFE_ASSERT_RETURN(cachedPlugins != nullptr, nullptr);
- CARLA_SAFE_ASSERT_RETURN(index < pluginCount, nullptr);
-
- return cachedPlugins[index];
- }
-
- const LilvPlugin* getPluginFromURI(const LV2_URI uri) const
- {
- CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);
- CARLA_SAFE_ASSERT_RETURN(! needsInit, nullptr);
- CARLA_SAFE_ASSERT_RETURN(allPlugins != nullptr, nullptr);
-
- LilvNode* const uriNode(lilv_new_uri(this->me, uri));
- CARLA_SAFE_ASSERT_RETURN(uriNode != nullptr, nullptr);
-
- const LilvPlugin* const cPlugin(lilv_plugins_get_by_uri(allPlugins, uriNode));
- lilv_node_free(uriNode);
-
- return cPlugin;
- }
-
- LilvState* getStateFromURI(const LV2_URI uri, const LV2_URID_Map* const uridMap) const
- {
- CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);
- CARLA_SAFE_ASSERT_RETURN(uridMap != nullptr, nullptr);
- CARLA_SAFE_ASSERT_RETURN(! needsInit, nullptr);
-
- LilvNode* const uriNode(lilv_new_uri(this->me, uri));
- CARLA_SAFE_ASSERT_RETURN(uriNode != nullptr, nullptr);
-
- CARLA_SAFE_ASSERT(lilv_world_load_resource(this->me, uriNode) >= 0);
-
- LilvState* const cState(lilv_state_new_from_world(this->me, uridMap, uriNode));
- lilv_node_free(uriNode);
-
- return cState;
- }
-
- CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION
- CARLA_DECLARE_NON_COPY_STRUCT(Lv2WorldClass)
- };
-
- // -----------------------------------------------------------------------
- // Create new RDF object (using lilv)
-
- static inline
- const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool loadPresets)
- {
- CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);
-
- Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());
-
- const LilvPlugin* const cPlugin(lv2World.getPluginFromURI(uri));
- CARLA_SAFE_ASSERT_RETURN(cPlugin != nullptr, nullptr);
-
- Lilv::Plugin lilvPlugin(cPlugin);
- LV2_RDF_Descriptor* const rdfDescriptor(new LV2_RDF_Descriptor());
-
- // -------------------------------------------------------------------
- // Set Plugin Type
- {
- Lilv::Nodes typeNodes(lilvPlugin.get_value(lv2World.rdf_type));
-
- if (typeNodes.size() > 0)
- {
- if (typeNodes.contains(lv2World.class_allpass))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_ALLPASS;
- if (typeNodes.contains(lv2World.class_amplifier))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_AMPLIFIER;
- if (typeNodes.contains(lv2World.class_analyzer))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_ANALYSER;
- if (typeNodes.contains(lv2World.class_bandpass))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_BANDPASS;
- if (typeNodes.contains(lv2World.class_chorus))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_CHORUS;
- if (typeNodes.contains(lv2World.class_comb))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_COMB;
- if (typeNodes.contains(lv2World.class_compressor))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_COMPRESSOR;
- if (typeNodes.contains(lv2World.class_constant))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_CONSTANT;
- if (typeNodes.contains(lv2World.class_converter))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_CONVERTER;
- if (typeNodes.contains(lv2World.class_delay))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_DELAY;
- if (typeNodes.contains(lv2World.class_distortion))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_DISTORTION;
- if (typeNodes.contains(lv2World.class_dynamics))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_DYNAMICS;
- if (typeNodes.contains(lv2World.class_eq))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_EQ;
- if (typeNodes.contains(lv2World.class_envelope))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_ENVELOPE;
- if (typeNodes.contains(lv2World.class_expander))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_EXPANDER;
- if (typeNodes.contains(lv2World.class_filter))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_FILTER;
- if (typeNodes.contains(lv2World.class_flanger))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_FLANGER;
- if (typeNodes.contains(lv2World.class_function))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_FUNCTION;
- if (typeNodes.contains(lv2World.class_gate))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_GATE;
- if (typeNodes.contains(lv2World.class_generator))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_GENERATOR;
- if (typeNodes.contains(lv2World.class_highpass))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_HIGHPASS;
- if (typeNodes.contains(lv2World.class_instrument))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_INSTRUMENT;
- if (typeNodes.contains(lv2World.class_limiter))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_LIMITER;
- if (typeNodes.contains(lv2World.class_lowpass))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_LOWPASS;
- if (typeNodes.contains(lv2World.class_mixer))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_MIXER;
- if (typeNodes.contains(lv2World.class_modulator))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_MODULATOR;
- if (typeNodes.contains(lv2World.class_multiEQ))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_MULTI_EQ;
- if (typeNodes.contains(lv2World.class_oscillator))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_OSCILLATOR;
- if (typeNodes.contains(lv2World.class_paraEQ))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_PARA_EQ;
- if (typeNodes.contains(lv2World.class_phaser))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_PHASER;
- if (typeNodes.contains(lv2World.class_pitch))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_PITCH;
- if (typeNodes.contains(lv2World.class_reverb))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_REVERB;
- if (typeNodes.contains(lv2World.class_simulator))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_SIMULATOR;
- if (typeNodes.contains(lv2World.class_spatial))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_SPATIAL;
- if (typeNodes.contains(lv2World.class_spectral))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_SPECTRAL;
- if (typeNodes.contains(lv2World.class_utility))
- rdfDescriptor->Type[1] |= LV2_PLUGIN_UTILITY;
- if (typeNodes.contains(lv2World.class_waveshaper))
- rdfDescriptor->Type[0] |= LV2_PLUGIN_WAVESHAPER;
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(typeNodes.me));
- }
-
- // -------------------------------------------------------------------
- // Set Plugin Information
- {
- rdfDescriptor->URI = carla_strdup(uri);
-
- if (LilvNode* const nameNode = lilv_plugin_get_name(lilvPlugin.me))
- {
- if (const char* const name = lilv_node_as_string(nameNode))
- rdfDescriptor->Name = carla_strdup(name);
- lilv_node_free(nameNode);
- }
-
- if (const char* const author = lilvPlugin.get_author_name().as_string())
- rdfDescriptor->Author = carla_strdup(author);
-
- if (const char* const binary = lilvPlugin.get_library_uri().as_string())
- rdfDescriptor->Binary = carla_strdup_free(lilv_file_uri_parse(binary, nullptr));
-
- if (const char* const bundle = lilvPlugin.get_bundle_uri().as_string())
- rdfDescriptor->Bundle = carla_strdup_free(lilv_file_uri_parse(bundle, nullptr));
-
- Lilv::Nodes licenseNodes(lilvPlugin.get_value(lv2World.doap_license));
-
- if (licenseNodes.size() > 0)
- {
- if (const char* const license = licenseNodes.get_first().as_string())
- rdfDescriptor->License = carla_strdup(license);
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(licenseNodes.me));
- }
-
- // -------------------------------------------------------------------
- // Set Plugin UniqueID
- {
- Lilv::Nodes replaceNodes(lilvPlugin.get_value(lv2World.dct_replaces));
-
- if (replaceNodes.size() > 0)
- {
- Lilv::Node replaceNode(replaceNodes.get_first());
-
- if (replaceNode.is_uri())
- {
- #ifdef USE_QT
- const QString replaceURI(replaceNode.as_uri());
-
- if (replaceURI.startsWith("urn:"))
- {
- const QString replaceId(replaceURI.split(":").last());
-
- bool ok;
- const ulong uniqueId(replaceId.toULong(&ok));
-
- if (ok && uniqueId != 0)
- rdfDescriptor->UniqueID = uniqueId;
- }
- #else
- const juce::String replaceURI(replaceNode.as_uri());
-
- if (replaceURI.startsWith("urn:"))
- {
- const int uniqueId(replaceURI.getTrailingIntValue());
-
- if (uniqueId > 0)
- rdfDescriptor->UniqueID = static_cast<ulong>(uniqueId);
- }
- #endif
- }
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(replaceNodes.me));
- }
-
- // -------------------------------------------------------------------
- // Set Plugin Ports
-
- if (lilvPlugin.get_num_ports() > 0)
- {
- rdfDescriptor->PortCount = lilvPlugin.get_num_ports();
- rdfDescriptor->Ports = new LV2_RDF_Port[rdfDescriptor->PortCount];
-
- for (uint32_t i = 0; i < rdfDescriptor->PortCount; ++i)
- {
- Lilv::Port lilvPort(lilvPlugin.get_port_by_index(i));
- LV2_RDF_Port* const rdfPort(&rdfDescriptor->Ports[i]);
-
- // -----------------------------------------------------------
- // Set Port Information
- {
- if (LilvNode* const nameNode = lilv_port_get_name(lilvPlugin.me, lilvPort.me))
- {
- if (const char* const name = lilv_node_as_string(nameNode))
- rdfPort->Name = carla_strdup(name);
- lilv_node_free(nameNode);
- }
-
- if (const char* const symbol = lilv_node_as_string(lilvPort.get_symbol()))
- rdfPort->Symbol = carla_strdup(symbol);
- }
-
- // -----------------------------------------------------------
- // Set Port Mode and Type
- {
- // Input or Output
- /**/ if (lilvPort.is_a(lv2World.port_input))
- rdfPort->Types |= LV2_PORT_INPUT;
- else if (lilvPort.is_a(lv2World.port_output))
- rdfPort->Types |= LV2_PORT_OUTPUT;
- else
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is not input or output", uri, rdfPort->Name);
-
- // Data Type
- /**/ if (lilvPort.is_a(lv2World.port_control))
- {
- rdfPort->Types |= LV2_PORT_CONTROL;
- }
- else if (lilvPort.is_a(lv2World.port_audio))
- {
- rdfPort->Types |= LV2_PORT_AUDIO;
- }
- else if (lilvPort.is_a(lv2World.port_cv))
- {
- rdfPort->Types |= LV2_PORT_CV;
- }
- else if (lilvPort.is_a(lv2World.port_atom))
- {
- rdfPort->Types |= LV2_PORT_ATOM;
-
- Lilv::Nodes bufferTypeNodes(lilvPort.get_value(lv2World.atom_bufferType));
-
- for (LilvIter* it = lilv_nodes_begin(bufferTypeNodes.me); ! lilv_nodes_is_end(bufferTypeNodes.me, it); it = lilv_nodes_next(bufferTypeNodes.me, it))
- {
- const Lilv::Node node(lilv_nodes_get(bufferTypeNodes.me, it));
- CARLA_SAFE_ASSERT_CONTINUE(node.is_uri());
-
- if (node.equals(lv2World.atom_sequence))
- rdfPort->Types |= LV2_PORT_ATOM_SEQUENCE;
- else
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses an unknown atom buffer type '%s'", uri, rdfPort->Name, node.as_uri());
- }
-
- Lilv::Nodes supportNodes(lilvPort.get_value(lv2World.atom_supports));
-
- for (LilvIter* it = lilv_nodes_begin(supportNodes.me); ! lilv_nodes_is_end(supportNodes.me, it); it = lilv_nodes_next(supportNodes.me, it))
- {
- const Lilv::Node node(lilv_nodes_get(supportNodes.me, it));
- CARLA_SAFE_ASSERT_CONTINUE(node.is_uri());
-
- /**/ if (node.equals(lv2World.midi_event))
- rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
-
- else if (node.equals(lv2World.patch_message))
- rdfPort->Types |= LV2_PORT_DATA_PATCH_MESSAGE;
-
- else if (node.equals(lv2World.time_position))
- rdfPort->Types |= LV2_PORT_DATA_TIME_POSITION;
-
- #if 0
- // something new we don't support yet?
- else if (std::strstr(node.as_uri(), "lv2plug.in/") != nullptr)
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of atom type but has unsupported data '%s'", uri, rdfPort->Name, node.as_uri());
- #endif
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(bufferTypeNodes.me));
- lilv_nodes_free(const_cast<LilvNodes*>(supportNodes.me));
- }
- else if (lilvPort.is_a(lv2World.port_event))
- {
- rdfPort->Types |= LV2_PORT_EVENT;
- bool supported = false;
-
- if (lilvPort.supports_event(lv2World.midi_event))
- {
- rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
- supported = true;
- }
- if (lilvPort.supports_event(lv2World.patch_message))
- {
- rdfPort->Types |= LV2_PORT_DATA_PATCH_MESSAGE;
- supported = true;
- }
- if (lilvPort.supports_event(lv2World.time_position))
- {
- rdfPort->Types |= LV2_PORT_DATA_TIME_POSITION;
- supported = true;
- }
-
- if (! supported)
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of event type but has unsupported data", uri, rdfPort->Name);
- }
- else if (lilvPort.is_a(lv2World.port_midi))
- {
- rdfPort->Types |= LV2_PORT_MIDI_LL;
- rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
- }
- else
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of unkown data type", uri, rdfPort->Name);
- }
-
- // -----------------------------------------------------------
- // Set Port Properties
- {
- if (lilvPort.has_property(lv2World.pprop_optional))
- rdfPort->Properties |= LV2_PORT_OPTIONAL;
- if (lilvPort.has_property(lv2World.pprop_enumeration))
- rdfPort->Properties |= LV2_PORT_ENUMERATION;
- if (lilvPort.has_property(lv2World.pprop_integer))
- rdfPort->Properties |= LV2_PORT_INTEGER;
- if (lilvPort.has_property(lv2World.pprop_sampleRate))
- rdfPort->Properties |= LV2_PORT_SAMPLE_RATE;
- if (lilvPort.has_property(lv2World.pprop_toggled))
- rdfPort->Properties |= LV2_PORT_TOGGLED;
-
- if (lilvPort.has_property(lv2World.pprop_artifacts))
- rdfPort->Properties |= LV2_PORT_CAUSES_ARTIFACTS;
- if (lilvPort.has_property(lv2World.pprop_continuousCV))
- rdfPort->Properties |= LV2_PORT_CONTINUOUS_CV;
- if (lilvPort.has_property(lv2World.pprop_discreteCV))
- rdfPort->Properties |= LV2_PORT_DISCRETE_CV;
- if (lilvPort.has_property(lv2World.pprop_expensive))
- rdfPort->Properties |= LV2_PORT_EXPENSIVE;
- if (lilvPort.has_property(lv2World.pprop_strictBounds))
- rdfPort->Properties |= LV2_PORT_STRICT_BOUNDS;
- if (lilvPort.has_property(lv2World.pprop_logarithmic))
- rdfPort->Properties |= LV2_PORT_LOGARITHMIC;
- if (lilvPort.has_property(lv2World.pprop_notAutomatic))
- rdfPort->Properties |= LV2_PORT_NOT_AUTOMATIC;
- if (lilvPort.has_property(lv2World.pprop_notOnGUI))
- rdfPort->Properties |= LV2_PORT_NOT_ON_GUI;
- if (lilvPort.has_property(lv2World.pprop_trigger))
- rdfPort->Properties |= LV2_PORT_TRIGGER;
- if (lilvPort.has_property(lv2World.pprop_nonAutomable))
- rdfPort->Properties |= LV2_PORT_NON_AUTOMABLE;
-
- if (lilvPort.has_property(lv2World.reportsLatency))
- rdfPort->Designation = LV2_PORT_DESIGNATION_LATENCY;
-
- // no port properties set, check if using old/invalid ones
- if (rdfPort->Properties == 0x0)
- {
- const Lilv::Node oldPropArtifacts(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#causesArtifacts"));
- const Lilv::Node oldPropContinuousCV(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#continuousCV"));
- const Lilv::Node oldPropDiscreteCV(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#discreteCV"));
- const Lilv::Node oldPropExpensive(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#expensive"));
- const Lilv::Node oldPropStrictBounds(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#hasStrictBounds"));
- const Lilv::Node oldPropLogarithmic(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#logarithmic"));
- const Lilv::Node oldPropNotAutomatic(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#notAutomatic"));
- const Lilv::Node oldPropNotOnGUI(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#notOnGUI"));
- const Lilv::Node oldPropTrigger(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#trigger"));
-
- if (lilvPort.has_property(oldPropArtifacts))
- {
- rdfPort->Properties |= LV2_PORT_CAUSES_ARTIFACTS;
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'causesArtifacts'", uri, rdfPort->Name);
- }
- if (lilvPort.has_property(oldPropContinuousCV))
- {
- rdfPort->Properties |= LV2_PORT_CONTINUOUS_CV;
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'continuousCV'", uri, rdfPort->Name);
- }
- if (lilvPort.has_property(oldPropDiscreteCV))
- {
- rdfPort->Properties |= LV2_PORT_DISCRETE_CV;
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'discreteCV'", uri, rdfPort->Name);
- }
- if (lilvPort.has_property(oldPropExpensive))
- {
- rdfPort->Properties |= LV2_PORT_EXPENSIVE;
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'expensive'", uri, rdfPort->Name);
- }
- if (lilvPort.has_property(oldPropStrictBounds))
- {
- rdfPort->Properties |= LV2_PORT_STRICT_BOUNDS;
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'hasStrictBounds'", uri, rdfPort->Name);
- }
- if (lilvPort.has_property(oldPropLogarithmic))
- {
- rdfPort->Properties |= LV2_PORT_LOGARITHMIC;
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'logarithmic'", uri, rdfPort->Name);
- }
- if (lilvPort.has_property(oldPropNotAutomatic))
- {
- rdfPort->Properties |= LV2_PORT_NOT_AUTOMATIC;
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'notAutomatic'", uri, rdfPort->Name);
- }
- if (lilvPort.has_property(oldPropNotOnGUI))
- {
- rdfPort->Properties |= LV2_PORT_NOT_ON_GUI;
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'notOnGUI'", uri, rdfPort->Name);
- }
- if (lilvPort.has_property(oldPropTrigger))
- {
- rdfPort->Properties |= LV2_PORT_TRIGGER;
- carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/invalid LV2 property for 'trigger'", uri, rdfPort->Name);
- }
- }
- }
-
- // -----------------------------------------------------------
- // Set Port Designation
- {
- if (LilvNode* const designationNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.designation.me))
- {
- if (const char* const designation = lilv_node_as_string(designationNode))
- {
- /**/ if (std::strcmp(designation, LV2_CORE__control) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_CONTROL;
- else if (std::strcmp(designation, LV2_CORE__freeWheeling) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_FREEWHEELING;
- else if (std::strcmp(designation, LV2_CORE__latency) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_LATENCY;
- else if (std::strcmp(designation, LV2_PARAMETERS__sampleRate) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_SAMPLE_RATE;
- else if (std::strcmp(designation, LV2_TIME__bar) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BAR;
- else if (std::strcmp(designation, LV2_TIME__barBeat) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BAR_BEAT;
- else if (std::strcmp(designation, LV2_TIME__beat) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BEAT;
- else if (std::strcmp(designation, LV2_TIME__beatUnit) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BEAT_UNIT;
- else if (std::strcmp(designation, LV2_TIME__beatsPerBar) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BEATS_PER_BAR;
- else if (std::strcmp(designation, LV2_TIME__beatsPerMinute) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_BEATS_PER_MINUTE;
- else if (std::strcmp(designation, LV2_TIME__frame) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_FRAME;
- else if (std::strcmp(designation, LV2_TIME__framesPerSecond) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_FRAMES_PER_SECOND;
- else if (std::strcmp(designation, LV2_TIME__speed) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_SPEED;
- else if (std::strcmp(designation, LV2_KXSTUDIO_PROPERTIES__TimePositionTicksPerBeat) == 0)
- rdfPort->Designation = LV2_PORT_DESIGNATION_TIME_TICKS_PER_BEAT;
- else if (std::strncmp(designation, LV2_PARAMETERS_PREFIX, std::strlen(LV2_PARAMETERS_PREFIX)) == 0)
- pass();
- else if (std::strncmp(designation, LV2_PORT_GROUPS_PREFIX, std::strlen(LV2_PORT_GROUPS_PREFIX)) == 0)
- pass();
- else
- carla_stderr("lv2_rdf_new(\"%s\") - got unknown port designation '%s'", uri, designation);
- }
- lilv_node_free(designationNode);
- }
- }
-
- // -----------------------------------------------------------
- // Set Port MIDI Map
- {
- if (LilvNode* const midiMapNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.mm_defaultControl.me))
- {
- if (lilv_node_is_blank(midiMapNode))
- {
- Lilv::Nodes midiMapTypeNodes(lv2World.find_nodes(midiMapNode, lv2World.mm_controlType, nullptr));
- Lilv::Nodes midiMapNumberNodes(lv2World.find_nodes(midiMapNode, lv2World.mm_controlNumber, nullptr));
-
- if (midiMapTypeNodes.size() == 1 && midiMapNumberNodes.size() == 1)
- {
- if (const char* const midiMapType = midiMapTypeNodes.get_first().as_string())
- {
- /**/ if (std::strcmp(midiMapType, LV2_MIDI_Map__CC) == 0)
- rdfPort->MidiMap.Type = LV2_PORT_MIDI_MAP_CC;
- else if (std::strcmp(midiMapType, LV2_MIDI_Map__NRPN) == 0)
- rdfPort->MidiMap.Type = LV2_PORT_MIDI_MAP_NRPN;
- else
- carla_stderr("lv2_rdf_new(\"%s\") - got unknown port Midi-Map type '%s'", uri, midiMapType);
-
- rdfPort->MidiMap.Number = static_cast<uint32_t>(midiMapNumberNodes.get_first().as_int());
- }
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(midiMapTypeNodes.me));
- lilv_nodes_free(const_cast<LilvNodes*>(midiMapNumberNodes.me));
- }
-
- lilv_node_free(midiMapNode);
- }
-
- // TODO - also check using new official MIDI API too
- }
-
- // -----------------------------------------------------------
- // Set Port Points
- {
- if (LilvNode* const defNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.value_default.me))
- {
- rdfPort->Points.Hints |= LV2_PORT_POINT_DEFAULT;
- rdfPort->Points.Default = lilv_node_as_float(defNode);
- lilv_node_free(defNode);
- }
-
- if (LilvNode* const minNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.value_minimum.me))
- {
- rdfPort->Points.Hints |= LV2_PORT_POINT_MINIMUM;
- rdfPort->Points.Minimum = lilv_node_as_float(minNode);
- lilv_node_free(minNode);
- }
-
- if (LilvNode* const maxNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.value_maximum.me))
- {
- rdfPort->Points.Hints |= LV2_PORT_POINT_MAXIMUM;
- rdfPort->Points.Maximum = lilv_node_as_float(maxNode);
- lilv_node_free(maxNode);
- }
- }
-
- // -----------------------------------------------------------
- // Set Port Unit
- {
- if (LilvNode* const unitUnitNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.unit_unit.me))
- {
- if (lilv_node_is_uri(unitUnitNode))
- {
- if (const char* const unitUnit = lilv_node_as_uri(unitUnitNode))
- {
- rdfPort->Unit.Hints |= LV2_PORT_UNIT_UNIT;
-
- /**/ if (std::strcmp(unitUnit, LV2_UNITS__bar) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_BAR;
- else if (std::strcmp(unitUnit, LV2_UNITS__beat) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_BEAT;
- else if (std::strcmp(unitUnit, LV2_UNITS__bpm) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_BPM;
- else if (std::strcmp(unitUnit, LV2_UNITS__cent) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_CENT;
- else if (std::strcmp(unitUnit, LV2_UNITS__cm) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_CM;
- else if (std::strcmp(unitUnit, LV2_UNITS__coef) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_COEF;
- else if (std::strcmp(unitUnit, LV2_UNITS__db) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_DB;
- else if (std::strcmp(unitUnit, LV2_UNITS__degree) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_DEGREE;
- else if (std::strcmp(unitUnit, LV2_UNITS__frame) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_FRAME;
- else if (std::strcmp(unitUnit, LV2_UNITS__hz) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_HZ;
- else if (std::strcmp(unitUnit, LV2_UNITS__inch) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_INCH;
- else if (std::strcmp(unitUnit, LV2_UNITS__khz) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_KHZ;
- else if (std::strcmp(unitUnit, LV2_UNITS__km) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_KM;
- else if (std::strcmp(unitUnit, LV2_UNITS__m) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_M;
- else if (std::strcmp(unitUnit, LV2_UNITS__mhz) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_MHZ;
- else if (std::strcmp(unitUnit, LV2_UNITS__midiNote) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_MIDINOTE;
- else if (std::strcmp(unitUnit, LV2_UNITS__mile) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_MILE;
- else if (std::strcmp(unitUnit, LV2_UNITS__min) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_MIN;
- else if (std::strcmp(unitUnit, LV2_UNITS__mm) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_MM;
- else if (std::strcmp(unitUnit, LV2_UNITS__ms) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_MS;
- else if (std::strcmp(unitUnit, LV2_UNITS__oct) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_OCT;
- else if (std::strcmp(unitUnit, LV2_UNITS__pc) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_PC;
- else if (std::strcmp(unitUnit, LV2_UNITS__s) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_S;
- else if (std::strcmp(unitUnit, LV2_UNITS__semitone12TET) == 0)
- rdfPort->Unit.Unit = LV2_PORT_UNIT_SEMITONE;
- else
- carla_stderr("lv2_rdf_new(\"%s\") - got unknown unit unit '%s'", uri, unitUnit);
- }
- }
-
- if (LilvNode* const unitNameNode = lilv_world_get(lv2World.me, unitUnitNode, lv2World.unit_name.me, nullptr))
- {
- if (const char* const unitName = lilv_node_as_string(unitNameNode))
- {
- rdfPort->Unit.Hints |= LV2_PORT_UNIT_NAME;
- rdfPort->Unit.Name = carla_strdup(unitName);
- }
- lilv_node_free(unitNameNode);
- }
-
- if (LilvNode* const unitRenderNode = lilv_world_get(lv2World.me, unitUnitNode, lv2World.unit_render.me, nullptr))
- {
- if (const char* const unitRender = lilv_node_as_string(unitRenderNode))
- {
- rdfPort->Unit.Hints |= LV2_PORT_UNIT_RENDER;
- rdfPort->Unit.Render = carla_strdup(unitRender);
- }
- lilv_node_free(unitRenderNode);
- }
-
- if (LilvNode* const unitSymbolNode = lilv_world_get(lv2World.me, unitUnitNode, lv2World.unit_symbol.me, nullptr))
- {
- if (const char* const unitSymbol = lilv_node_as_string(unitSymbolNode))
- {
- rdfPort->Unit.Hints |= LV2_PORT_UNIT_SYMBOL;
- rdfPort->Unit.Symbol = carla_strdup(unitSymbol);
- }
- lilv_node_free(unitSymbolNode);
- }
-
- lilv_node_free(unitUnitNode);
- }
- }
-
- // -----------------------------------------------------------
- // Set Port Minimum Size
- {
- if (LilvNode* const minimumSizeNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.rz_minSize.me))
- {
- const int minimumSize(lilv_node_as_int(minimumSizeNode));
-
- if (minimumSize > 0)
- rdfPort->MinimumSize = static_cast<uint32_t>(minimumSize);
- else
- carla_safe_assert_int("minimumSize > 0", __FILE__, __LINE__, minimumSize);
-
- lilv_node_free(minimumSizeNode);
- }
- }
-
- // -----------------------------------------------------------
- // Set Port Scale Points
-
- {
- Lilv::ScalePoints lilvScalePoints(lilvPort.get_scale_points());
-
- if (lilvScalePoints.size() > 0)
- {
- rdfPort->ScalePointCount = lilvScalePoints.size();
- rdfPort->ScalePoints = new LV2_RDF_PortScalePoint[rdfPort->ScalePointCount];
-
- // get all scalepoints and sort them by value
- LilvScalePointMap sortedpoints;
-
- LILV_FOREACH(scale_points, it, lilvScalePoints)
- {
- Lilv::ScalePoint lilvScalePoint(lilvScalePoints.get(it));
-
- CARLA_SAFE_ASSERT_CONTINUE(lilvScalePoint.get_label() != nullptr);
-
- if (const LilvNode* const valuenode = lilvScalePoint.get_value())
- {
- const double valueid = lilv_node_as_float(valuenode);
- sortedpoints[valueid] = lilvScalePoint.me;
- }
- }
-
- // now safe to store, sorted by using std::map
- uint32_t h = 0;
- for (LilvScalePointMap::iterator it=sortedpoints.begin(), end=sortedpoints.end(); it != end; ++it)
- {
- CARLA_SAFE_ASSERT_BREAK(h < rdfPort->ScalePointCount);
- LV2_RDF_PortScalePoint* const rdfScalePoint(&rdfPort->ScalePoints[h++]);
-
- const LilvScalePoint* const scalepoint = it->second;
-
- const LilvNode* const xlabel = lilv_scale_point_get_label(scalepoint);
- const LilvNode* const xvalue = lilv_scale_point_get_value(scalepoint);
-
- rdfScalePoint->Label = carla_strdup(lilv_node_as_string(xlabel));
- rdfScalePoint->Value = lilv_node_as_float(xvalue);
- }
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(lilvScalePoints.me));
- }
- }
- }
-
- // -------------------------------------------------------------------
- // Set Plugin Presets
-
- if (loadPresets)
- {
- Lilv::Nodes presetNodes(lilvPlugin.get_related(lv2World.preset_preset));
-
- if (presetNodes.size() > 0)
- {
- // create a list of preset URIs (for sorting and unique-ness)
- #ifdef USE_QT
- QStringList presetListURIs;
-
- LILV_FOREACH(nodes, it, presetNodes)
- {
- Lilv::Node presetNode(presetNodes.get(it));
-
- QString presetURI(presetNode.as_uri());
-
- if (! (presetURI.trimmed().isEmpty() || presetListURIs.contains(presetURI)))
- presetListURIs.append(presetURI);
- }
-
- presetListURIs.sort();
-
- rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.count());
- #else
- juce::StringArray presetListURIs;
-
- LILV_FOREACH(nodes, it, presetNodes)
- {
- Lilv::Node presetNode(presetNodes.get(it));
-
- juce::String presetURI(presetNode.as_uri());
-
- if (presetURI.trim().isNotEmpty())
- presetListURIs.addIfNotAlreadyThere(presetURI);
- }
-
- presetListURIs.sortNatural();
-
- rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.size());
- #endif
-
- // create presets with unique URIs
- rdfDescriptor->Presets = new LV2_RDF_Preset[rdfDescriptor->PresetCount];
-
- // set preset data
- LILV_FOREACH(nodes, it, presetNodes)
- {
- Lilv::Node presetNode(presetNodes.get(it));
-
- const char* const presetURI(presetNode.as_uri());
- CARLA_SAFE_ASSERT_CONTINUE(presetURI != nullptr && presetURI[0] != '\0');
-
- // try to find label without loading the preset resource first
- Lilv::Nodes presetLabelNodes(lv2World.find_nodes(presetNode, lv2World.rdfs_label, nullptr));
-
- // failed, try loading resource
- if (presetLabelNodes.size() == 0)
- {
- // if loading resource fails, skip this preset
- if (lv2World.load_resource(presetNode) == -1)
- continue;
-
- // ok, let's try again
- presetLabelNodes = lv2World.find_nodes(presetNode, lv2World.rdfs_label, nullptr);
- }
-
- if (presetLabelNodes.size() > 0)
- {
- #ifdef USE_QT
- const int index(presetListURIs.indexOf(QString(presetURI)));
- #else
- const int index(presetListURIs.indexOf(juce::String(presetURI)));
- #endif
- CARLA_SAFE_ASSERT_CONTINUE(index >= 0 && index < static_cast<int>(rdfDescriptor->PresetCount));
-
- LV2_RDF_Preset* const rdfPreset(&rdfDescriptor->Presets[index]);
-
- // ---------------------------------------------------
- // Set Preset Information
-
- rdfPreset->URI = carla_strdup(presetURI);
-
- if (const char* const label = presetLabelNodes.get_first().as_string())
- rdfPreset->Label = carla_strdup(label);
-
- lilv_nodes_free(const_cast<LilvNodes*>(presetLabelNodes.me));
- }
- }
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(presetNodes.me));
- }
-
- // -------------------------------------------------------------------
- // Set Plugin Features
- {
- Lilv::Nodes lilvFeatureNodes(lilvPlugin.get_supported_features());
-
- if (lilvFeatureNodes.size() > 0)
- {
- Lilv::Nodes lilvFeatureNodesR(lilvPlugin.get_required_features());
-
- rdfDescriptor->FeatureCount = lilvFeatureNodes.size();
- rdfDescriptor->Features = new LV2_RDF_Feature[rdfDescriptor->FeatureCount];
-
- uint32_t h = 0;
- LILV_FOREACH(nodes, it, lilvFeatureNodes)
- {
- CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->FeatureCount);
-
- Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(it));
- LV2_RDF_Feature* const rdfFeature(&rdfDescriptor->Features[h++]);
-
- rdfFeature->Required = lilvFeatureNodesR.contains(lilvFeatureNode);
-
- if (const char* const featureURI = lilvFeatureNode.as_uri())
- rdfFeature->URI = carla_strdup(featureURI);
- else
- rdfFeature->URI = nullptr;
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodesR.me));
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodes.me));
- }
-
- // -------------------------------------------------------------------
- // Set Plugin Extensions
- {
- Lilv::Nodes lilvExtensionDataNodes(lilvPlugin.get_extension_data());
-
- if (lilvExtensionDataNodes.size() > 0)
- {
- rdfDescriptor->ExtensionCount = lilvExtensionDataNodes.size();
- rdfDescriptor->Extensions = new LV2_URI[rdfDescriptor->ExtensionCount];
-
- uint32_t h = 0;
- LILV_FOREACH(nodes, it, lilvExtensionDataNodes)
- {
- CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->ExtensionCount);
-
- Lilv::Node lilvExtensionDataNode(lilvExtensionDataNodes.get(it));
- LV2_URI* const rdfExtension(&rdfDescriptor->Extensions[h++]);
-
- if (lilvExtensionDataNode.is_uri())
- {
- if (const char* const extURI = lilvExtensionDataNode.as_uri())
- {
- *rdfExtension = carla_strdup(extURI);
- continue;
- }
- }
- *rdfExtension = nullptr;
- }
-
- for (uint32_t x=h; x < rdfDescriptor->ExtensionCount; ++x)
- rdfDescriptor->Extensions[x] = nullptr;
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(lilvExtensionDataNodes.me));
- }
-
- // -------------------------------------------------------------------
- // Set Plugin UIs
- {
- const bool hasMODGui(lilvPlugin.get_modgui_resources_directory().as_uri() != nullptr);
-
- Lilv::UIs lilvUIs(lilvPlugin.get_uis());
-
- if (lilvUIs.size() > 0 || hasMODGui)
- {
- rdfDescriptor->UICount = lilvUIs.size() + (hasMODGui ? 1 : 0);
- rdfDescriptor->UIs = new LV2_RDF_UI[rdfDescriptor->UICount];
-
- uint32_t h = 0;
- LILV_FOREACH(uis, it, lilvUIs)
- {
- CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->UICount);
-
- Lilv::UI lilvUI(lilvUIs.get(it));
- LV2_RDF_UI* const rdfUI(&rdfDescriptor->UIs[h++]);
-
- // -------------------------------------------------------
- // Set UI Type
-
- /**/ if (lilvUI.is_a(lv2World.ui_gtk2))
- rdfUI->Type = LV2_UI_GTK2;
- else if (lilvUI.is_a(lv2World.ui_gtk3))
- rdfUI->Type = LV2_UI_GTK3;
- else if (lilvUI.is_a(lv2World.ui_qt4))
- rdfUI->Type = LV2_UI_QT4;
- else if (lilvUI.is_a(lv2World.ui_qt5))
- rdfUI->Type = LV2_UI_QT5;
- else if (lilvUI.is_a(lv2World.ui_cocoa))
- rdfUI->Type = LV2_UI_COCOA;
- else if (lilvUI.is_a(lv2World.ui_windows))
- rdfUI->Type = LV2_UI_WINDOWS;
- else if (lilvUI.is_a(lv2World.ui_x11))
- rdfUI->Type = LV2_UI_X11;
- else if (lilvUI.is_a(lv2World.ui_external))
- rdfUI->Type = LV2_UI_EXTERNAL;
- else if (lilvUI.is_a(lv2World.ui_externalOld))
- rdfUI->Type = LV2_UI_OLD_EXTERNAL;
- else if (lilvUI.is_a(lv2World.ui_externalOld2))
- pass();
- else
- carla_stderr("lv2_rdf_new(\"%s\") - UI '%s' is of unknown type", uri, lilvUI.get_uri().as_uri());
-
- // -------------------------------------------------------
- // Set UI Information
- {
- if (const char* const uiURI = lilvUI.get_uri().as_uri())
- rdfUI->URI = carla_strdup(uiURI);
-
- if (const char* const uiBinary = lilvUI.get_binary_uri().as_string())
- rdfUI->Binary = carla_strdup_free(lilv_file_uri_parse(uiBinary, nullptr));
-
- if (const char* const uiBundle = lilvUI.get_bundle_uri().as_string())
- rdfUI->Bundle = carla_strdup_free(lilv_file_uri_parse(uiBundle, nullptr));
- }
-
- // -------------------------------------------------------
- // Set UI Features
- {
- Lilv::Nodes lilvFeatureNodes(lilvUI.get_supported_features());
-
- if (lilvFeatureNodes.size() > 0)
- {
- Lilv::Nodes lilvFeatureNodesR(lilvUI.get_required_features());
-
- rdfUI->FeatureCount = lilvFeatureNodes.size();
- rdfUI->Features = new LV2_RDF_Feature[rdfUI->FeatureCount];
-
- uint32_t h2 = 0;
- LILV_FOREACH(nodes, it2, lilvFeatureNodes)
- {
- CARLA_SAFE_ASSERT_BREAK(h2 < rdfUI->FeatureCount);
-
- Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(it2));
- LV2_RDF_Feature* const rdfFeature(&rdfUI->Features[h2++]);
-
- rdfFeature->Required = lilvFeatureNodesR.contains(lilvFeatureNode);
-
- if (const char* const featureURI = lilvFeatureNode.as_uri())
- rdfFeature->URI = carla_strdup(featureURI);
- else
- rdfFeature->URI = nullptr;
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodesR.me));
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodes.me));
- }
-
- // -------------------------------------------------------
- // Set UI Extensions
- {
- Lilv::Nodes lilvExtensionDataNodes(lilvUI.get_extension_data());
-
- if (lilvExtensionDataNodes.size() > 0)
- {
- rdfUI->ExtensionCount = lilvExtensionDataNodes.size();
- rdfUI->Extensions = new LV2_URI[rdfUI->ExtensionCount];
-
- uint32_t h2 = 0;
- LILV_FOREACH(nodes, it2, lilvExtensionDataNodes)
- {
- CARLA_SAFE_ASSERT_BREAK(h2 < rdfUI->ExtensionCount);
-
- Lilv::Node lilvExtensionDataNode(lilvExtensionDataNodes.get(it2));
- LV2_URI* const rdfExtension(&rdfUI->Extensions[h2++]);
-
- if (lilvExtensionDataNode.is_uri())
- {
- if (const char* const extURI = lilvExtensionDataNode.as_uri())
- {
- *rdfExtension = carla_strdup(extURI);
- continue;
- }
- }
- *rdfExtension = nullptr;
- }
-
- for (uint32_t x2=h2; x2 < rdfUI->ExtensionCount; ++x2)
- rdfUI->Extensions[x2] = nullptr;
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(lilvExtensionDataNodes.me));
- }
- }
-
- for (; hasMODGui;)
- {
- CARLA_SAFE_ASSERT_BREAK(h == rdfDescriptor->UICount-1);
-
- LV2_RDF_UI* const rdfUI(&rdfDescriptor->UIs[h++]);
-
- // -------------------------------------------------------
- // Set UI Type
-
- rdfUI->Type = LV2_UI_MOD;
-
- // -------------------------------------------------------
- // Set UI Information
-
- if (const char* const resDir = lilvPlugin.get_modgui_resources_directory().as_uri())
- rdfUI->URI = carla_strdup_free(lilv_file_uri_parse(resDir, nullptr));
-
- if (rdfDescriptor->Bundle != nullptr)
- rdfUI->Bundle = carla_strdup(rdfDescriptor->Bundle);
-
- break;
- }
- }
-
- lilv_nodes_free(const_cast<LilvNodes*>(lilvUIs.me));
- }
-
- return rdfDescriptor;
- }
-
- // -----------------------------------------------------------------------
- // Check if we support a plugin port
-
- static inline
- bool is_lv2_port_supported(const LV2_Property types) noexcept
- {
- if (LV2_IS_PORT_CONTROL(types))
- return true;
- if (LV2_IS_PORT_AUDIO(types))
- return true;
- if (LV2_IS_PORT_CV(types))
- return true;
- if (LV2_IS_PORT_ATOM_SEQUENCE(types))
- return true;
- if (LV2_IS_PORT_EVENT(types))
- return true;
- if (LV2_IS_PORT_MIDI_LL(types))
- return true;
- return false;
- }
-
- // -----------------------------------------------------------------------
- // Check if we support a plugin feature
-
- static inline
- bool is_lv2_feature_supported(const LV2_URI uri) noexcept
- {
- CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', false);
-
- if (std::strcmp(uri, LV2_BUF_SIZE__boundedBlockLength) == 0)
- return true;
- if (std::strcmp(uri, LV2_BUF_SIZE__fixedBlockLength) == 0)
- return true;
- if (std::strcmp(uri, LV2_BUF_SIZE__powerOf2BlockLength) == 0)
- return true;
- if (std::strcmp(uri, LV2_CORE__hardRTCapable) == 0)
- return true;
- if (std::strcmp(uri, LV2_CORE__inPlaceBroken) == 0)
- return true;
- if (std::strcmp(uri, LV2_CORE__isLive) == 0)
- return true;
- if (std::strcmp(uri, LV2_EVENT_URI) == 0)
- return true;
- if (std::strcmp(uri, LV2_LOG__log) == 0)
- return true;
- if (std::strcmp(uri, LV2_OPTIONS__options) == 0)
- return true;
- if (std::strcmp(uri, LV2_PROGRAMS__Host) == 0)
- return true;
- if (std::strcmp(uri, LV2_RESIZE_PORT__resize) == 0)
- return true;
- if (std::strcmp(uri, LV2_RTSAFE_MEMORY_POOL__Pool) == 0)
- return true;
- if (std::strcmp(uri, LV2_RTSAFE_MEMORY_POOL_DEPRECATED_URI) == 0)
- return true;
- if (std::strcmp(uri, LV2_STATE__loadDefaultState) == 0)
- return true;
- if (std::strcmp(uri, LV2_STATE__makePath) == 0)
- return true;
- if (std::strcmp(uri, LV2_STATE__mapPath) == 0)
- return true;
- if (std::strcmp(uri, LV2_PORT_PROPS__supportsStrictBounds) == 0)
- return true;
- if (std::strcmp(uri, LV2_URI_MAP_URI) == 0)
- return true;
- if (std::strcmp(uri, LV2_URID__map) == 0)
- return true;
- if (std::strcmp(uri, LV2_URID__unmap) == 0)
- return true;
- if (std::strcmp(uri, LV2_WORKER__schedule) == 0)
- return true;
- return false;
- }
-
- // -----------------------------------------------------------------------
- // Check if we support a plugin or UI feature
-
- static inline
- bool is_lv2_ui_feature_supported(const LV2_URI uri) noexcept
- {
- CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', false);
-
- if (is_lv2_feature_supported(uri))
- return true;
- #ifndef BUILD_BRIDGE_UI
- if (std::strcmp(uri, LV2_DATA_ACCESS_URI) == 0)
- return true;
- if (std::strcmp(uri, LV2_INSTANCE_ACCESS_URI) == 0)
- return true;
- #endif
- if (std::strcmp(uri, LV2_UI__fixedSize) == 0)
- return true;
- if (std::strcmp(uri, LV2_UI__idleInterface) == 0)
- return true;
- if (std::strcmp(uri, LV2_UI__makeResident) == 0)
- return true;
- if (std::strcmp(uri, LV2_UI__makeSONameResident) == 0)
- return true;
- if (std::strcmp(uri, LV2_UI__noUserResize) == 0)
- return true;
- if (std::strcmp(uri, LV2_UI__parent) == 0)
- return true;
- if (std::strcmp(uri, LV2_UI__portMap) == 0)
- return true;
- if (std::strcmp(uri, LV2_UI__portSubscribe) == 0)
- return true;
- if (std::strcmp(uri, LV2_UI__resize) == 0)
- return true;
- if (std::strcmp(uri, LV2_UI__touch) == 0)
- return true;
- if (std::strcmp(uri, LV2_EXTERNAL_UI__Widget) == 0)
- return true;
- if (std::strcmp(uri, LV2_EXTERNAL_UI_DEPRECATED_URI) == 0)
- return true;
- return false;
- }
-
- // -----------------------------------------------------------------------
-
- #endif // CARLA_LV2_UTILS_HPP_INCLUDED
|