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.

151 lines
4.2KB

  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. CARLA_BACKEND_START_NAMESPACE
  27. // -------------------------------------------------------------------------------------------------------------------
  28. static inline
  29. const char* CarlaEngineType2Str(const CarlaEngineType type)
  30. {
  31. switch (type)
  32. {
  33. case CarlaEngineTypeNull:
  34. return "CarlaEngineTypeNull";
  35. case CarlaEngineTypeJack:
  36. return "CarlaEngineTypeJack";
  37. case CarlaEngineTypeRtAudio:
  38. return "CarlaEngineTypeRtAudio";
  39. case CarlaEngineTypePlugin:
  40. return "CarlaEngineTypePlugin";
  41. }
  42. qWarning("CarlaBackend::CarlaEngineType2Str(%i) - invalid type", type);
  43. return nullptr;
  44. }
  45. static inline
  46. const char* CarlaEnginePortType2Str(const CarlaEnginePortType type)
  47. {
  48. switch (type)
  49. {
  50. case CarlaEnginePortTypeNull:
  51. return "CarlaEnginePortTypeNull";
  52. case CarlaEnginePortTypeAudio:
  53. return "CarlaEnginePortTypeAudio";
  54. case CarlaEnginePortTypeControl:
  55. return "CarlaEnginePortTypeControl";
  56. case CarlaEnginePortTypeMIDI:
  57. return "CarlaEnginePortTypeMIDI";
  58. }
  59. qWarning("CarlaBackend::CarlaEnginePortType2Str(%i) - invalid type", type);
  60. return nullptr;
  61. }
  62. static inline
  63. const char* CarlaEngineControlEventType2Str(const CarlaEngineControlEventType type)
  64. {
  65. switch (type)
  66. {
  67. case CarlaEngineNullEvent:
  68. return "CarlaEngineNullEvent";
  69. case CarlaEngineParameterChangeEvent:
  70. return "CarlaEngineParameterChangeEvent";
  71. case CarlaEngineMidiBankChangeEvent:
  72. return "CarlaEngineMidiBankChangeEvent";
  73. case CarlaEngineMidiProgramChangeEvent:
  74. return "CarlaEngineMidiProgramChangeEvent";
  75. case CarlaEngineAllSoundOffEvent:
  76. return "CarlaEngineAllSoundOffEvent";
  77. case CarlaEngineAllNotesOffEvent:
  78. return "CarlaEngineAllNotesOffEvent";
  79. }
  80. qWarning("CarlaBackend::CarlaEngineControlEventType2Str(%i) - invalid type", type);
  81. return nullptr;
  82. }
  83. // -------------------------------------------------------------------------------------------------------------------
  84. /*!
  85. * Maximum number of peaks per plugin.\n
  86. * \note There are both input and output peaks.
  87. */
  88. /*static*/ const unsigned short MAX_PEAKS = 2;
  89. const uint32_t PATCHBAY_BUFFER_SIZE = 128;
  90. const unsigned short PATCHBAY_EVENT_COUNT = 256;
  91. struct CarlaEnginePrivateData {
  92. CarlaEngineOsc osc;
  93. CarlaEngineThread thread;
  94. const CarlaOscData* oscData;
  95. CallbackFunc callback;
  96. void* callbackPtr;
  97. CarlaString lastError;
  98. #ifndef BUILD_BRIDGE
  99. QProcessEnvironment procEnv;
  100. #endif
  101. CarlaMutex procLock;
  102. CarlaMutex midiLock;
  103. // TODO - use ListHead for pointers, remove maximum static value
  104. CarlaPlugin* carlaPlugins[MAX_PLUGINS];
  105. const char* uniqueNames[MAX_PLUGINS];
  106. double insPeak[MAX_PLUGINS * MAX_PEAKS];
  107. double outsPeak[MAX_PLUGINS * MAX_PEAKS];
  108. bool aboutToClose;
  109. unsigned short maxPluginNumber;
  110. CarlaEnginePrivateData(CarlaEngine* const engine)
  111. : osc(engine),
  112. thread(engine),
  113. oscData(nullptr),
  114. callback(nullptr),
  115. callbackPtr(nullptr),
  116. carlaPlugins{nullptr},
  117. uniqueNames{nullptr},
  118. insPeak{0.0},
  119. outsPeak{0.0},
  120. aboutToClose(false),
  121. maxPluginNumber(0) {}
  122. };
  123. CARLA_BACKEND_END_NAMESPACE
  124. #endif // __CARLA_ENGINE_INTERNAL_HPP__