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.

245 lines
5.9KB

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