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 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Carla Bridge UI
  3. * Copyright (C) 2011-2017 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* const filename) noexcept;
  47. void* libSymbol(const char* const symbol) const noexcept;
  48. const char* libError() const noexcept;
  49. // ---------------------------------------------------------------------
  50. // DSP Callbacks
  51. virtual void dspParameterChanged(const uint32_t index, const float value) = 0;
  52. virtual void dspProgramChanged(const uint32_t index) = 0;
  53. virtual void dspMidiProgramChanged(const uint32_t bank, const uint32_t program) = 0;
  54. virtual void dspStateChanged(const char* const key, const char* const value) = 0;
  55. virtual void dspNoteReceived(const bool onOff, const uint8_t channel, const uint8_t note, const uint8_t velocity) = 0;
  56. virtual void dspAtomReceived(const uint32_t index, const LV2_Atom* const atom) = 0;
  57. virtual void dspURIDReceived(const LV2_URID urid, const char* const uri) = 0;
  58. struct BridgeFormatOptions {
  59. double sampleRate;
  60. uint32_t bgColor;
  61. uint32_t fgColor;
  62. float uiScale;
  63. bool useTheme;
  64. bool useThemeColors;
  65. const char* windowTitle;
  66. uintptr_t transientWindowId;
  67. };
  68. virtual void uiOptionsChanged(const BridgeFormatOptions& opts) = 0;
  69. public:
  70. // ---------------------------------------------------------------------
  71. // UI initialization
  72. virtual bool init(const int argc, const char* argv[]);
  73. virtual void exec(const bool showUI);
  74. virtual void idleUI() {}
  75. // ---------------------------------------------------------------------
  76. // UI management
  77. /*!
  78. * Get the widget associated with this UI.
  79. * This can be a Gtk widget, Qt widget or a native Window handle depending on the compile target.
  80. */
  81. virtual void* getWidget() const noexcept = 0;
  82. /*!
  83. * TESTING
  84. */
  85. virtual void uiResized(const uint width, const uint height) = 0;
  86. /*!
  87. * Options.
  88. */
  89. struct Options {
  90. /*!
  91. * UI is resizable by the user.
  92. * The UI can still sometimes resize itself internally if this is false.
  93. */
  94. bool isResizable;
  95. /*!
  96. * Use the Carla PRO theme if possible.
  97. */
  98. bool useTheme;
  99. /*!
  100. * Use the Carla PRO theme colors if possible.
  101. * This implies useTheme to be true.
  102. */
  103. bool useThemeColors;
  104. /*!
  105. * Window title.
  106. */
  107. CarlaString windowTitle;
  108. /*!
  109. * Transient window id (parent), zero if unset.
  110. */
  111. uintptr_t transientWindowId;
  112. /*!
  113. * Constructor for default options.
  114. */
  115. Options() noexcept
  116. : isResizable(true),
  117. useTheme(true),
  118. useThemeColors(true),
  119. windowTitle("TestUI"),
  120. transientWindowId(0) {}
  121. };
  122. /*!
  123. * Get options associated with this UI.
  124. */
  125. virtual const Options& getOptions() const noexcept = 0;
  126. // ---------------------------------------------------------------------
  127. protected:
  128. bool fQuitReceived;
  129. bool fGotOptions;
  130. int fLastMsgTimer;
  131. CarlaBridgeToolkit* fToolkit;
  132. lib_t fLib;
  133. CarlaString fLibFilename;
  134. std::vector<uint8_t> fBase64ReservedChunk;
  135. /*! @internal */
  136. bool msgReceived(const char* const msg) noexcept override;
  137. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaBridgeFormat)
  138. };
  139. /**@}*/
  140. // -----------------------------------------------------------------------
  141. CARLA_BRIDGE_UI_END_NAMESPACE
  142. #endif // CARLA_BRIDGE_FORMAT_HPP_INCLUDED