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.

carla-base.cpp 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Carla Native Plugins
  3. * Copyright (C) 2013-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 "CarlaEngine.hpp"
  18. #include "CarlaNativePlugin.h"
  19. #include "CarlaJuceUtils.hpp"
  20. #include "LinkedList.hpp"
  21. // -----------------------------------------------------------------------
  22. #ifdef CARLA_NATIVE_PLUGIN_LV2
  23. #include "lv2/lv2.h"
  24. // defined in CarlaPluginNative.cpp
  25. std::size_t carla_getNativePluginCount() noexcept;
  26. const NativePluginDescriptor* carla_getNativePluginDescriptor(const std::size_t index) noexcept;
  27. #endif
  28. // -----------------------------------------------------------------------
  29. // Plugin List
  30. struct PluginListManager {
  31. PluginListManager()
  32. : descs()
  33. #ifdef CARLA_NATIVE_PLUGIN_LV2
  34. , lv2Descs()
  35. #endif
  36. {
  37. #ifdef CARLA_NATIVE_PLUGIN_LV2
  38. for (std::size_t i=0, count = carla_getNativePluginCount(); i < count; ++i)
  39. {
  40. const NativePluginDescriptor* const desc(carla_getNativePluginDescriptor(i));
  41. CARLA_SAFE_ASSERT_BREAK(desc != nullptr);
  42. if (std::strcmp(desc->label, "audiofile" ) == 0 ||
  43. std::strcmp(desc->label, "audiogain" ) == 0 ||
  44. std::strcmp(desc->label, "audiogain_s" ) == 0 ||
  45. std::strcmp(desc->label, "lfo" ) == 0 ||
  46. std::strcmp(desc->label, "midichanab" ) == 0 ||
  47. std::strcmp(desc->label, "midichanfilter" ) == 0 ||
  48. std::strcmp(desc->label, "midichannelize" ) == 0 ||
  49. std::strcmp(desc->label, "midifile" ) == 0 ||
  50. std::strcmp(desc->label, "midigain" ) == 0 ||
  51. std::strcmp(desc->label, "midijoin" ) == 0 ||
  52. std::strcmp(desc->label, "midisplit" ) == 0 ||
  53. std::strcmp(desc->label, "miditranspose" ) == 0 ||
  54. std::strcmp(desc->label, "midipattern" ) == 0 ||
  55. std::strcmp(desc->label, "carlarack" ) == 0 ||
  56. std::strcmp(desc->label, "carlapatchbay" ) == 0 ||
  57. std::strcmp(desc->label, "carlapatchbay3s" ) == 0 ||
  58. std::strcmp(desc->label, "carlapatchbay16" ) == 0 ||
  59. std::strcmp(desc->label, "carlapatchbay32" ) == 0 ||
  60. std::strcmp(desc->label, "carlapatchbay64" ) == 0 ||
  61. std::strcmp(desc->label, "carlapatchbaycv" ) == 0 ||
  62. std::strcmp(desc->label, "bigmeter" ) == 0
  63. /*std::strcmp(desc->label, "notes" ) == 0*/)
  64. {
  65. descs.append(desc);
  66. }
  67. }
  68. #else
  69. descs.append(carla_get_native_rack_plugin());
  70. descs.append(carla_get_native_patchbay_plugin());
  71. descs.append(carla_get_native_patchbay16_plugin());
  72. descs.append(carla_get_native_patchbay32_plugin());
  73. descs.append(carla_get_native_patchbay64_plugin());
  74. #endif
  75. }
  76. ~PluginListManager()
  77. {
  78. #ifdef CARLA_NATIVE_PLUGIN_LV2
  79. for (LinkedList<const LV2_Descriptor*>::Itenerator it = lv2Descs.begin2(); it.valid(); it.next())
  80. {
  81. const LV2_Descriptor* const lv2Desc(it.getValue(nullptr));
  82. CARLA_SAFE_ASSERT_CONTINUE(lv2Desc != nullptr);
  83. delete[] lv2Desc->URI;
  84. delete lv2Desc;
  85. }
  86. lv2Descs.clear();
  87. #endif
  88. descs.clear();
  89. }
  90. static PluginListManager& getInstance()
  91. {
  92. static PluginListManager plm;
  93. return plm;
  94. }
  95. LinkedList<const NativePluginDescriptor*> descs;
  96. #ifdef CARLA_NATIVE_PLUGIN_LV2
  97. LinkedList<const LV2_Descriptor*> lv2Descs;
  98. #endif
  99. };
  100. // -----------------------------------------------------------------------