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.

705 lines
25KB

  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2019 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 "CarlaUtils.h"
  18. #include "CarlaNative.h"
  19. #include "CarlaString.hpp"
  20. #include "CarlaBackendUtils.hpp"
  21. #include "CarlaLv2Utils.hpp"
  22. #if defined(USING_JUCE) && defined(CARLA_OS_MAC)
  23. # include "AppConfig.h"
  24. # include "juce_audio_processors/juce_audio_processors.h"
  25. #endif
  26. #include "water/containers/Array.h"
  27. #include "water/files/File.h"
  28. namespace CB = CarlaBackend;
  29. using water::Array;
  30. using water::File;
  31. using water::String;
  32. using water::StringArray;
  33. // -------------------------------------------------------------------------------------------------------------------
  34. static const char* const gNullCharPtr = "";
  35. static bool isCachedPluginType(const CB::PluginType ptype)
  36. {
  37. switch (ptype)
  38. {
  39. case CB::PLUGIN_INTERNAL:
  40. case CB::PLUGIN_LV2:
  41. case CB::PLUGIN_AU:
  42. case CB::PLUGIN_SFZ:
  43. return true;
  44. default:
  45. return false;
  46. }
  47. }
  48. // -------------------------------------------------------------------------------------------------------------------
  49. _CarlaCachedPluginInfo::_CarlaCachedPluginInfo() noexcept
  50. : valid(false),
  51. category(CB::PLUGIN_CATEGORY_NONE),
  52. hints(0x0),
  53. audioIns(0),
  54. audioOuts(0),
  55. cvIns(0),
  56. cvOuts(0),
  57. midiIns(0),
  58. midiOuts(0),
  59. parameterIns(0),
  60. parameterOuts(0),
  61. name(gNullCharPtr),
  62. label(gNullCharPtr),
  63. maker(gNullCharPtr),
  64. copyright(gNullCharPtr) {}
  65. // -------------------------------------------------------------------------------------------------------------------
  66. static Array<File> gSFZs;
  67. static void findSFZs(const char* const sfzPaths)
  68. {
  69. gSFZs.clearQuick();
  70. CARLA_SAFE_ASSERT_RETURN(sfzPaths != nullptr,);
  71. if (sfzPaths[0] == '\0')
  72. return;
  73. const StringArray splitPaths(StringArray::fromTokens(sfzPaths, CARLA_OS_SPLIT_STR, ""));
  74. for (String *it = splitPaths.begin(), *end = splitPaths.end(); it != end; ++it)
  75. {
  76. Array<File> results;
  77. if (File(*it).findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, true, "*.sfz") > 0)
  78. gSFZs.addArray(results);
  79. }
  80. }
  81. // -------------------------------------------------------------------------------------------------------------------
  82. static const CarlaCachedPluginInfo* get_cached_plugin_internal(const NativePluginDescriptor& desc)
  83. {
  84. static CarlaCachedPluginInfo info;
  85. info.category = static_cast<CB::PluginCategory>(desc.category);
  86. info.hints = 0x0;
  87. if (desc.hints & NATIVE_PLUGIN_IS_RTSAFE)
  88. info.hints |= CB::PLUGIN_IS_RTSAFE;
  89. if (desc.hints & NATIVE_PLUGIN_IS_SYNTH)
  90. info.hints |= CB::PLUGIN_IS_SYNTH;
  91. if (desc.hints & NATIVE_PLUGIN_HAS_UI)
  92. info.hints |= CB::PLUGIN_HAS_CUSTOM_UI;
  93. if (desc.hints & NATIVE_PLUGIN_HAS_INLINE_DISPLAY)
  94. info.hints |= CB::PLUGIN_HAS_INLINE_DISPLAY;
  95. if (desc.hints & NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS)
  96. info.hints |= CB::PLUGIN_NEEDS_FIXED_BUFFERS;
  97. if (desc.hints & NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD)
  98. info.hints |= CB::PLUGIN_NEEDS_UI_MAIN_THREAD;
  99. if (desc.hints & NATIVE_PLUGIN_USES_MULTI_PROGS)
  100. info.hints |= CB::PLUGIN_USES_MULTI_PROGS;
  101. info.valid = true;
  102. info.audioIns = desc.audioIns;
  103. info.audioOuts = desc.audioOuts;
  104. info.cvIns = desc.cvIns;
  105. info.cvOuts = desc.cvOuts;
  106. info.midiIns = desc.midiIns;
  107. info.midiOuts = desc.midiOuts;
  108. info.parameterIns = desc.paramIns;
  109. info.parameterOuts = desc.paramOuts;
  110. info.name = desc.name;
  111. info.label = desc.label;
  112. info.maker = desc.maker;
  113. info.copyright = desc.copyright;
  114. return &info;
  115. }
  116. // -------------------------------------------------------------------------------------------------------------------
  117. static const CarlaCachedPluginInfo* get_cached_plugin_lv2(Lv2WorldClass& lv2World, Lilv::Plugin& lilvPlugin)
  118. {
  119. static CarlaCachedPluginInfo info;
  120. info.valid = false;
  121. bool supported = true;
  122. // ----------------------------------------------------------------------------------------------------------------
  123. // text data
  124. {
  125. static CarlaString suri, sname, smaker, slicense;
  126. suri.clear(); sname.clear(); smaker.clear(); slicense.clear();
  127. suri = lilvPlugin.get_uri().as_uri();
  128. if (char* const bundle = lilv_file_uri_parse(lilvPlugin.get_bundle_uri().as_uri(), nullptr))
  129. {
  130. File fbundle(bundle);
  131. lilv_free(bundle);
  132. suri = (fbundle.getFileName() + CARLA_OS_SEP).toRawUTF8() + suri;
  133. }
  134. else
  135. {
  136. suri = CARLA_OS_SEP_STR + suri;
  137. }
  138. #if 0 // def HAVE_FLUIDSYNTH
  139. // If we have fluidsynth support built-in, loading these plugins will lead to issues
  140. if (suri == "urn:ardour:a-fluidsynth")
  141. return &info;
  142. if (suri == "http://calf.sourceforge.net/plugins/Fluidsynth")
  143. return &info;
  144. #endif
  145. if (LilvNode* const nameNode = lilv_plugin_get_name(lilvPlugin.me))
  146. {
  147. if (const char* const name = lilv_node_as_string(nameNode))
  148. sname = name;
  149. lilv_node_free(nameNode);
  150. }
  151. if (const char* const author = lilvPlugin.get_author_name().as_string())
  152. smaker = author;
  153. Lilv::Nodes licenseNodes(lilvPlugin.get_value(lv2World.doap_license));
  154. if (licenseNodes.size() > 0)
  155. {
  156. if (const char* const license = licenseNodes.get_first().as_string())
  157. slicense = license;
  158. }
  159. lilv_nodes_free(const_cast<LilvNodes*>(licenseNodes.me));
  160. info.name = sname.buffer();
  161. info.label = suri.buffer();
  162. info.maker = smaker.buffer();
  163. info.copyright = slicense.buffer();
  164. }
  165. // ----------------------------------------------------------------------------------------------------------------
  166. // features
  167. info.hints = 0x0;
  168. if (lilvPlugin.get_uis().size() > 0 || lilvPlugin.get_modgui_resources_directory().as_uri() != nullptr)
  169. info.hints |= CB::PLUGIN_HAS_CUSTOM_UI;
  170. {
  171. Lilv::Nodes lilvRequiredFeatureNodes(lilvPlugin.get_required_features());
  172. LILV_FOREACH(nodes, it, lilvRequiredFeatureNodes)
  173. {
  174. Lilv::Node lilvFeatureNode(lilvRequiredFeatureNodes.get(it));
  175. const char* const featureURI(lilvFeatureNode.as_uri());
  176. CARLA_SAFE_ASSERT_CONTINUE(featureURI != nullptr);
  177. if (! is_lv2_feature_supported(featureURI))
  178. {
  179. if (std::strcmp(featureURI, LV2_DATA_ACCESS_URI) == 0
  180. || std::strcmp(featureURI, LV2_INSTANCE_ACCESS_URI) == 0)
  181. {
  182. // we give a warning about this below
  183. continue;
  184. }
  185. supported = false;
  186. carla_stderr("LV2 plugin '%s' requires unsupported feature '%s'", info.label, featureURI);
  187. }
  188. }
  189. lilv_nodes_free(const_cast<LilvNodes*>(lilvRequiredFeatureNodes.me));
  190. }
  191. {
  192. Lilv::Nodes lilvSupportedFeatureNodes(lilvPlugin.get_supported_features());
  193. LILV_FOREACH(nodes, it, lilvSupportedFeatureNodes)
  194. {
  195. Lilv::Node lilvFeatureNode(lilvSupportedFeatureNodes.get(it));
  196. const char* const featureURI(lilvFeatureNode.as_uri());
  197. CARLA_SAFE_ASSERT_CONTINUE(featureURI != nullptr);
  198. /**/ if (std::strcmp(featureURI, LV2_CORE__hardRTCapable) == 0)
  199. {
  200. info.hints |= CB::PLUGIN_IS_RTSAFE;
  201. }
  202. else if (std::strcmp(featureURI, LV2_INLINEDISPLAY__queue_draw) == 0)
  203. {
  204. info.hints |= CB::PLUGIN_HAS_INLINE_DISPLAY;
  205. }
  206. else if (std::strcmp(featureURI, LV2_DATA_ACCESS_URI) == 0
  207. || std::strcmp(featureURI, LV2_INSTANCE_ACCESS_URI) == 0)
  208. {
  209. carla_stderr("LV2 plugin '%s' DSP wants UI feature '%s', ignoring this", info.label, featureURI);
  210. }
  211. }
  212. lilv_nodes_free(const_cast<LilvNodes*>(lilvSupportedFeatureNodes.me));
  213. }
  214. // ----------------------------------------------------------------------------------------------------------------
  215. // category
  216. info.category = CB::PLUGIN_CATEGORY_NONE;
  217. {
  218. Lilv::Nodes typeNodes(lilvPlugin.get_value(lv2World.rdf_type));
  219. if (typeNodes.size() > 0)
  220. {
  221. if (typeNodes.contains(lv2World.class_allpass))
  222. info.category = CB::PLUGIN_CATEGORY_FILTER;
  223. if (typeNodes.contains(lv2World.class_amplifier))
  224. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  225. if (typeNodes.contains(lv2World.class_analyzer))
  226. info.category = CB::PLUGIN_CATEGORY_UTILITY;
  227. if (typeNodes.contains(lv2World.class_bandpass))
  228. info.category = CB::PLUGIN_CATEGORY_FILTER;
  229. if (typeNodes.contains(lv2World.class_chorus))
  230. info.category = CB::PLUGIN_CATEGORY_MODULATOR;
  231. if (typeNodes.contains(lv2World.class_comb))
  232. info.category = CB::PLUGIN_CATEGORY_FILTER;
  233. if (typeNodes.contains(lv2World.class_compressor))
  234. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  235. if (typeNodes.contains(lv2World.class_constant))
  236. info.category = CB::PLUGIN_CATEGORY_OTHER;
  237. if (typeNodes.contains(lv2World.class_converter))
  238. info.category = CB::PLUGIN_CATEGORY_UTILITY;
  239. if (typeNodes.contains(lv2World.class_delay))
  240. info.category = CB::PLUGIN_CATEGORY_DELAY;
  241. if (typeNodes.contains(lv2World.class_distortion))
  242. info.category = CB::PLUGIN_CATEGORY_DISTORTION;
  243. if (typeNodes.contains(lv2World.class_dynamics))
  244. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  245. if (typeNodes.contains(lv2World.class_eq))
  246. info.category = CB::PLUGIN_CATEGORY_EQ;
  247. if (typeNodes.contains(lv2World.class_envelope))
  248. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  249. if (typeNodes.contains(lv2World.class_expander))
  250. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  251. if (typeNodes.contains(lv2World.class_filter))
  252. info.category = CB::PLUGIN_CATEGORY_FILTER;
  253. if (typeNodes.contains(lv2World.class_flanger))
  254. info.category = CB::PLUGIN_CATEGORY_MODULATOR;
  255. if (typeNodes.contains(lv2World.class_function))
  256. info.category = CB::PLUGIN_CATEGORY_UTILITY;
  257. if (typeNodes.contains(lv2World.class_gate))
  258. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  259. if (typeNodes.contains(lv2World.class_generator))
  260. info.category = CB::PLUGIN_CATEGORY_OTHER;
  261. if (typeNodes.contains(lv2World.class_highpass))
  262. info.category = CB::PLUGIN_CATEGORY_FILTER;
  263. if (typeNodes.contains(lv2World.class_limiter))
  264. info.category = CB::PLUGIN_CATEGORY_DYNAMICS;
  265. if (typeNodes.contains(lv2World.class_lowpass))
  266. info.category = CB::PLUGIN_CATEGORY_FILTER;
  267. if (typeNodes.contains(lv2World.class_mixer))
  268. info.category = CB::PLUGIN_CATEGORY_UTILITY;
  269. if (typeNodes.contains(lv2World.class_modulator))
  270. info.category = CB::PLUGIN_CATEGORY_MODULATOR;
  271. if (typeNodes.contains(lv2World.class_multiEQ))
  272. info.category = CB::PLUGIN_CATEGORY_EQ;
  273. if (typeNodes.contains(lv2World.class_oscillator))
  274. info.category = CB::PLUGIN_CATEGORY_OTHER;
  275. if (typeNodes.contains(lv2World.class_paraEQ))
  276. info.category = CB::PLUGIN_CATEGORY_EQ;
  277. if (typeNodes.contains(lv2World.class_phaser))
  278. info.category = CB::PLUGIN_CATEGORY_MODULATOR;
  279. if (typeNodes.contains(lv2World.class_pitch))
  280. info.category = CB::PLUGIN_CATEGORY_OTHER;
  281. if (typeNodes.contains(lv2World.class_reverb))
  282. info.category = CB::PLUGIN_CATEGORY_DELAY;
  283. if (typeNodes.contains(lv2World.class_simulator))
  284. info.category = CB::PLUGIN_CATEGORY_OTHER;
  285. if (typeNodes.contains(lv2World.class_spatial))
  286. info.category = CB::PLUGIN_CATEGORY_OTHER;
  287. if (typeNodes.contains(lv2World.class_spectral))
  288. info.category = CB::PLUGIN_CATEGORY_OTHER;
  289. if (typeNodes.contains(lv2World.class_utility))
  290. info.category = CB::PLUGIN_CATEGORY_UTILITY;
  291. if (typeNodes.contains(lv2World.class_waveshaper))
  292. info.category = CB::PLUGIN_CATEGORY_DISTORTION;
  293. if (typeNodes.contains(lv2World.class_instrument))
  294. {
  295. info.category = CB::PLUGIN_CATEGORY_SYNTH;
  296. info.hints |= CB::PLUGIN_IS_SYNTH;
  297. }
  298. }
  299. lilv_nodes_free(const_cast<LilvNodes*>(typeNodes.me));
  300. }
  301. // ----------------------------------------------------------------------------------------------------------------
  302. // number data
  303. info.audioIns = 0;
  304. info.audioOuts = 0;
  305. info.cvIns = 0;
  306. info.cvOuts = 0;
  307. info.midiIns = 0;
  308. info.midiOuts = 0;
  309. info.parameterIns = 0;
  310. info.parameterOuts = 0;
  311. for (uint i=0, count=lilvPlugin.get_num_ports(); i<count; ++i)
  312. {
  313. Lilv::Port lilvPort(lilvPlugin.get_port_by_index(i));
  314. bool isInput;
  315. /**/ if (lilvPort.is_a(lv2World.port_input))
  316. {
  317. isInput = true;
  318. }
  319. else if (lilvPort.is_a(lv2World.port_output))
  320. {
  321. isInput = false;
  322. }
  323. else
  324. {
  325. const LilvNode* const symbolNode = lilvPort.get_symbol();
  326. CARLA_SAFE_ASSERT_CONTINUE(symbolNode != nullptr && lilv_node_is_string(symbolNode));
  327. const char* const symbol = lilv_node_as_string(symbolNode);
  328. CARLA_SAFE_ASSERT_CONTINUE(symbol != nullptr);
  329. carla_stderr("LV2 plugin '%s' port '%s' is neither input or output", info.label, symbol);
  330. continue;
  331. }
  332. /**/ if (lilvPort.is_a(lv2World.port_control))
  333. {
  334. // skip some control ports
  335. if (lilvPort.has_property(lv2World.reportsLatency))
  336. continue;
  337. if (LilvNode* const designationNode = lilv_port_get(lilvPort.parent, lilvPort.me, lv2World.designation.me))
  338. {
  339. bool skip = false;
  340. if (const char* const designation = lilv_node_as_string(designationNode))
  341. {
  342. /**/ if (std::strcmp(designation, LV2_CORE__control) == 0)
  343. skip = true;
  344. else if (std::strcmp(designation, LV2_CORE__freeWheeling) == 0)
  345. skip = true;
  346. else if (std::strcmp(designation, LV2_CORE__latency) == 0)
  347. skip = true;
  348. else if (std::strcmp(designation, LV2_PARAMETERS__sampleRate) == 0)
  349. skip = true;
  350. else if (std::strcmp(designation, LV2_TIME__bar) == 0)
  351. skip = true;
  352. else if (std::strcmp(designation, LV2_TIME__barBeat) == 0)
  353. skip = true;
  354. else if (std::strcmp(designation, LV2_TIME__beat) == 0)
  355. skip = true;
  356. else if (std::strcmp(designation, LV2_TIME__beatUnit) == 0)
  357. skip = true;
  358. else if (std::strcmp(designation, LV2_TIME__beatsPerBar) == 0)
  359. skip = true;
  360. else if (std::strcmp(designation, LV2_TIME__beatsPerMinute) == 0)
  361. skip = true;
  362. else if (std::strcmp(designation, LV2_TIME__frame) == 0)
  363. skip = true;
  364. else if (std::strcmp(designation, LV2_TIME__framesPerSecond) == 0)
  365. skip = true;
  366. else if (std::strcmp(designation, LV2_TIME__speed) == 0)
  367. skip = true;
  368. else if (std::strcmp(designation, LV2_KXSTUDIO_PROPERTIES__TimePositionTicksPerBeat) == 0)
  369. skip = true;
  370. }
  371. lilv_node_free(designationNode);
  372. if (skip)
  373. continue;
  374. }
  375. if (isInput)
  376. ++(info.parameterIns);
  377. else
  378. ++(info.parameterOuts);
  379. }
  380. else if (lilvPort.is_a(lv2World.port_audio))
  381. {
  382. if (isInput)
  383. ++(info.audioIns);
  384. else
  385. ++(info.audioOuts);
  386. }
  387. else if (lilvPort.is_a(lv2World.port_cv))
  388. {
  389. if (isInput)
  390. ++(info.cvIns);
  391. else
  392. ++(info.cvOuts);
  393. }
  394. else if (lilvPort.is_a(lv2World.port_atom))
  395. {
  396. Lilv::Nodes supportNodes(lilvPort.get_value(lv2World.atom_supports));
  397. for (LilvIter *it = lilv_nodes_begin(supportNodes.me); ! lilv_nodes_is_end(supportNodes.me, it); it = lilv_nodes_next(supportNodes.me, it))
  398. {
  399. const Lilv::Node node(lilv_nodes_get(supportNodes.me, it));
  400. CARLA_SAFE_ASSERT_CONTINUE(node.is_uri());
  401. if (node.equals(lv2World.midi_event))
  402. {
  403. if (isInput)
  404. ++(info.midiIns);
  405. else
  406. ++(info.midiOuts);
  407. }
  408. }
  409. lilv_nodes_free(const_cast<LilvNodes*>(supportNodes.me));
  410. }
  411. else if (lilvPort.is_a(lv2World.port_event))
  412. {
  413. if (lilvPort.supports_event(lv2World.midi_event))
  414. {
  415. if (isInput)
  416. ++(info.midiIns);
  417. else
  418. ++(info.midiOuts);
  419. }
  420. }
  421. else if (lilvPort.is_a(lv2World.port_midi))
  422. {
  423. if (isInput)
  424. ++(info.midiIns);
  425. else
  426. ++(info.midiOuts);
  427. }
  428. else
  429. {
  430. const LilvNode* const symbolNode = lilvPort.get_symbol();
  431. CARLA_SAFE_ASSERT_CONTINUE(symbolNode != nullptr && lilv_node_is_string(symbolNode));
  432. const char* const symbol = lilv_node_as_string(symbolNode);
  433. CARLA_SAFE_ASSERT_CONTINUE(symbol != nullptr);
  434. supported = false;
  435. carla_stderr("LV2 plugin '%s' port '%s' is required but has unsupported type", info.label, symbol);
  436. }
  437. }
  438. if (supported)
  439. info.valid = true;
  440. return &info;
  441. }
  442. // -------------------------------------------------------------------------------------------------------------------
  443. #if defined(USING_JUCE) && defined(CARLA_OS_MAC)
  444. static juce::StringArray gCachedAuPluginResults;
  445. static void findAUs()
  446. {
  447. if (gCachedAuPluginResults.size() != 0)
  448. return;
  449. juce::AudioUnitPluginFormat auFormat;
  450. gCachedAuPluginResults = auFormat.searchPathsForPlugins(juce::FileSearchPath(), false, false);
  451. }
  452. static const CarlaCachedPluginInfo* get_cached_plugin_au(const juce::String pluginId)
  453. {
  454. static CarlaCachedPluginInfo info;
  455. static CarlaString sname, slabel, smaker;
  456. info.valid = false;
  457. juce::AudioUnitPluginFormat auFormat;
  458. juce::OwnedArray<juce::PluginDescription> results;
  459. auFormat.findAllTypesForFile(results, pluginId);
  460. CARLA_SAFE_ASSERT_RETURN(results.size() > 0, &info);
  461. CARLA_SAFE_ASSERT(results.size() == 1);
  462. juce::PluginDescription* const desc(results[0]);
  463. CARLA_SAFE_ASSERT_RETURN(desc != nullptr, &info);
  464. info.category = CB::getPluginCategoryFromName(desc->category.toRawUTF8());
  465. info.hints = 0x0;
  466. info.valid = true;
  467. if (desc->isInstrument)
  468. info.hints |= CB::PLUGIN_IS_SYNTH;
  469. if (true)
  470. info.hints |= CB::PLUGIN_HAS_CUSTOM_UI;
  471. info.audioIns = static_cast<uint32_t>(desc->numInputChannels);
  472. info.audioOuts = static_cast<uint32_t>(desc->numOutputChannels);
  473. info.cvIns = 0;
  474. info.cvOuts = 0;
  475. info.midiIns = desc->isInstrument ? 1 : 0;
  476. info.midiOuts = 0;
  477. info.parameterIns = 0;
  478. info.parameterOuts = 0;
  479. sname = desc->name.toRawUTF8();
  480. slabel = desc->fileOrIdentifier.toRawUTF8();
  481. smaker = desc->manufacturerName.toRawUTF8();
  482. info.name = sname;
  483. info.label = slabel;
  484. info.maker = smaker;
  485. info.copyright = gNullCharPtr;
  486. return &info;
  487. }
  488. #endif
  489. // -------------------------------------------------------------------------------------------------------------------
  490. static const CarlaCachedPluginInfo* get_cached_plugin_sfz(const File file)
  491. {
  492. static CarlaCachedPluginInfo info;
  493. static CarlaString name, filename;
  494. name = file.getFileNameWithoutExtension().toRawUTF8();
  495. name.replace('_',' ');
  496. filename = file.getFullPathName().toRawUTF8();
  497. info.category = CB::PLUGIN_CATEGORY_SYNTH;
  498. info.hints = CB::PLUGIN_IS_SYNTH;
  499. // CB::PLUGIN_IS_RTSAFE
  500. info.valid = true;
  501. info.audioIns = 0;
  502. info.audioOuts = 2;
  503. info.cvIns = 0;
  504. info.cvOuts = 0;
  505. info.midiIns = 1;
  506. info.midiOuts = 0;
  507. info.parameterIns = 0;
  508. info.parameterOuts = 1;
  509. info.name = name.buffer();
  510. info.label = filename.buffer();
  511. info.maker = gNullCharPtr;
  512. info.copyright = gNullCharPtr;
  513. return &info;
  514. }
  515. // -------------------------------------------------------------------------------------------------------------------
  516. uint carla_get_cached_plugin_count(CB::PluginType ptype, const char* pluginPath)
  517. {
  518. CARLA_SAFE_ASSERT_RETURN(isCachedPluginType(ptype), 0);
  519. carla_debug("carla_get_cached_plugin_count(%i:%s, %s)", ptype, CB::PluginType2Str(ptype), pluginPath);
  520. switch (ptype)
  521. {
  522. case CB::PLUGIN_INTERNAL: {
  523. uint32_t count = 0;
  524. carla_get_native_plugins_data(&count);
  525. return count;
  526. }
  527. case CB::PLUGIN_LV2: {
  528. Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());
  529. lv2World.initIfNeeded(pluginPath);
  530. return lv2World.getPluginCount();
  531. }
  532. #if defined(USING_JUCE) && defined(CARLA_OS_MAC)
  533. case CB::PLUGIN_AU: {
  534. findAUs();
  535. return static_cast<uint>(gCachedAuPluginResults.size());
  536. }
  537. #endif
  538. case CB::PLUGIN_SFZ: {
  539. findSFZs(pluginPath);
  540. return static_cast<uint>(gSFZs.size());
  541. }
  542. default:
  543. return 0;
  544. }
  545. }
  546. const CarlaCachedPluginInfo* carla_get_cached_plugin_info(CB::PluginType ptype, uint index)
  547. {
  548. carla_debug("carla_get_cached_plugin_info(%i:%s, %i)", ptype, CB::PluginType2Str(ptype), index);
  549. switch (ptype)
  550. {
  551. case CB::PLUGIN_INTERNAL: {
  552. uint32_t count = 0;
  553. const NativePluginDescriptor* const descs(carla_get_native_plugins_data(&count));
  554. CARLA_SAFE_ASSERT_BREAK(index < count);
  555. CARLA_SAFE_ASSERT_BREAK(descs != nullptr);
  556. const NativePluginDescriptor& desc(descs[index]);
  557. return get_cached_plugin_internal(desc);
  558. }
  559. case CB::PLUGIN_LV2: {
  560. Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());
  561. const LilvPlugin* const cPlugin(lv2World.getPluginFromIndex(index));
  562. CARLA_SAFE_ASSERT_BREAK(cPlugin != nullptr);
  563. Lilv::Plugin lilvPlugin(cPlugin);
  564. CARLA_SAFE_ASSERT_BREAK(lilvPlugin.get_uri().is_uri());
  565. return get_cached_plugin_lv2(lv2World, lilvPlugin);
  566. }
  567. #if defined(USING_JUCE) && defined(CARLA_OS_MAC)
  568. case CB::PLUGIN_AU: {
  569. CARLA_SAFE_ASSERT_BREAK(index < static_cast<uint>(gCachedAuPluginResults.size()));
  570. return get_cached_plugin_au(gCachedAuPluginResults.strings.getUnchecked(static_cast<int>(index)));
  571. }
  572. #endif
  573. case CB::PLUGIN_SFZ: {
  574. CARLA_SAFE_ASSERT_BREAK(index < static_cast<uint>(gSFZs.size()));
  575. return get_cached_plugin_sfz(gSFZs.getUnchecked(static_cast<int>(index)));
  576. }
  577. default:
  578. break;
  579. }
  580. static CarlaCachedPluginInfo info;
  581. return &info;
  582. }
  583. // -------------------------------------------------------------------------------------------------------------------
  584. #include "../native-plugins/_data.cpp"
  585. // -------------------------------------------------------------------------------------------------------------------