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.

CarlaHostCommon.cpp 25KB

10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. /*
  2. * Carla Plugin Host
  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. #include "CarlaHost.h"
  18. #include "CarlaNative.h"
  19. #include "CarlaLv2Utils.hpp"
  20. #include "CarlaPlugin.hpp"
  21. #include "CarlaString.hpp"
  22. #include "juce_audio_formats.h"
  23. #ifdef CARLA_OS_MAC
  24. # include "juce_audio_processors.h"
  25. using juce::AudioUnitPluginFormat;
  26. using juce::StringArray;
  27. #endif
  28. namespace CB = CarlaBackend;
  29. // -------------------------------------------------------------------------------------------------------------------
  30. // Always return a valid string ptr
  31. static const char* const gNullCharPtr = "";
  32. #ifdef CARLA_COMMON_NEED_CHECKSTRINGPTR
  33. static void checkStringPtr(const char*& charPtr) noexcept
  34. {
  35. if (charPtr == nullptr)
  36. charPtr = gNullCharPtr;
  37. }
  38. #endif
  39. // -------------------------------------------------------------------------------------------------------------------
  40. // Constructors
  41. _CarlaPluginInfo::_CarlaPluginInfo() noexcept
  42. : type(CB::PLUGIN_NONE),
  43. category(CB::PLUGIN_CATEGORY_NONE),
  44. hints(0x0),
  45. optionsAvailable(0x0),
  46. optionsEnabled(0x0),
  47. filename(gNullCharPtr),
  48. name(gNullCharPtr),
  49. label(gNullCharPtr),
  50. maker(gNullCharPtr),
  51. copyright(gNullCharPtr),
  52. iconName(gNullCharPtr),
  53. uniqueId(0) {}
  54. _CarlaPluginInfo::~_CarlaPluginInfo() noexcept
  55. {
  56. if (label != gNullCharPtr)
  57. delete[] label;
  58. if (maker != gNullCharPtr)
  59. delete[] maker;
  60. if (copyright != gNullCharPtr)
  61. delete[] copyright;
  62. }
  63. _CarlaCachedPluginInfo::_CarlaCachedPluginInfo() noexcept
  64. : category(CB::PLUGIN_CATEGORY_NONE),
  65. hints(0x0),
  66. audioIns(0),
  67. audioOuts(0),
  68. midiIns(0),
  69. midiOuts(0),
  70. parameterIns(0),
  71. parameterOuts(0),
  72. name(gNullCharPtr),
  73. label(gNullCharPtr),
  74. maker(gNullCharPtr),
  75. copyright(gNullCharPtr) {}
  76. _CarlaParameterInfo::_CarlaParameterInfo() noexcept
  77. : name(gNullCharPtr),
  78. symbol(gNullCharPtr),
  79. unit(gNullCharPtr),
  80. scalePointCount(0) {}
  81. _CarlaParameterInfo::~_CarlaParameterInfo() noexcept
  82. {
  83. if (name != gNullCharPtr)
  84. delete[] name;
  85. if (symbol != gNullCharPtr)
  86. delete[] symbol;
  87. if (unit != gNullCharPtr)
  88. delete[] unit;
  89. }
  90. _CarlaScalePointInfo::_CarlaScalePointInfo() noexcept
  91. : value(0.0f),
  92. label(gNullCharPtr) {}
  93. _CarlaScalePointInfo::~_CarlaScalePointInfo() noexcept
  94. {
  95. if (label != gNullCharPtr)
  96. delete[] label;
  97. }
  98. _CarlaTransportInfo::_CarlaTransportInfo() noexcept
  99. : playing(false),
  100. frame(0),
  101. bar(0),
  102. beat(0),
  103. tick(0),
  104. bpm(0.0) {}
  105. // -------------------------------------------------------------------------------------------------------------------
  106. const char* carla_get_complete_license_text()
  107. {
  108. carla_debug("carla_get_complete_license_text()");
  109. static CarlaString retText;
  110. if (retText.isEmpty())
  111. {
  112. retText =
  113. "<p>This current Carla build is using the following features and 3rd-party code:</p>"
  114. "<ul>"
  115. // Plugin formats
  116. "<li>LADSPA plugin support</li>"
  117. "<li>DSSI plugin support</li>"
  118. "<li>LV2 plugin support</li>"
  119. #ifdef VESTIGE_HEADER
  120. "<li>VST2 plugin support using VeSTige header by Javier Serrano Polo</li>"
  121. #else
  122. "<li>VST2 plugin support using official VST SDK 2.4 [1]</li>"
  123. #endif
  124. #if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)
  125. "<li>VST3 plugin support using official VST SDK 3.6 [1]</li>"
  126. #endif
  127. #ifdef CARLA_OS_MAC
  128. "<li>AU plugin support</li>"
  129. #endif
  130. // Sample kit libraries
  131. #ifdef HAVE_FLUIDSYNTH
  132. "<li>FluidSynth library for SF2 support</li>"
  133. #endif
  134. #ifdef HAVE_LINUXSAMPLER
  135. "<li>LinuxSampler library for GIG and SFZ support [2]</li>"
  136. #endif
  137. // Internal plugins
  138. "<li>NekoFilter plugin code based on lv2fil by Nedko Arnaudov and Fons Adriaensen</li>"
  139. #ifdef WANT_ZYNADDSUBFX
  140. "<li>ZynAddSubFX plugin code</li>"
  141. #endif
  142. // misc libs
  143. "<li>base64 utilities based on code by Ren\u00E9 Nyffenegger</li>"
  144. #ifdef CARLA_OS_MAC
  145. "<li>sem_timedwait for Mac OS by Keith Shortridge</li>"
  146. #endif
  147. "<li>liblo library for OSC support</li>"
  148. "<li>rtmempool library by Nedko Arnaudov"
  149. "<li>serd, sord, sratom and lilv libraries for LV2 discovery</li>"
  150. #if ! (defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN))
  151. "<li>RtAudio and RtMidi libraries for extra Audio and MIDI support</li>"
  152. #endif
  153. // end
  154. "</ul>"
  155. "<p>"
  156. #if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN) || ! defined(VESTIGE_HEADER)
  157. // Required by VST SDK
  158. "&nbsp;[1] Trademark of Steinberg Media Technologies GmbH.<br/>"
  159. #endif
  160. #ifdef HAVE_LINUXSAMPLER
  161. // LinuxSampler GPL exception
  162. "&nbsp;[2] Using LinuxSampler code in commercial hardware or software products is not allowed without prior written authorization by the authors."
  163. #endif
  164. "</p>"
  165. ;
  166. }
  167. return retText;
  168. }
  169. const char* carla_get_juce_version()
  170. {
  171. carla_debug("carla_get_juce_version()");
  172. static CarlaString retVersion;
  173. if (retVersion.isEmpty())
  174. {
  175. if (const char* const version = juce::SystemStats::getJUCEVersion().toRawUTF8())
  176. retVersion = version+6;
  177. else
  178. retVersion = "3.0";
  179. }
  180. return retVersion;
  181. }
  182. const char* carla_get_supported_file_extensions()
  183. {
  184. carla_debug("carla_get_supported_file_extensions()");
  185. static CarlaString retText;
  186. if (retText.isEmpty())
  187. {
  188. retText =
  189. // Base types
  190. "*.carxp;*.carxs"
  191. // MIDI files
  192. ";*.mid;*.midi"
  193. #ifdef HAVE_FLUIDSYNTH
  194. // fluidsynth (sf2)
  195. ";*.sf2"
  196. #endif
  197. #ifdef HAVE_LINUXSAMPLER
  198. // linuxsampler (gig and sfz)
  199. ";*.gig;*.sfz"
  200. #endif
  201. #ifdef WANT_ZYNADDSUBFX
  202. // zynaddsubfx presets
  203. ";*.xmz;*.xiz"
  204. #endif
  205. ;
  206. #ifndef BUILD_BRIDGE
  207. // Audio files
  208. {
  209. using namespace juce;
  210. AudioFormatManager afm;
  211. afm.registerBasicFormats();
  212. String juceFormats;
  213. for (AudioFormat **it=afm.begin(), **end=afm.end(); it != end; ++it)
  214. {
  215. const StringArray& exts((*it)->getFileExtensions());
  216. for (String *eit=exts.begin(), *eend=exts.end(); eit != eend; ++eit)
  217. juceFormats += String(";*" + (*eit)).toRawUTF8();
  218. }
  219. retText += juceFormats.toRawUTF8();
  220. }
  221. #endif
  222. }
  223. return retText;
  224. }
  225. // -------------------------------------------------------------------------------------------------------------------
  226. #ifdef CARLA_OS_MAC
  227. static StringArray gCachedAuPluginResults;
  228. #endif
  229. uint carla_get_cached_plugin_count(PluginType ptype, const char* pluginPath)
  230. {
  231. CARLA_SAFE_ASSERT_RETURN(ptype == CB::PLUGIN_INTERNAL || ptype == CB::PLUGIN_LV2 || ptype == CB::PLUGIN_AU, 0);
  232. carla_debug("carla_get_cached_plugin_count(%i:%s)", ptype, CB::PluginType2Str(ptype));
  233. switch (ptype)
  234. {
  235. case CB::PLUGIN_INTERNAL: {
  236. #ifndef BUILD_BRIDGE
  237. return static_cast<uint>(CarlaPlugin::getNativePluginCount());
  238. #else
  239. return 0;
  240. #endif
  241. }
  242. case CB::PLUGIN_LV2: {
  243. Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());
  244. lv2World.initIfNeeded(pluginPath);
  245. return lv2World.getPluginCount();
  246. }
  247. case CB::PLUGIN_AU: {
  248. #ifdef CARLA_OS_MAC
  249. static bool initiated = false;
  250. if (initiated)
  251. return static_cast<uint>(gCachedAuPluginResults.size());
  252. initiated = true;
  253. AudioUnitPluginFormat auFormat;
  254. gCachedAuPluginResults = auFormat.searchPathsForPlugins(juce::FileSearchPath(), false);
  255. return static_cast<uint>(gCachedAuPluginResults.size());
  256. #else
  257. return 0;
  258. #endif
  259. }
  260. default:
  261. return 0;
  262. }
  263. }
  264. const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginType ptype, uint index)
  265. {
  266. carla_debug("carla_get_cached_plugin_info(%i:%s, %i)", ptype, CB::PluginType2Str(ptype), index);
  267. static CarlaCachedPluginInfo info;
  268. switch (ptype)
  269. {
  270. case CB::PLUGIN_INTERNAL: {
  271. #ifndef BUILD_BRIDGE
  272. const NativePluginDescriptor* const desc(CarlaPlugin::getNativePluginDescriptor(index));
  273. CARLA_SAFE_ASSERT_BREAK(desc != nullptr);
  274. info.category = static_cast<CB::PluginCategory>(desc->category);
  275. info.hints = 0x0;
  276. if (desc->hints & NATIVE_PLUGIN_IS_RTSAFE)
  277. info.hints |= CB::PLUGIN_IS_RTSAFE;
  278. if (desc->hints & NATIVE_PLUGIN_IS_SYNTH)
  279. info.hints |= CB::PLUGIN_IS_SYNTH;
  280. if (desc->hints & NATIVE_PLUGIN_HAS_UI)
  281. info.hints |= CB::PLUGIN_HAS_CUSTOM_UI;
  282. if (desc->hints & NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS)
  283. info.hints |= CB::PLUGIN_NEEDS_FIXED_BUFFERS;
  284. if (desc->hints & NATIVE_PLUGIN_NEEDS_SINGLE_THREAD)
  285. info.hints |= CB::PLUGIN_NEEDS_SINGLE_THREAD;
  286. info.audioIns = desc->audioIns;
  287. info.audioOuts = desc->audioOuts;
  288. info.midiIns = desc->midiIns;
  289. info.midiOuts = desc->midiOuts;
  290. info.parameterIns = desc->paramIns;
  291. info.parameterOuts = desc->paramOuts;
  292. info.name = desc->name;
  293. info.label = desc->label;
  294. info.maker = desc->maker;
  295. info.copyright = desc->copyright;
  296. return &info;
  297. #else
  298. break;
  299. #endif
  300. }
  301. case CB::PLUGIN_LV2: {
  302. Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());
  303. const LilvPlugin* const cPlugin(lv2World.getPluginFromIndex(index));
  304. CARLA_SAFE_ASSERT_BREAK(cPlugin != nullptr);
  305. Lilv::Plugin lilvPlugin(cPlugin);
  306. CARLA_SAFE_ASSERT_BREAK(lilvPlugin.get_uri().is_uri());
  307. carla_stdout("Filling info for LV2 with URI '%s'", lilvPlugin.get_uri().as_uri());
  308. // features
  309. info.hints = 0x0;
  310. if (lilvPlugin.get_uis().size() > 0 || lilvPlugin.get_modgui_resources_directory().as_uri() != nullptr)
  311. info.hints |= CB::PLUGIN_HAS_CUSTOM_UI;
  312. {
  313. Lilv::Nodes lilvFeatureNodes(lilvPlugin.get_supported_features());
  314. LILV_FOREACH(nodes, it, lilvFeatureNodes)
  315. {
  316. Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(it));
  317. const char* const featureURI(lilvFeatureNode.as_uri());
  318. CARLA_SAFE_ASSERT_CONTINUE(featureURI != nullptr);
  319. if (std::strcmp(featureURI, LV2_CORE__hardRTCapable) == 0)
  320. info.hints |= CB::PLUGIN_IS_RTSAFE;
  321. }
  322. lilv_nodes_free(const_cast<LilvNodes*>(lilvFeatureNodes.me));
  323. }
  324. // category
  325. info.category = CB::PLUGIN_CATEGORY_NONE;
  326. {
  327. Lilv::Nodes typeNodes(lilvPlugin.get_value(lv2World.rdf_type));
  328. if (typeNodes.size() > 0)
  329. {
  330. if (typeNodes.contains(lv2World.class_allpass))
  331. info.category = CB::PLUGIN_CATEGORY_FILTER;
  332. if (typeNodes.contains(lv2World.class_amplifier))
  333. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  334. if (typeNodes.contains(lv2World.class_analyzer))
  335. info.category = CB::PLUGIN_CATEGORY_UTILITY;
  336. if (typeNodes.contains(lv2World.class_bandpass))
  337. info.category = CB::PLUGIN_CATEGORY_FILTER;
  338. if (typeNodes.contains(lv2World.class_chorus))
  339. info.category = CB::PLUGIN_CATEGORY_MODULATOR;
  340. if (typeNodes.contains(lv2World.class_comb))
  341. info.category = CB::PLUGIN_CATEGORY_FILTER;
  342. if (typeNodes.contains(lv2World.class_compressor))
  343. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  344. if (typeNodes.contains(lv2World.class_constant))
  345. info.category = CB::PLUGIN_CATEGORY_OTHER;
  346. if (typeNodes.contains(lv2World.class_converter))
  347. info.category = CB::PLUGIN_CATEGORY_UTILITY;
  348. if (typeNodes.contains(lv2World.class_delay))
  349. info.category = CB::PLUGIN_CATEGORY_DELAY;
  350. if (typeNodes.contains(lv2World.class_distortion))
  351. info.category = CB::PLUGIN_CATEGORY_DISTORTION;
  352. if (typeNodes.contains(lv2World.class_dynamics))
  353. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  354. if (typeNodes.contains(lv2World.class_eq))
  355. info.category = CB::PLUGIN_CATEGORY_EQ;
  356. if (typeNodes.contains(lv2World.class_envelope))
  357. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  358. if (typeNodes.contains(lv2World.class_expander))
  359. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  360. if (typeNodes.contains(lv2World.class_filter))
  361. info.category = CB::PLUGIN_CATEGORY_FILTER;
  362. if (typeNodes.contains(lv2World.class_flanger))
  363. info.category = CB::PLUGIN_CATEGORY_MODULATOR;
  364. if (typeNodes.contains(lv2World.class_function))
  365. info.category = CB::PLUGIN_CATEGORY_UTILITY;
  366. if (typeNodes.contains(lv2World.class_gate))
  367. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  368. if (typeNodes.contains(lv2World.class_generator))
  369. info.category = CB::PLUGIN_CATEGORY_OTHER;
  370. if (typeNodes.contains(lv2World.class_highpass))
  371. info.category = CB::PLUGIN_CATEGORY_FILTER;
  372. if (typeNodes.contains(lv2World.class_limiter))
  373. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  374. if (typeNodes.contains(lv2World.class_lowpass))
  375. info.category = CB::PLUGIN_CATEGORY_FILTER;
  376. if (typeNodes.contains(lv2World.class_mixer))
  377. info.category = CB::PLUGIN_CATEGORY_UTILITY;
  378. if (typeNodes.contains(lv2World.class_modulator))
  379. info.category = CB::PLUGIN_CATEGORY_MODULATOR;
  380. if (typeNodes.contains(lv2World.class_multiEQ))
  381. info.category = CB::PLUGIN_CATEGORY_EQ;
  382. if (typeNodes.contains(lv2World.class_oscillator))
  383. info.category = CB::PLUGIN_CATEGORY_OTHER;
  384. if (typeNodes.contains(lv2World.class_paraEQ))
  385. info.category = CB::PLUGIN_CATEGORY_EQ;
  386. if (typeNodes.contains(lv2World.class_phaser))
  387. info.category = CB::PLUGIN_CATEGORY_MODULATOR;
  388. if (typeNodes.contains(lv2World.class_pitch))
  389. info.category = CB::PLUGIN_CATEGORY_OTHER;
  390. if (typeNodes.contains(lv2World.class_reverb))
  391. info.category = CB::PLUGIN_CATEGORY_DELAY;
  392. if (typeNodes.contains(lv2World.class_simulator))
  393. info.category = CB::PLUGIN_CATEGORY_OTHER;
  394. if (typeNodes.contains(lv2World.class_spatial))
  395. info.category = CB::PLUGIN_CATEGORY_OTHER;
  396. if (typeNodes.contains(lv2World.class_spectral))
  397. info.category = CB::PLUGIN_CATEGORY_OTHER;
  398. if (typeNodes.contains(lv2World.class_utility))
  399. info.category = CB::PLUGIN_CATEGORY_UTILITY;
  400. if (typeNodes.contains(lv2World.class_waveshaper))
  401. info.category = CB::PLUGIN_CATEGORY_DISTORTION;
  402. if (typeNodes.contains(lv2World.class_instrument))
  403. {
  404. info.category = CB::PLUGIN_CATEGORY_SYNTH;
  405. info.hints |= CB::PLUGIN_IS_SYNTH;
  406. }
  407. }
  408. lilv_nodes_free(const_cast<LilvNodes*>(typeNodes.me));
  409. }
  410. // number data
  411. info.audioIns = 0;
  412. info.audioOuts = 0;
  413. info.midiIns = 0;
  414. info.midiOuts = 0;
  415. info.parameterIns = 0;
  416. info.parameterOuts = 0;
  417. for (uint i=0, count=lilvPlugin.get_num_ports(); i<count; ++i)
  418. {
  419. Lilv::Port lilvPort(lilvPlugin.get_port_by_index(i));
  420. bool isInput;
  421. /**/ if (lilvPort.is_a(lv2World.port_input))
  422. isInput = true;
  423. else if (lilvPort.is_a(lv2World.port_output))
  424. isInput = false;
  425. else
  426. continue;
  427. /**/ if (lilvPort.is_a(lv2World.port_control))
  428. {
  429. // skip some control ports
  430. if (lilvPort.has_property(lv2World.reportsLatency))
  431. continue;
  432. if (LilvNode* const designationNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.designation.me))
  433. {
  434. bool skip = false;
  435. if (const char* const designation = lilv_node_as_string(designationNode))
  436. {
  437. /**/ if (std::strcmp(designation, LV2_CORE__control) == 0)
  438. skip = true;
  439. else if (std::strcmp(designation, LV2_CORE__freeWheeling) == 0)
  440. skip = true;
  441. else if (std::strcmp(designation, LV2_CORE__latency) == 0)
  442. skip = true;
  443. else if (std::strcmp(designation, LV2_PARAMETERS__sampleRate) == 0)
  444. skip = true;
  445. else if (std::strcmp(designation, LV2_TIME__bar) == 0)
  446. skip = true;
  447. else if (std::strcmp(designation, LV2_TIME__barBeat) == 0)
  448. skip = true;
  449. else if (std::strcmp(designation, LV2_TIME__beat) == 0)
  450. skip = true;
  451. else if (std::strcmp(designation, LV2_TIME__beatUnit) == 0)
  452. skip = true;
  453. else if (std::strcmp(designation, LV2_TIME__beatsPerBar) == 0)
  454. skip = true;
  455. else if (std::strcmp(designation, LV2_TIME__beatsPerMinute) == 0)
  456. skip = true;
  457. else if (std::strcmp(designation, LV2_TIME__frame) == 0)
  458. skip = true;
  459. else if (std::strcmp(designation, LV2_TIME__framesPerSecond) == 0)
  460. skip = true;
  461. else if (std::strcmp(designation, LV2_TIME__speed) == 0)
  462. skip = true;
  463. else if (std::strcmp(designation, LV2_KXSTUDIO_PROPERTIES__TimePositionTicksPerBeat) == 0)
  464. skip = true;
  465. }
  466. lilv_node_free(designationNode);
  467. if (skip)
  468. continue;
  469. }
  470. if (isInput)
  471. ++(info.parameterIns);
  472. else
  473. ++(info.parameterOuts);
  474. }
  475. else if (lilvPort.is_a(lv2World.port_audio))
  476. {
  477. if (isInput)
  478. ++(info.audioIns);
  479. else
  480. ++(info.audioOuts);
  481. }
  482. else if (lilvPort.is_a(lv2World.port_cv))
  483. {
  484. }
  485. else if (lilvPort.is_a(lv2World.port_atom))
  486. {
  487. Lilv::Nodes supportNodes(lilvPort.get_value(lv2World.atom_supports));
  488. for (LilvIter *it = lilv_nodes_begin(supportNodes.me); ! lilv_nodes_is_end(supportNodes.me, it); it = lilv_nodes_next(supportNodes.me, it))
  489. {
  490. const Lilv::Node node(lilv_nodes_get(supportNodes.me, it));
  491. CARLA_SAFE_ASSERT_CONTINUE(node.is_uri());
  492. if (node.equals(lv2World.midi_event))
  493. {
  494. if (isInput)
  495. ++(info.midiIns);
  496. else
  497. ++(info.midiOuts);
  498. }
  499. }
  500. lilv_nodes_free(const_cast<LilvNodes*>(supportNodes.me));
  501. }
  502. else if (lilvPort.is_a(lv2World.port_event))
  503. {
  504. if (lilvPort.supports_event(lv2World.midi_event))
  505. {
  506. if (isInput)
  507. ++(info.midiIns);
  508. else
  509. ++(info.midiOuts);
  510. }
  511. }
  512. else if (lilvPort.is_a(lv2World.port_midi))
  513. {
  514. if (isInput)
  515. ++(info.midiIns);
  516. else
  517. ++(info.midiOuts);
  518. }
  519. }
  520. // text data
  521. static CarlaString suri, sname, smaker, slicense;
  522. suri.clear(); sname.clear(); smaker.clear(); slicense.clear();
  523. suri = lilvPlugin.get_uri().as_uri();
  524. if (const char* const name = lilvPlugin.get_name().as_string())
  525. sname = name;
  526. else
  527. sname.clear();
  528. if (const char* const author = lilvPlugin.get_author_name().as_string())
  529. smaker = author;
  530. else
  531. smaker.clear();
  532. Lilv::Nodes licenseNodes(lilvPlugin.get_value(lv2World.doap_license));
  533. if (licenseNodes.size() > 0)
  534. {
  535. if (const char* const license = licenseNodes.get_first().as_string())
  536. slicense = license;
  537. }
  538. lilv_nodes_free(const_cast<LilvNodes*>(licenseNodes.me));
  539. info.name = sname;
  540. info.label = suri;
  541. info.maker = smaker;
  542. info.copyright = slicense;
  543. return &info;
  544. }
  545. case CB::PLUGIN_AU: {
  546. #ifdef CARLA_OS_MAC
  547. const int indexi(static_cast<int>(index));
  548. CARLA_SAFE_ASSERT_BREAK(indexi < gCachedAuPluginResults.size());
  549. using namespace juce;
  550. String pluginId(gCachedAuPluginResults[indexi]);
  551. OwnedArray<PluginDescription> results;
  552. AudioUnitPluginFormat auFormat;
  553. auFormat.findAllTypesForFile(results, pluginId);
  554. CARLA_SAFE_ASSERT_BREAK(results.size() > 0);
  555. CARLA_SAFE_ASSERT(results.size() == 1);
  556. PluginDescription* const desc(results[0]);
  557. CARLA_SAFE_ASSERT_BREAK(desc != nullptr);
  558. info.category = CB::getPluginCategoryFromName(desc->category.toRawUTF8());
  559. info.hints = 0x0;
  560. if (desc->isInstrument)
  561. info.hints |= CB::PLUGIN_IS_SYNTH;
  562. if (true)
  563. info.hints |= CB::PLUGIN_HAS_CUSTOM_UI;
  564. info.audioIns = static_cast<uint32_t>(desc->numInputChannels);
  565. info.audioOuts = static_cast<uint32_t>(desc->numOutputChannels);
  566. info.midiIns = desc->isInstrument ? 1 : 0;
  567. info.midiOuts = 0;
  568. info.parameterIns = 0;
  569. info.parameterOuts = 0;
  570. static CarlaString sname, slabel, smaker;
  571. sname = desc->name.toRawUTF8();
  572. slabel = desc->fileOrIdentifier.toRawUTF8();
  573. smaker = desc->manufacturerName.toRawUTF8();
  574. info.name = sname;
  575. info.label = slabel;
  576. info.maker = smaker;
  577. info.copyright = gNullCharPtr;
  578. return &info;
  579. #else
  580. break;
  581. #endif
  582. }
  583. default:
  584. break;
  585. }
  586. info.category = CB::PLUGIN_CATEGORY_NONE;
  587. info.hints = 0x0;
  588. info.audioIns = 0;
  589. info.audioOuts = 0;
  590. info.midiIns = 0;
  591. info.midiOuts = 0;
  592. info.parameterIns = 0;
  593. info.parameterOuts = 0;
  594. info.name = gNullCharPtr;
  595. info.label = gNullCharPtr;
  596. info.maker = gNullCharPtr;
  597. info.copyright = gNullCharPtr;
  598. return &info;
  599. }
  600. // -------------------------------------------------------------------------------------------------------------------
  601. const char* carla_get_library_filename()
  602. {
  603. carla_debug("carla_get_library_filename()");
  604. static CarlaString ret;
  605. if (ret.isEmpty())
  606. {
  607. using juce::File;
  608. ret = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName().toRawUTF8();
  609. }
  610. return ret;
  611. }
  612. const char* carla_get_library_folder()
  613. {
  614. carla_debug("carla_get_library_folder()");
  615. static CarlaString ret;
  616. if (ret.isEmpty())
  617. {
  618. using juce::File;
  619. ret = File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName().toRawUTF8();
  620. }
  621. return ret;
  622. }
  623. // -------------------------------------------------------------------------------------------------------------------