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.

293 lines
11KB

  1. /*
  2. * Carla plugin host
  3. * Copyright (C) 2011-2019 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. #ifndef CARLA_HOST_HPP_INCLUDED
  18. #define CARLA_HOST_HPP_INCLUDED
  19. //---------------------------------------------------------------------------------------------------------------------
  20. // Imports (Global)
  21. #include <QtWidgets/QMainWindow>
  22. //---------------------------------------------------------------------------------------------------------------------
  23. // Imports (Custom)
  24. #include "shared.hpp"
  25. #include "../../backend/CarlaBackend.h"
  26. #include "../../utils/CarlaJuceUtils.hpp"
  27. CARLA_BACKEND_USE_NAMESPACE;
  28. //---------------------------------------------------------------------------------------------------------------------
  29. struct Host : public QObject
  30. {
  31. // info about this host object
  32. bool isControl;
  33. bool isPlugin;
  34. bool isRemote;
  35. bool nsmOK;
  36. // settings
  37. EngineProcessMode processMode;
  38. EngineTransportMode transportMode;
  39. QString transportExtra;
  40. EngineProcessMode nextProcessMode;
  41. bool processModeForced;
  42. QString audioDriverForced;
  43. // settings
  44. bool experimental;
  45. bool exportLV2;
  46. bool forceStereo;
  47. bool manageUIs;
  48. uint maxParameters;
  49. bool preferPluginBridges;
  50. bool preferUIBridges;
  51. bool preventBadBehaviour;
  52. bool showLogs;
  53. bool showPluginBridges;
  54. bool showWineBridges;
  55. bool uiBridgesTimeout;
  56. bool uisAlwaysOnTop;
  57. // settings
  58. QString pathBinaries;
  59. QString pathResources;
  60. Host();
  61. // Qt Stuff
  62. Q_SIGNAL void EngineStartedCallback(uint, int, int, int, float, QString);
  63. Q_SIGNAL void EngineStoppedCallback();
  64. Q_OBJECT
  65. };
  66. //---------------------------------------------------------------------------------------------------------------------
  67. // Host Window
  68. class CarlaHostWindow : public QMainWindow
  69. {
  70. Q_OBJECT
  71. // signals
  72. Q_SIGNAL void SIGTERM();
  73. Q_SIGNAL void SIGUSR1();
  74. enum CustomActions {
  75. CUSTOM_ACTION_NONE,
  76. CUSTOM_ACTION_APP_CLOSE,
  77. CUSTOM_ACTION_PROJECT_LOAD
  78. };
  79. public:
  80. //-----------------------------------------------------------------------------------------------------------------
  81. CarlaHostWindow(Host& host, const bool withCanvas, QWidget* const parent = nullptr);
  82. ~CarlaHostWindow() override;
  83. private:
  84. Host& host;
  85. struct PrivateData;
  86. PrivateData* const self;
  87. //-----------------------------------------------------------------------------------------------------------------
  88. // Setup
  89. void compactPlugin(uint pluginId);
  90. void changePluginColor(uint pluginId, QString color, QString colorStr);
  91. void changePluginSkin(uint pluginId, QString skin);
  92. void switchPlugins(uint pluginIdA, uint pluginIdB);
  93. void setLoadRDFsNeeded() noexcept;
  94. void setProperWindowTitle();
  95. void updateBufferSize(uint newBufferSize);
  96. void updateSampleRate(double newSampleRate);
  97. //-----------------------------------------------------------------------------------------------------------------
  98. // Files
  99. //-----------------------------------------------------------------------------------------------------------------
  100. // Files (menu actions)
  101. //-----------------------------------------------------------------------------------------------------------------
  102. // Engine (menu actions)
  103. Q_SLOT void slot_engineStart();
  104. Q_SLOT bool slot_engineStop(bool forced = false);
  105. Q_SLOT void slot_engineConfig();
  106. Q_SLOT bool slot_engineStopTryAgain();
  107. void engineStopFinal();
  108. //-----------------------------------------------------------------------------------------------------------------
  109. // Engine (host callbacks)
  110. Q_SLOT void slot_handleEngineStartedCallback(uint pluginCount, int processMode, int transportMode, int bufferSize, float sampleRate, QString driverName);
  111. Q_SLOT void slot_handleEngineStoppedCallback();
  112. //-----------------------------------------------------------------------------------------------------------------
  113. // Plugins
  114. //-----------------------------------------------------------------------------------------------------------------
  115. // Plugins (menu actions)
  116. //-----------------------------------------------------------------------------------------------------------------
  117. // Plugins (macros)
  118. //-----------------------------------------------------------------------------------------------------------------
  119. // Plugins (host callbacks)
  120. //-----------------------------------------------------------------------------------------------------------------
  121. // Canvas
  122. //-----------------------------------------------------------------------------------------------------------------
  123. // Canvas (menu actions)
  124. //-----------------------------------------------------------------------------------------------------------------
  125. // Canvas (canvas callbacks)
  126. //-----------------------------------------------------------------------------------------------------------------
  127. // Canvas (host callbacks)
  128. //-----------------------------------------------------------------------------------------------------------------
  129. // Settings
  130. void saveSettings();
  131. void loadSettings(bool firstTime);
  132. //-----------------------------------------------------------------------------------------------------------------
  133. // Settings (helpers)
  134. //-----------------------------------------------------------------------------------------------------------------
  135. // Settings (menu actions)
  136. Q_SLOT void slot_showSidePanel(bool yesNo);
  137. Q_SLOT void slot_showToolbar(bool yesNo);
  138. Q_SLOT void slot_showCanvasMeters(bool yesNo);
  139. Q_SLOT void slot_showCanvasKeyboard(bool yesNo);
  140. Q_SLOT void slot_configureCarla();
  141. //-----------------------------------------------------------------------------------------------------------------
  142. // About (menu actions)
  143. //-----------------------------------------------------------------------------------------------------------------
  144. // Disk (menu actions)
  145. //-----------------------------------------------------------------------------------------------------------------
  146. // Transport
  147. void refreshTransport(bool forced = false);
  148. //-----------------------------------------------------------------------------------------------------------------
  149. // Transport (menu actions)
  150. Q_SLOT void slot_transportPlayPause(bool toggled);
  151. Q_SLOT void slot_transportStop();
  152. Q_SLOT void slot_transportBackwards();
  153. Q_SLOT void slot_transportBpmChanged(qreal newValue);
  154. Q_SLOT void slot_transportForwards();
  155. Q_SLOT void slot_transportJackEnabled(bool clicked);
  156. Q_SLOT void slot_transportLinkEnabled(bool clicked);
  157. //-----------------------------------------------------------------------------------------------------------------
  158. // Other
  159. Q_SLOT void slot_xrunClear();
  160. //-----------------------------------------------------------------------------------------------------------------
  161. // Canvas scrollbars
  162. //-----------------------------------------------------------------------------------------------------------------
  163. // Canvas keyboard
  164. //-----------------------------------------------------------------------------------------------------------------
  165. // Canvas keyboard (host callbacks)
  166. //-----------------------------------------------------------------------------------------------------------------
  167. //-----------------------------------------------------------------------------------------------------------------
  168. // MiniCanvas stuff
  169. //-----------------------------------------------------------------------------------------------------------------
  170. // Timers
  171. void startTimers();
  172. void restartTimersIfNeeded();
  173. void killTimers();
  174. //-----------------------------------------------------------------------------------------------------------------
  175. // Misc
  176. //-----------------------------------------------------------------------------------------------------------------
  177. //-----------------------------------------------------------------------------------------------------------------
  178. //-----------------------------------------------------------------------------------------------------------------
  179. //-----------------------------------------------------------------------------------------------------------------
  180. // Internal stuff
  181. //-----------------------------------------------------------------------------------------------------------------
  182. //-----------------------------------------------------------------------------------------------------------------
  183. //-----------------------------------------------------------------------------------------------------------------
  184. // show/hide event
  185. //-----------------------------------------------------------------------------------------------------------------
  186. // resize event
  187. //-----------------------------------------------------------------------------------------------------------------
  188. // timer event
  189. void refreshRuntimeInfo(float load, int xruns);
  190. void getAndRefreshRuntimeInfo();
  191. void idleFast();
  192. void idleSlow();
  193. void timerEvent(QTimerEvent* event);
  194. //-----------------------------------------------------------------------------------------------------------------
  195. // color/style change event
  196. void changeEvent(QEvent* event) override;
  197. void updateStyle();
  198. //-----------------------------------------------------------------------------------------------------------------
  199. // close event
  200. bool shouldIgnoreClose();
  201. void closeEvent(QCloseEvent* event) override;
  202. //-----------------------------------------------------------------------------------------------------------------
  203. // CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaHostWindow)
  204. };
  205. //---------------------------------------------------------------------------------------------------------------------
  206. // Init host
  207. Host& initHost(const QString initName, const bool isControl, const bool isPlugin, const bool failError);
  208. //---------------------------------------------------------------------------------------------------------------------
  209. // Load host settings
  210. void loadHostSettings(Host& host);
  211. //---------------------------------------------------------------------------------------------------------------------
  212. #endif // CARLA_HOST_HPP_INCLUDED