Audio plugin host https://kx.studio/carla
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.

158 lines
4.0KB

  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2014 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 2 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 doc/GPL.txt file.
  16. */
  17. #include "CarlaHost.h"
  18. #include "CarlaString.hpp"
  19. #include "water/files/File.h"
  20. namespace CB = CarlaBackend;
  21. // -------------------------------------------------------------------------------------------------------------------
  22. // Always return a valid string ptr
  23. static const char* const gNullCharPtr = "";
  24. #ifdef CARLA_COMMON_NEED_CHECKSTRINGPTR
  25. static void checkStringPtr(const char*& charPtr) noexcept
  26. {
  27. if (charPtr == nullptr)
  28. charPtr = gNullCharPtr;
  29. }
  30. #endif
  31. // -------------------------------------------------------------------------------------------------------------------
  32. // Constructors
  33. _CarlaPluginInfo::_CarlaPluginInfo() noexcept
  34. : type(CB::PLUGIN_NONE),
  35. category(CB::PLUGIN_CATEGORY_NONE),
  36. hints(0x0),
  37. optionsAvailable(0x0),
  38. optionsEnabled(0x0),
  39. filename(gNullCharPtr),
  40. name(gNullCharPtr),
  41. label(gNullCharPtr),
  42. maker(gNullCharPtr),
  43. copyright(gNullCharPtr),
  44. iconName(gNullCharPtr),
  45. uniqueId(0) {}
  46. _CarlaPluginInfo::~_CarlaPluginInfo() noexcept
  47. {
  48. if (label != gNullCharPtr)
  49. delete[] label;
  50. if (maker != gNullCharPtr)
  51. delete[] maker;
  52. if (copyright != gNullCharPtr)
  53. delete[] copyright;
  54. }
  55. _CarlaParameterInfo::_CarlaParameterInfo() noexcept
  56. : name(gNullCharPtr),
  57. symbol(gNullCharPtr),
  58. unit(gNullCharPtr),
  59. comment(gNullCharPtr),
  60. groupName(gNullCharPtr),
  61. scalePointCount(0),
  62. _reserved(gNullCharPtr) {}
  63. _CarlaParameterInfo::_CarlaParameterInfo(const char* const n) noexcept
  64. : name(n),
  65. symbol(n),
  66. unit(n),
  67. comment(n),
  68. groupName(n),
  69. scalePointCount(0),
  70. _reserved(n) {}
  71. _CarlaParameterInfo::~_CarlaParameterInfo() noexcept
  72. {
  73. if (name != _reserved)
  74. delete[] name;
  75. if (symbol != _reserved)
  76. delete[] symbol;
  77. if (unit != _reserved)
  78. delete[] unit;
  79. if (comment != _reserved)
  80. delete[] comment;
  81. if (groupName != _reserved)
  82. delete[] groupName;
  83. }
  84. _CarlaScalePointInfo::_CarlaScalePointInfo() noexcept
  85. : value(0.0f),
  86. label(gNullCharPtr) {}
  87. _CarlaScalePointInfo::~_CarlaScalePointInfo() noexcept
  88. {
  89. if (label != gNullCharPtr)
  90. delete[] label;
  91. }
  92. _CarlaTransportInfo::_CarlaTransportInfo() noexcept
  93. : playing(false),
  94. frame(0),
  95. bar(0),
  96. beat(0),
  97. tick(0),
  98. bpm(0.0) {}
  99. void _CarlaTransportInfo::clear() noexcept
  100. {
  101. playing = false;
  102. frame = 0;
  103. bar = 0;
  104. beat = 0;
  105. tick = 0;
  106. bpm = 0.0;
  107. }
  108. // -------------------------------------------------------------------------------------------------------------------
  109. const char* carla_get_library_filename()
  110. {
  111. carla_debug("carla_get_library_filename()");
  112. static CarlaString ret;
  113. if (ret.isEmpty())
  114. {
  115. using water::File;
  116. ret = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName().toRawUTF8();
  117. }
  118. return ret;
  119. }
  120. const char* carla_get_library_folder()
  121. {
  122. carla_debug("carla_get_library_folder()");
  123. static CarlaString ret;
  124. if (ret.isEmpty())
  125. {
  126. using water::File;
  127. ret = File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName().toRawUTF8();
  128. }
  129. return ret;
  130. }
  131. // -------------------------------------------------------------------------------------------------------------------