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.

148 lines
5.0KB

  1. /*
  2. * Carla Native Plugins
  3. * Copyright (C) 2013-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 "CarlaEngine.hpp"
  18. #include "CarlaPlugin.hpp"
  19. #include "CarlaHost.h"
  20. #include "CarlaNative.h"
  21. #include "CarlaBackendUtils.hpp"
  22. #include "LinkedList.hpp"
  23. #ifdef CARLA_NATIVE_PLUGIN_DSSI
  24. # include "dssi/dssi.h"
  25. #endif
  26. #ifdef CARLA_NATIVE_PLUGIN_LV2
  27. # include "lv2/lv2.h"
  28. #endif
  29. using CarlaBackend::CarlaPlugin;
  30. // -----------------------------------------------------------------------
  31. CARLA_EXTERN_C
  32. std::size_t carla_getNativePluginCount() noexcept;
  33. CARLA_EXTERN_C
  34. const NativePluginDescriptor* carla_getNativePluginDescriptor(const std::size_t index) noexcept;
  35. // -----------------------------------------------------------------------
  36. // Plugin List
  37. struct PluginListManager {
  38. PluginListManager()
  39. #ifdef CARLA_NATIVE_PLUGIN_DSSI
  40. : dssiDescs(),
  41. #endif
  42. #ifdef CARLA_NATIVE_PLUGIN_LV2
  43. : lv2Descs(),
  44. #endif
  45. #ifdef CARLA_NATIVE_PLUGIN_VST
  46. : _dummy(0),
  47. #endif
  48. descs()
  49. {
  50. for (std::size_t i=0, count = carla_getNativePluginCount(); i < count; ++i)
  51. {
  52. const NativePluginDescriptor* const desc(carla_getNativePluginDescriptor(i));
  53. if (std::strcmp(desc->label, "lfo" ) == 0 ||
  54. std::strcmp(desc->label, "midichanfilter" ) == 0 ||
  55. std::strcmp(desc->label, "midichanab" ) == 0 ||
  56. std::strcmp(desc->label, "midigain" ) == 0 ||
  57. std::strcmp(desc->label, "midijoin" ) == 0 ||
  58. std::strcmp(desc->label, "midisplit" ) == 0 ||
  59. std::strcmp(desc->label, "midithrough" ) == 0 ||
  60. std::strcmp(desc->label, "miditranspose" ) == 0 ||
  61. std::strcmp(desc->label, "midipattern" ) == 0 ||
  62. std::strcmp(desc->label, "carlarack" ) == 0 ||
  63. std::strcmp(desc->label, "carlapatchbay" ) == 0 ||
  64. std::strcmp(desc->label, "carlapatchbay3s" ) == 0 ||
  65. std::strcmp(desc->label, "carlapatchbay16" ) == 0 ||
  66. std::strcmp(desc->label, "carlapatchbay32" ) == 0 ||
  67. std::strcmp(desc->label, "bigmeter" ) == 0 ||
  68. std::strcmp(desc->label, "notes" ) == 0 ||
  69. #ifdef CARLA_ZYN_LV2_EXPORTED
  70. std::strcmp(desc->label, "zynalienwah" ) == 0 ||
  71. std::strcmp(desc->label, "zynchorus" ) == 0 ||
  72. std::strcmp(desc->label, "zyndistortion" ) == 0 ||
  73. std::strcmp(desc->label, "zyndynamicfilter") == 0 ||
  74. std::strcmp(desc->label, "zynecho" ) == 0 ||
  75. std::strcmp(desc->label, "zynphaser" ) == 0 ||
  76. std::strcmp(desc->label, "zynreverb" ) == 0 ||
  77. std::strcmp(desc->label, "zynaddsubfx" ) == 0 ||
  78. #endif
  79. std::strcmp(desc->label, "at1" ) == 0 ||
  80. std::strcmp(desc->label, "bls1" ) == 0 ||
  81. std::strcmp(desc->label, "rev1-ambisonic" ) == 0 ||
  82. std::strcmp(desc->label, "rev1-stereo" ) == 0)
  83. {
  84. descs.append(desc);
  85. }
  86. }
  87. }
  88. ~PluginListManager()
  89. {
  90. #ifdef CARLA_NATIVE_PLUGIN_DSSI
  91. for (LinkedList<const DSSI_Descriptor*>::Itenerator it = dssiDescs.begin2(); it.valid(); it.next())
  92. {
  93. const DSSI_Descriptor* const dssiDesc(it.getValue());
  94. CARLA_SAFE_ASSERT_CONTINUE(dssiDesc != nullptr);
  95. //delete[] lv2Desc->URI;
  96. delete dssiDesc;
  97. }
  98. dssiDescs.clear();
  99. #endif
  100. #ifdef CARLA_NATIVE_PLUGIN_LV2
  101. for (LinkedList<const LV2_Descriptor*>::Itenerator it = lv2Descs.begin2(); it.valid(); it.next())
  102. {
  103. const LV2_Descriptor* const lv2Desc(it.getValue(nullptr));
  104. CARLA_SAFE_ASSERT_CONTINUE(lv2Desc != nullptr);
  105. delete[] lv2Desc->URI;
  106. delete lv2Desc;
  107. }
  108. lv2Descs.clear();
  109. #endif
  110. descs.clear();
  111. }
  112. static PluginListManager& getInstance()
  113. {
  114. static PluginListManager plm;
  115. return plm;
  116. }
  117. #ifdef CARLA_NATIVE_PLUGIN_DSSI
  118. LinkedList<const DSSI_Descriptor*> dssiDescs;
  119. #endif
  120. #ifdef CARLA_NATIVE_PLUGIN_LV2
  121. LinkedList<const LV2_Descriptor*> lv2Descs;
  122. #endif
  123. #ifdef CARLA_NATIVE_PLUGIN_VST
  124. char _dummy;
  125. #endif
  126. LinkedList<const NativePluginDescriptor*> descs;
  127. };
  128. // -----------------------------------------------------------------------