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.

156 lines
3.9KB

  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. _CarlaParameterInfo::_CarlaParameterInfo(const char* const n) noexcept
  63. : name(n),
  64. symbol(n),
  65. unit(n),
  66. comment(n),
  67. groupName(n),
  68. scalePointCount(0) {}
  69. _CarlaParameterInfo::~_CarlaParameterInfo() noexcept
  70. {
  71. if (name != gNullCharPtr)
  72. delete[] name;
  73. if (symbol != gNullCharPtr)
  74. delete[] symbol;
  75. if (unit != gNullCharPtr)
  76. delete[] unit;
  77. if (comment != gNullCharPtr)
  78. delete[] comment;
  79. if (groupName != gNullCharPtr)
  80. delete[] groupName;
  81. }
  82. _CarlaScalePointInfo::_CarlaScalePointInfo() noexcept
  83. : value(0.0f),
  84. label(gNullCharPtr) {}
  85. _CarlaScalePointInfo::~_CarlaScalePointInfo() noexcept
  86. {
  87. if (label != gNullCharPtr)
  88. delete[] label;
  89. }
  90. _CarlaTransportInfo::_CarlaTransportInfo() noexcept
  91. : playing(false),
  92. frame(0),
  93. bar(0),
  94. beat(0),
  95. tick(0),
  96. bpm(0.0) {}
  97. void _CarlaTransportInfo::clear() noexcept
  98. {
  99. playing = false;
  100. frame = 0;
  101. bar = 0;
  102. beat = 0;
  103. tick = 0;
  104. bpm = 0.0;
  105. }
  106. // -------------------------------------------------------------------------------------------------------------------
  107. const char* carla_get_library_filename()
  108. {
  109. carla_debug("carla_get_library_filename()");
  110. static CarlaString ret;
  111. if (ret.isEmpty())
  112. {
  113. using water::File;
  114. ret = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName().toRawUTF8();
  115. }
  116. return ret;
  117. }
  118. const char* carla_get_library_folder()
  119. {
  120. carla_debug("carla_get_library_folder()");
  121. static CarlaString ret;
  122. if (ret.isEmpty())
  123. {
  124. using water::File;
  125. ret = File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName().toRawUTF8();
  126. }
  127. return ret;
  128. }
  129. // -------------------------------------------------------------------------------------------------------------------