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.

218 lines
5.2KB

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