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.

160 lines
4.4KB

  1. /*
  2. * Carla Engine
  3. * Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * 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 COPYING 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. #ifndef BUILD_BRIDGE
  24. # include <QtCore/QProcessEnvironment>
  25. #endif
  26. #ifdef CARLA_ENGINE_RTAUDIO
  27. # if defined(Q_OS_MAC) && ! defined(__MACOSX_CORE__)
  28. # define __MACOSX_CORE__
  29. # endif
  30. # if defined(Q_OS_WIN) && ! (defined(__WINDOWS_ASIO__) || defined(__WINDOWS_DS__))
  31. # define __WINDOWS_ASIO__
  32. # define __WINDOWS_DS__
  33. # endif
  34. #endif
  35. CARLA_BACKEND_START_NAMESPACE
  36. // -------------------------------------------------------------------------------------------------------------------
  37. static inline
  38. const char* CarlaEngineType2Str(const CarlaEngineType type)
  39. {
  40. switch (type)
  41. {
  42. case CarlaEngineTypeNull:
  43. return "CarlaEngineTypeNull";
  44. case CarlaEngineTypeJack:
  45. return "CarlaEngineTypeJack";
  46. case CarlaEngineTypeRtAudio:
  47. return "CarlaEngineTypeRtAudio";
  48. case CarlaEngineTypePlugin:
  49. return "CarlaEngineTypePlugin";
  50. }
  51. qWarning("CarlaBackend::CarlaEngineType2Str(%i) - invalid type", type);
  52. return nullptr;
  53. }
  54. static inline
  55. const char* CarlaEnginePortType2Str(const CarlaEnginePortType type)
  56. {
  57. switch (type)
  58. {
  59. case CarlaEnginePortTypeNull:
  60. return "CarlaEnginePortTypeNull";
  61. case CarlaEnginePortTypeAudio:
  62. return "CarlaEnginePortTypeAudio";
  63. case CarlaEnginePortTypeControl:
  64. return "CarlaEnginePortTypeControl";
  65. case CarlaEnginePortTypeMIDI:
  66. return "CarlaEnginePortTypeMIDI";
  67. }
  68. qWarning("CarlaBackend::CarlaEnginePortType2Str(%i) - invalid type", type);
  69. return nullptr;
  70. }
  71. static inline
  72. const char* CarlaEngineControlEventType2Str(const CarlaEngineControlEventType type)
  73. {
  74. switch (type)
  75. {
  76. case CarlaEngineNullEvent:
  77. return "CarlaEngineNullEvent";
  78. case CarlaEngineParameterChangeEvent:
  79. return "CarlaEngineParameterChangeEvent";
  80. case CarlaEngineMidiBankChangeEvent:
  81. return "CarlaEngineMidiBankChangeEvent";
  82. case CarlaEngineMidiProgramChangeEvent:
  83. return "CarlaEngineMidiProgramChangeEvent";
  84. case CarlaEngineAllSoundOffEvent:
  85. return "CarlaEngineAllSoundOffEvent";
  86. case CarlaEngineAllNotesOffEvent:
  87. return "CarlaEngineAllNotesOffEvent";
  88. }
  89. qWarning("CarlaBackend::CarlaEngineControlEventType2Str(%i) - invalid type", type);
  90. return nullptr;
  91. }
  92. // -------------------------------------------------------------------------------------------------------------------
  93. /*!
  94. * Maximum number of peaks per plugin.\n
  95. * \note There are both input and output peaks.
  96. */
  97. /*static*/ const unsigned short MAX_PEAKS = 2;
  98. const uint32_t PATCHBAY_BUFFER_SIZE = 128;
  99. const unsigned short PATCHBAY_EVENT_COUNT = 256;
  100. struct CarlaEnginePrivateData {
  101. CarlaEngineOsc osc;
  102. CarlaEngineThread thread;
  103. const CarlaOscData* oscData;
  104. CallbackFunc callback;
  105. void* callbackPtr;
  106. CarlaString lastError;
  107. #ifndef BUILD_BRIDGE
  108. QProcessEnvironment procEnv;
  109. #endif
  110. QMutex procLock;
  111. QMutex midiLock;
  112. CarlaPlugin* carlaPlugins[MAX_PLUGINS];
  113. const char* uniqueNames[MAX_PLUGINS];
  114. double insPeak[MAX_PLUGINS * MAX_PEAKS];
  115. double outsPeak[MAX_PLUGINS * MAX_PEAKS];
  116. bool aboutToClose;
  117. unsigned short maxPluginNumber;
  118. CarlaEnginePrivateData(CarlaEngine* const engine)
  119. : osc(engine),
  120. thread(engine),
  121. oscData(nullptr),
  122. callback(nullptr),
  123. callbackPtr(nullptr),
  124. carlaPlugins{nullptr},
  125. uniqueNames{nullptr},
  126. insPeak{0.0},
  127. outsPeak{0.0},
  128. aboutToClose(false),
  129. maxPluginNumber(0) {}
  130. };
  131. CARLA_BACKEND_END_NAMESPACE
  132. #endif // __CARLA_ENGINE_INTERNAL_HPP__