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.

176 lines
4.0KB

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