DISTRHO Plugin Framework
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.

129 lines
3.4KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "DistrhoPluginInternal.hpp"
  17. #include <fstream>
  18. #include <iostream>
  19. // -----------------------------------------------------------------------
  20. int au_generate_r(const char* const basename)
  21. {
  22. USE_NAMESPACE_DISTRHO
  23. // Dummy plugin to get data from
  24. d_lastBufferSize = 512;
  25. d_lastSampleRate = 44100.0;
  26. PluginExporter plugin(nullptr, nullptr);
  27. d_lastBufferSize = 0;
  28. d_lastSampleRate = 0.0;
  29. String filename(basename);
  30. if (! filename.endsWith("/"))
  31. filename += "/";
  32. filename += "DistrhoPluginInfo.r";
  33. // ---------------------------------------------
  34. std::cout << "Writing DistrhoPluginInfo.r..."; std::cout.flush();
  35. std::fstream rFile(filename, std::ios::out);
  36. // full name
  37. {
  38. String fullname(plugin.getMaker());
  39. if (fullname.isEmpty())
  40. fullname = "DPF";
  41. fullname += ": ";
  42. fullname += plugin.getName();
  43. rFile << "#define DISTRHO_PLUGIN_FULL_NAME \"" + fullname + "\"\n";
  44. }
  45. // description
  46. {
  47. String description(plugin.getDescription());
  48. if (description.isNotEmpty())
  49. {
  50. description.replace('\n', ' ').replace('"', '\'');
  51. }
  52. else
  53. {
  54. description = plugin.getName();
  55. description += " AU";
  56. }
  57. rFile << "#define DISTRHO_PLUGIN_DESCRIPTION \"" + description + "\"\n";
  58. }
  59. // res id
  60. if (const int64_t uniqueId = plugin.getUniqueId())
  61. {
  62. if (uniqueId < 0)
  63. {
  64. d_stderr2("AU plugin Id cannot be negative");
  65. return 1;
  66. }
  67. if (uniqueId >= UINT16_MAX)
  68. {
  69. d_stderr2("AU plugin Id cannot be higher than uint16");
  70. }
  71. rFile << "#define DISTRHO_PLUGIN_AU_RES_ID " + String(uniqueId % UINT16_MAX) + "\n";
  72. }
  73. #ifndef DEBUG
  74. // version
  75. {
  76. String version(plugin.getVersion());
  77. if (version.isEmpty())
  78. version = "0";
  79. rFile << "#define DISTRHO_PLUGIN_VERSION " + version + "\n";
  80. }
  81. #else
  82. rFile << "#define DISTRHO_PLUGIN_VERSION 0xFFFFFFFF\n";
  83. #endif
  84. rFile.close();
  85. std::cout << " done!" << std::endl;
  86. return 0;
  87. }
  88. // -----------------------------------------------------------------------
  89. int main(int argc, char* argv[])
  90. {
  91. if (argc != 2)
  92. {
  93. std::cout << "Single argument (output path) required!" << std::endl;
  94. return 1;
  95. }
  96. return au_generate_r(argv[1]);
  97. }
  98. // -----------------------------------------------------------------------
  99. #include "DistrhoPlugin.cpp"
  100. // -----------------------------------------------------------------------