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.

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