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.

179 lines
4.6KB

  1. /*
  2. * Carla Engine
  3. * Copyright (C) 2012-2013 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 GPL.txt file
  16. */
  17. #ifndef __CARLA_ENGINE_INTERNAL_HPP__
  18. #define __CARLA_ENGINE_INTERNAL_HPP__
  19. #include "carla_engine.hpp"
  20. #include "carla_engine_osc.hpp"
  21. #include "carla_engine_thread.hpp"
  22. #include "carla_plugin.hpp"
  23. //#include "rt_list.hpp"
  24. #ifndef BUILD_BRIDGE
  25. # include <QtCore/QProcessEnvironment>
  26. #endif
  27. CARLA_BACKEND_START_NAMESPACE
  28. // -------------------------------------------------------------------------------------------------------------------
  29. static inline
  30. const char* EngineType2Str(const EngineType type)
  31. {
  32. switch (type)
  33. {
  34. case kEngineTypeNull:
  35. return "kEngineTypeNull";
  36. case kEngineTypeJack:
  37. return "kEngineTypeJack";
  38. case kEngineTypeRtAudio:
  39. return "kEngineTypeRtAudio";
  40. case kEngineTypePlugin:
  41. return "kEngineTypePlugin";
  42. }
  43. qWarning("CarlaBackend::EngineType2Str(%i) - invalid type", type);
  44. return nullptr;
  45. }
  46. static inline
  47. const char* EnginePortType2Str(const EnginePortType type)
  48. {
  49. switch (type)
  50. {
  51. case kEnginePortTypeNull:
  52. return "kEnginePortTypeNull";
  53. case kEnginePortTypeAudio:
  54. return "kEnginePortTypeAudio";
  55. case kEnginePortTypeEvent:
  56. return "kEnginePortTypeEvent";
  57. }
  58. qWarning("CarlaBackend::EnginePortType2Str(%i) - invalid type", type);
  59. return nullptr;
  60. }
  61. static inline
  62. const char* EngineControlEventType2Str(const EngineControlEventType type)
  63. {
  64. switch (type)
  65. {
  66. case kEngineControlEventTypeNull:
  67. return "kEngineNullEvent";
  68. case kEngineControlEventTypeParameter:
  69. return "kEngineControlEventTypeParameter";
  70. case kEngineControlEventTypeMidiBank:
  71. return "kEngineControlEventTypeMidiBank";
  72. case kEngineControlEventTypeMidiProgram:
  73. return "kEngineControlEventTypeMidiProgram";
  74. case kEngineControlEventTypeAllSoundOff:
  75. return "kEngineControlEventTypeAllSoundOff";
  76. case kEngineControlEventTypeAllNotesOff:
  77. return "kEngineControlEventTypeAllNotesOff";
  78. }
  79. qWarning("CarlaBackend::EngineControlEventType2Str(%i) - invalid type", type);
  80. return nullptr;
  81. }
  82. // -------------------------------------------------------------------------------------------------------------------
  83. /*!
  84. * Maximum number of peaks per plugin.\n
  85. * \note There are both input and output peaks.
  86. */
  87. /*static*/ const unsigned short MAX_PEAKS = 2;
  88. const uint32_t PATCHBAY_BUFFER_SIZE = 128;
  89. const unsigned short PATCHBAY_EVENT_COUNT = 512;
  90. const unsigned short RACK_EVENT_COUNT = 1024;
  91. #if 0
  92. enum EnginePostEventType {
  93. EnginePostEventNull,
  94. EnginePostEventDebug,
  95. EnginePostEventAddPlugin, // id, ptr
  96. EnginePostEventRemovePlugin // id
  97. };
  98. struct EnginePostEvent {
  99. EnginePostEventType type;
  100. int32_t value1;
  101. void* valuePtr;
  102. EnginePostEvent()
  103. : type(EnginePostEventNull),
  104. value1(-1),
  105. valuePtr(nullptr) {}
  106. };
  107. #endif
  108. struct EnginePluginData {
  109. CarlaPlugin* plugin;
  110. double insPeak[MAX_PEAKS];
  111. double outsPeak[MAX_PEAKS];
  112. EnginePluginData()
  113. : plugin(nullptr),
  114. insPeak{0},
  115. outsPeak{0} {}
  116. };
  117. struct CarlaEngineProtectedData {
  118. CarlaEngineOsc osc;
  119. CarlaEngineThread thread;
  120. const CarlaOscData* oscData;
  121. CallbackFunc callback;
  122. void* callbackPtr;
  123. CarlaString lastError;
  124. #ifndef BUILD_BRIDGE
  125. QProcessEnvironment procEnv;
  126. #endif
  127. bool aboutToClose; // don't re-activate thread if true
  128. unsigned int curPluginCount; // number of plugins loaded (0...max)
  129. unsigned int maxPluginNumber; // number of plugins allowed (0, 16, 99 or 999)
  130. EnginePluginData* plugins;
  131. CarlaEngineProtectedData(CarlaEngine* const engine)
  132. : osc(engine),
  133. thread(engine),
  134. oscData(nullptr),
  135. callback(nullptr),
  136. callbackPtr(nullptr),
  137. aboutToClose(false),
  138. curPluginCount(0),
  139. maxPluginNumber(0),
  140. plugins(nullptr) {}
  141. CarlaEngineProtectedData() = delete;
  142. CARLA_LEAK_DETECTOR(CarlaEngineProtectedData)
  143. };
  144. CARLA_BACKEND_END_NAMESPACE
  145. #endif // __CARLA_ENGINE_INTERNAL_HPP__