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.

152 lines
5.1KB

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