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.

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