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.

124 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 <rack.hpp>
  18. #include <context.hpp>
  19. #include "DistrhoUtils.hpp"
  20. using namespace rack;
  21. extern Model* modelSpringReverb;
  22. Plugin* pluginInstance__Befaco;
  23. namespace rack {
  24. Context::~Context() {
  25. }
  26. static thread_local Context* threadContext;
  27. Context* contextGet() {
  28. DISTRHO_SAFE_ASSERT(threadContext != nullptr);
  29. return threadContext;
  30. }
  31. // Apple's clang incorrectly compiles this function when -O2 or higher is enabled.
  32. #ifdef ARCH_MAC
  33. __attribute__((optnone))
  34. #endif
  35. void contextSet(Context* const context) {
  36. // DISTRHO_SAFE_ASSERT(threadContext == nullptr);
  37. threadContext = context;
  38. }
  39. Exception::Exception(const char* format, ...)
  40. {
  41. va_list args;
  42. va_start(args, format);
  43. msg = string::fV(format, args);
  44. va_end(args);
  45. }
  46. namespace asset {
  47. std::string plugin(plugin::Plugin* plugin, std::string filename) { return {}; }
  48. std::string system(std::string filename) { return {}; }
  49. }
  50. namespace engine {
  51. float Engine::getParamValue(Module* module, int paramId) { return 0.0f; }
  52. float Engine::getParamSmoothValue(Module* module, int paramId) { return 0.0f; }
  53. void Engine::setParamValue(Module* module, int paramId, float value) {}
  54. void Engine::setParamSmoothValue(Module* module, int paramId, float value) {}
  55. }
  56. namespace plugin {
  57. void Plugin::addModel(Model* model)
  58. {
  59. // Check that the model is not added to a plugin already
  60. DISTRHO_SAFE_ASSERT_RETURN(model != nullptr,);
  61. DISTRHO_SAFE_ASSERT_RETURN(model->plugin == nullptr,);
  62. model->plugin = this;
  63. models.push_back(model);
  64. }
  65. Model* modelFromJson(json_t* moduleJ) {
  66. return nullptr;
  67. }
  68. std::vector<Plugin*> plugins;
  69. } // namespace plugin
  70. } // namespace rack
  71. int main()
  72. {
  73. Plugin* const p = new Plugin;
  74. pluginInstance__Befaco = p;
  75. p->addModel(modelSpringReverb);
  76. engine::Module* module = modelSpringReverb->createModule();
  77. d_stdout("modelSpringReverb is %p %p", modelSpringReverb, module);
  78. d_stdout("modelSpringReverb has %d ins, %d outs, %d lights, %d params",
  79. module->getNumInputs(), module->getNumOutputs(), module->getNumLights(), module->getNumParams());
  80. for (int i=0; i<module->getNumInputs(); ++i)
  81. d_stdout(" in %d has name '%s'; description '%s'",
  82. i+1, module->getInputInfo(i)->getFullName().c_str(), module->getInputInfo(i)->getDescription().c_str());
  83. for (int i=0; i<module->getNumOutputs(); ++i)
  84. d_stdout(" out %d has name '%s'; description '%s'",
  85. i+1, module->getOutputInfo(i)->getFullName().c_str(), module->getOutputInfo(i)->getDescription().c_str());
  86. // for (int i=0; i<module->getNumLights(); ++i)
  87. // {
  88. // LightInfo* l = module->getLightInfo(i);
  89. // DISTRHO_SAFE_ASSERT_CONTINUE(l != nullptr);
  90. // d_stdout(" light %d has name '%s'; description '%s'",
  91. // i+1, l->getName().c_str(), l->getDescription().c_str());
  92. // }
  93. for (int i=0; i<module->getNumParams(); ++i)
  94. {
  95. ParamQuantity* q = module->getParamQuantity(i);
  96. d_stdout(" param %d has name '%s'; description '%s'; unit '%s'; min %f; max %f; def %f",
  97. i+1, q->name.c_str(), q->getDescription().c_str(), q->unit.c_str(),
  98. q->minValue, q->maxValue, q->defaultValue);
  99. }
  100. Module::ProcessArgs args = {
  101. 48000.0f,
  102. 1.0f / 48000.0f,
  103. 0
  104. };
  105. for (int i=0; i<96000; ++i)
  106. {
  107. module->process(args);
  108. ++args.frame;
  109. }
  110. return 0;
  111. }