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.

139 lines
4.4KB

  1. /*
  2. * DISTRHO Cardinal Plugin
  3. * Copyright (C) 2021-2022 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. #ifndef PLUGIN_MODEL
  18. # error PLUGIN_MODEL undefined
  19. #endif
  20. #ifndef PLUGIN_CV_INPUTS
  21. # error PLUGIN_CV_INPUTS undefined
  22. #endif
  23. #ifndef PLUGIN_CV_OUTPUTS
  24. # error PLUGIN_CV_OUTPUTS undefined
  25. #endif
  26. #include <cstdio>
  27. // -----------------------------------------------------------------------
  28. DISTRHO_PLUGIN_EXPORT
  29. void lv2_generate_ttl()
  30. {
  31. Context context;
  32. context._engine.sampleRate = 48000.f;
  33. contextSet(&context);
  34. engine::Module* module = PLUGIN_MODEL->createModule();
  35. d_stdout("@prefix doap: <http://usefulinc.com/ns/doap#> .");
  36. d_stdout("@prefix foaf: <http://xmlns.com/foaf/0.1/> .");
  37. d_stdout("@prefix lv2: <http://lv2plug.in/ns/lv2core#> .");
  38. d_stdout("");
  39. d_stdout("<urn:cardinal:" SLUG ">");
  40. d_stdout(" a lv2:Plugin, doap:Project ;");
  41. d_stdout(" doap:name \"" SLUG "\" ;");
  42. d_stdout("");
  43. int index = 0;
  44. for (int i=0, numAudio=0, numCV=0; i<module->getNumInputs(); ++i)
  45. {
  46. d_stdout(" lv2:port [");
  47. if (kCvInputs[i])
  48. {
  49. d_stdout(" a lv2:InputPort, lv2:CVPort ;");
  50. d_stdout(" lv2:symbol \"lv2_cv_in_%d\" ;", ++numCV);
  51. }
  52. else
  53. {
  54. d_stdout(" a lv2:InputPort, lv2:AudioPort ;");
  55. d_stdout(" lv2:symbol \"lv2_audio_in_%d\" ;", ++numAudio);
  56. }
  57. d_stdout(" lv2:name \"%s\" ;", module->getInputInfo(i)->getFullName().c_str());
  58. d_stdout(" lv2:index %d ;", index++);
  59. d_stdout(" ] ;");
  60. d_stdout("");
  61. }
  62. for (int i=0, numAudio=0, numCV=0; i<module->getNumOutputs(); ++i)
  63. {
  64. d_stdout(" lv2:port [");
  65. if (kCvOutputs[i])
  66. {
  67. d_stdout(" a lv2:OutputPort, lv2:CVPort ;");
  68. d_stdout(" lv2:symbol \"lv2_cv_out_%d\" ;", ++numCV);
  69. }
  70. else
  71. {
  72. d_stdout(" a lv2:OutputPort, lv2:AudioPort ;");
  73. d_stdout(" lv2:symbol \"lv2_audio_out_%d\" ;", ++numAudio);
  74. }
  75. d_stdout(" lv2:name \"%s\" ;", module->getOutputInfo(i)->getFullName().c_str());
  76. d_stdout(" lv2:index %d ;", index++);
  77. d_stdout(" ] ;");
  78. d_stdout("");
  79. }
  80. for (int i=0; i<module->getNumParams(); ++i)
  81. {
  82. ParamQuantity* const q = module->getParamQuantity(i);
  83. d_stdout(" lv2:port [");
  84. d_stdout(" a lv2:InputPort, lv2:ControlPort ;");
  85. d_stdout(" lv2:index %d ;", index++);
  86. d_stdout(" lv2:symbol \"lv2_param_%d\" ;", i + 1);
  87. d_stdout(" lv2:name \"%s\" ;", q->name.c_str());
  88. d_stdout(" lv2:default %f ;", q->defaultValue);
  89. d_stdout(" lv2:minimum %f ;", q->minValue);
  90. d_stdout(" lv2:maximum %f ;", q->maxValue);
  91. d_stdout(" ] ;");
  92. d_stdout("");
  93. // q->getDescription().c_str()
  94. // q->unit.c_str()
  95. }
  96. for (int i=0; i<module->getNumLights(); ++i)
  97. {
  98. LightInfo* const li = module->getLightInfo(i);
  99. d_stdout(" lv2:port [");
  100. d_stdout(" a lv2:OutputPort, lv2:ControlPort ;");
  101. d_stdout(" lv2:index %d ;", index++);
  102. d_stdout(" lv2:symbol \"lv2_light_%d\" ;", i + 1);
  103. if (!li->name.empty())
  104. {
  105. d_stdout(" lv2:name \"%s\" ;", li->name.c_str());
  106. if (!li->description.empty())
  107. d_stdout(" lv2:comment \"%s\" ;", li->description.c_str());
  108. }
  109. else
  110. {
  111. d_stdout(" lv2:name \"Light %d\" ;", i + 1);
  112. }
  113. d_stdout(" ] ;");
  114. d_stdout("");
  115. // q->getDescription().c_str()
  116. // q->unit.c_str()
  117. }
  118. d_stdout(" .");
  119. delete module;
  120. }
  121. // -----------------------------------------------------------------------