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.

CarlaBridgeFormat.hpp 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * Carla Bridge UI
  3. * Copyright (C) 2011-2021 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_BRIDGE_FORMAT_HPP_INCLUDED
  18. #define CARLA_BRIDGE_FORMAT_HPP_INCLUDED
  19. #include "CarlaBridgeUI.hpp"
  20. #include "CarlaLibUtils.hpp"
  21. #include "CarlaPipeUtils.hpp"
  22. #include "CarlaString.hpp"
  23. #include "lv2/atom.h"
  24. #include "lv2/urid.h"
  25. #include <vector>
  26. CARLA_BRIDGE_UI_START_NAMESPACE
  27. /*!
  28. * @defgroup CarlaBridgeUIAPI Carla UI Bridge API
  29. *
  30. * The Carla UI Bridge API.
  31. * @{
  32. */
  33. // -----------------------------------------------------------------------
  34. class CarlaBridgeFormat : public CarlaPipeClient
  35. {
  36. protected:
  37. /*!
  38. * Constructor.
  39. */
  40. CarlaBridgeFormat() noexcept;
  41. /*!
  42. * Destructor.
  43. */
  44. virtual ~CarlaBridgeFormat() /*noexcept*/;
  45. // ---------------------------------------------------------------------
  46. bool libOpen(const char* filename) noexcept;
  47. void* libSymbol(const char* symbol) const noexcept;
  48. const char* libError() const noexcept;
  49. // ---------------------------------------------------------------------
  50. // DSP Callbacks
  51. virtual void dspParameterChanged(uint32_t index, float value) = 0;
  52. virtual void dspParameterChanged(const char* uri, float value) = 0;
  53. virtual void dspProgramChanged(uint32_t index) = 0;
  54. virtual void dspMidiProgramChanged(uint32_t bank, uint32_t program) = 0;
  55. virtual void dspStateChanged(const char* key, const char* value) = 0;
  56. virtual void dspNoteReceived(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity) = 0;
  57. virtual void dspAtomReceived(uint32_t index, const LV2_Atom* atom) = 0;
  58. virtual void dspURIDReceived(LV2_URID urid, const char* uri) = 0;
  59. struct BridgeFormatOptions {
  60. double sampleRate;
  61. uint32_t bgColor;
  62. uint32_t fgColor;
  63. float uiScale;
  64. bool isStandalone;
  65. bool useTheme;
  66. bool useThemeColors;
  67. const char* windowTitle;
  68. uintptr_t transientWindowId;
  69. };
  70. virtual void uiOptionsChanged(const BridgeFormatOptions& opts) = 0;
  71. public:
  72. // ---------------------------------------------------------------------
  73. // UI initialization
  74. virtual bool init(int argc, const char* argv[]);
  75. virtual void exec(bool showUI);
  76. virtual void idleUI() {}
  77. // ---------------------------------------------------------------------
  78. // UI management
  79. /*!
  80. * Get the widget associated with this UI.
  81. * This can be a Gtk widget, Qt widget or a native Window handle depending on the compile target.
  82. */
  83. virtual void* getWidget() const noexcept = 0;
  84. #ifndef CARLA_OS_MAC
  85. /*!
  86. * TESTING
  87. */
  88. virtual void setScaleFactor(double scaleFactor) = 0;
  89. #endif
  90. /*!
  91. * TESTING
  92. */
  93. virtual void uiResized(uint width, uint height) = 0;
  94. /*!
  95. * Options.
  96. */
  97. struct Options {
  98. /*!
  99. * UI is standalone, not controlled by another application.
  100. */
  101. bool isStandalone;
  102. /*!
  103. * UI is resizable by the user.
  104. * The UI can still sometimes resize itself internally if this is false.
  105. */
  106. bool isResizable;
  107. /*!
  108. * Use the Carla PRO theme if possible.
  109. */
  110. bool useTheme;
  111. /*!
  112. * Use the Carla PRO theme colors if possible.
  113. * This implies useTheme to be true.
  114. */
  115. bool useThemeColors;
  116. /*!
  117. * Window title.
  118. */
  119. CarlaString windowTitle;
  120. /*!
  121. * Transient window id (parent), zero if unset.
  122. */
  123. uintptr_t transientWindowId;
  124. /*!
  125. * Constructor for default options.
  126. */
  127. Options() noexcept
  128. : isStandalone(true),
  129. isResizable(true),
  130. useTheme(true),
  131. useThemeColors(true),
  132. windowTitle("TestUI"),
  133. transientWindowId(0) {}
  134. };
  135. /*!
  136. * Get options associated with this UI.
  137. */
  138. virtual const Options& getOptions() const noexcept = 0;
  139. // ---------------------------------------------------------------------
  140. protected:
  141. bool fQuitReceived;
  142. bool fGotOptions;
  143. int fLastMsgTimer;
  144. CarlaBridgeToolkit* fToolkit;
  145. lib_t fLib;
  146. CarlaString fLibFilename;
  147. std::vector<uint8_t> fBase64ReservedChunk;
  148. /*! @internal */
  149. bool msgReceived(const char* msg) noexcept override;
  150. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaBridgeFormat)
  151. };
  152. /**@}*/
  153. // -----------------------------------------------------------------------
  154. CARLA_BRIDGE_UI_END_NAMESPACE
  155. #endif // CARLA_BRIDGE_FORMAT_HPP_INCLUDED