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.

196 lines
4.6KB

  1. /*
  2. * DISTRHO Cardinal Plugin
  3. * Copyright (C) 2021 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 3 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 LICENSE file.
  16. */
  17. #include <plugin.hpp>
  18. #include "DistrhoUtils.hpp"
  19. #include "AnimatedCircuits/src/plugin.hpp"
  20. #include "AudibleInstruments/src/plugin.hpp"
  21. #include "Befaco/src/plugin.hpp"
  22. #include "Fundamental/src/plugin.hpp"
  23. Plugin* pluginInstance__AnimatedCircuits;
  24. Plugin* pluginInstance__AudibleInstruments;
  25. Plugin* pluginInstance__Befaco;
  26. Plugin* pluginInstance__Fundamental;
  27. namespace rack {
  28. namespace plugin {
  29. struct StaticPluginLoader {
  30. Plugin* const plugin;
  31. FILE* file;
  32. json_t* rootJ;
  33. StaticPluginLoader(Plugin* const p, const char* const name)
  34. : plugin(p),
  35. file(nullptr),
  36. rootJ(nullptr)
  37. {
  38. p->path = system::join(CARDINAL_PLUGINS_DIR, name);
  39. const std::string manifestFilename = system::join(p->path, "plugin.json");
  40. if ((file = std::fopen(manifestFilename.c_str(), "r")) == nullptr)
  41. {
  42. d_stderr2("Manifest file %s does not exist", manifestFilename.c_str());
  43. return;
  44. }
  45. json_error_t error;
  46. if ((rootJ = json_loadf(file, 0, &error)) == nullptr)
  47. {
  48. d_stderr2("JSON parsing error at %s %d:%d %s", manifestFilename.c_str(), error.line, error.column, error.text);
  49. return;
  50. }
  51. // force ABI, we use static plugins so this doesnt matter as long as it builds
  52. json_t* const version = json_string((APP_VERSION_MAJOR + ".0").c_str());
  53. json_object_set(rootJ, "version", version);
  54. json_decref(version);
  55. }
  56. ~StaticPluginLoader()
  57. {
  58. if (rootJ != nullptr)
  59. {
  60. plugin->fromJson(rootJ);
  61. json_decref(rootJ);
  62. plugins.push_back(plugin);
  63. }
  64. if (file != nullptr)
  65. std::fclose(file);
  66. }
  67. bool ok() const noexcept
  68. {
  69. return rootJ != nullptr;
  70. }
  71. };
  72. static void initStatic__AnimatedCircuits()
  73. {
  74. Plugin* p = new Plugin;
  75. pluginInstance__AnimatedCircuits = p;
  76. const StaticPluginLoader spl(p, "AnimatedCircuits");
  77. if (spl.ok())
  78. {
  79. p->addModel(model_AC_Folding);
  80. }
  81. }
  82. static void initStatic__AudibleInstruments()
  83. {
  84. Plugin* p = new Plugin;
  85. pluginInstance__AudibleInstruments = p;
  86. const StaticPluginLoader spl(p, "AudibleInstruments");
  87. if (spl.ok())
  88. {
  89. p->addModel(modelBraids);
  90. p->addModel(modelPlaits);
  91. p->addModel(modelElements);
  92. p->addModel(modelTides);
  93. p->addModel(modelTides2);
  94. p->addModel(modelClouds);
  95. p->addModel(modelWarps);
  96. p->addModel(modelRings);
  97. p->addModel(modelLinks);
  98. p->addModel(modelKinks);
  99. p->addModel(modelShades);
  100. p->addModel(modelBranches);
  101. p->addModel(modelBlinds);
  102. p->addModel(modelVeils);
  103. p->addModel(modelFrames);
  104. p->addModel(modelMarbles);
  105. p->addModel(modelStages);
  106. p->addModel(modelRipples);
  107. p->addModel(modelShelves);
  108. p->addModel(modelStreams);
  109. }
  110. }
  111. static void initStatic__Befaco()
  112. {
  113. Plugin* p = new Plugin;
  114. pluginInstance__Befaco = p;
  115. const StaticPluginLoader spl(p, "Befaco");
  116. if (spl.ok())
  117. {
  118. p->addModel(modelEvenVCO);
  119. p->addModel(modelRampage);
  120. p->addModel(modelABC);
  121. p->addModel(modelSpringReverb);
  122. p->addModel(modelMixer);
  123. p->addModel(modelSlewLimiter);
  124. p->addModel(modelDualAtenuverter);
  125. }
  126. }
  127. static void initStatic__Fundamental()
  128. {
  129. Plugin* p = new Plugin;
  130. pluginInstance__Fundamental = p;
  131. const StaticPluginLoader spl(p, "Fundamental");
  132. if (spl.ok())
  133. {
  134. p->addModel(modelVCO);
  135. p->addModel(modelVCO2);
  136. p->addModel(modelVCF);
  137. p->addModel(modelVCA_1);
  138. p->addModel(modelVCA);
  139. p->addModel(modelLFO);
  140. p->addModel(modelLFO2);
  141. p->addModel(modelDelay);
  142. p->addModel(modelADSR);
  143. p->addModel(modelVCMixer);
  144. p->addModel(model_8vert);
  145. p->addModel(modelUnity);
  146. p->addModel(modelMutes);
  147. p->addModel(modelPulses);
  148. p->addModel(modelScope);
  149. p->addModel(modelSEQ3);
  150. p->addModel(modelSequentialSwitch1);
  151. p->addModel(modelSequentialSwitch2);
  152. p->addModel(modelOctave);
  153. p->addModel(modelQuantizer);
  154. p->addModel(modelSplit);
  155. p->addModel(modelMerge);
  156. p->addModel(modelSum);
  157. p->addModel(modelViz);
  158. p->addModel(modelMidSide);
  159. p->addModel(modelNoise);
  160. p->addModel(modelRandom);
  161. }
  162. }
  163. void initStaticPlugins()
  164. {
  165. initStatic__AnimatedCircuits();
  166. initStatic__AudibleInstruments();
  167. initStatic__Befaco();
  168. initStatic__Fundamental();
  169. }
  170. }
  171. }