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.

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