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.

177 lines
4.8KB

  1. /*
  2. * Carla Bridge Client
  3. * Copyright (C) 2011-2013 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 GPL.txt file
  16. */
  17. #ifndef __CARLA_BRIDGE_CLIENT_HPP__
  18. #define __CARLA_BRIDGE_CLIENT_HPP__
  19. #include "CarlaBridgeOsc.hpp"
  20. #ifdef BUILD_BRIDGE_UI
  21. # include "CarlaBridgeToolkit.hpp"
  22. #endif
  23. CARLA_BRIDGE_START_NAMESPACE
  24. #if 0
  25. } // Fix editor indentation
  26. #endif
  27. class CarlaBridgeClient
  28. {
  29. public:
  30. CarlaBridgeClient(const char* const uiTitle);
  31. virtual ~CarlaBridgeClient();
  32. #ifdef BUILD_BRIDGE_UI
  33. // ---------------------------------------------------------------------
  34. // ui initialization
  35. virtual bool uiInit(const char* const, const char* const);
  36. virtual void uiClose();
  37. // ---------------------------------------------------------------------
  38. // ui management
  39. virtual void* getWidget() const = 0;
  40. virtual bool isResizable() const = 0;
  41. virtual bool needsReparent() const = 0;
  42. // ---------------------------------------------------------------------
  43. // ui processing
  44. virtual void setParameter(const int32_t rindex, const float value) = 0;
  45. virtual void setProgram(const uint32_t index) = 0;
  46. virtual void setMidiProgram(const uint32_t bank, const uint32_t program) = 0;
  47. virtual void noteOn(const uint8_t channel, const uint8_t note, const uint8_t velo) = 0;
  48. virtual void noteOff(const uint8_t channel, const uint8_t note) = 0;
  49. // ---------------------------------------------------------------------
  50. // ui toolkit
  51. void toolkitShow();
  52. void toolkitHide();
  53. void toolkitResize(const int width, const int height);
  54. void toolkitExec(const bool showGui);
  55. void toolkitQuit();
  56. #endif
  57. #ifdef BUILD_BRIDGE_PLUGIN
  58. // ---------------------------------------------------------------------
  59. // plugin management
  60. virtual void saveNow() = 0;
  61. virtual void setCustomData(const char* const type, const char* const key, const char* const value) = 0;
  62. virtual void setChunkData(const char* const filePath) = 0;
  63. #endif
  64. // ---------------------------------------------------------------------
  65. // osc stuff
  66. void oscInit(const char* const url);
  67. bool oscIdle();
  68. void oscClose();
  69. bool isOscControlRegistered() const;
  70. void sendOscUpdate();
  71. #ifdef BUILD_BRIDGE_PLUGIN
  72. void sendOscBridgeUpdate();
  73. void sendOscBridgeError(const char* const error);
  74. #endif
  75. // ---------------------------------------------------------------------
  76. protected:
  77. void sendOscConfigure(const char* const key, const char* const value);
  78. void sendOscControl(const int32_t index, const float value);
  79. void sendOscProgram(const int32_t index);
  80. void sendOscMidiProgram(const int32_t index);
  81. void sendOscMidi(const uint8_t midiBuf[4]);
  82. void sendOscExiting();
  83. #ifdef BRIDGE_LV2
  84. void sendOscLv2AtomTransfer(const int32_t portIndex, const char* const atomBuf);
  85. void sendOscLv2UridMap(const uint32_t urid, const char* const uri);
  86. #endif
  87. // ---------------------------------------------------------------------
  88. #ifdef BUILD_BRIDGE_UI
  89. void* getContainerId();
  90. bool uiLibOpen(const char* const filename);
  91. bool uiLibClose();
  92. void* uiLibSymbol(const char* const symbol);
  93. const char* uiLibError();
  94. #endif
  95. // ---------------------------------------------------------------------
  96. private:
  97. CarlaBridgeOsc kOsc;
  98. #ifdef BUILD_BRIDGE_UI
  99. struct UI {
  100. CarlaBridgeToolkit* const toolkit;
  101. CarlaString filename;
  102. void* lib;
  103. bool quit;
  104. UI(CarlaBridgeToolkit* const toolkit_)
  105. : toolkit(toolkit_),
  106. lib(nullptr),
  107. quit(false)
  108. {
  109. CARLA_ASSERT(toolkit != nullptr);
  110. }
  111. ~UI()
  112. {
  113. delete toolkit;
  114. }
  115. void init()
  116. {
  117. toolkit->init();
  118. quit = false;
  119. }
  120. void close()
  121. {
  122. quit = true;
  123. toolkit->quit();
  124. }
  125. # ifdef CARLA_PROPER_CPP11_SUPPORT
  126. UI() = delete;
  127. UI(UI&) = delete;
  128. UI(const UI&) = delete;
  129. # endif
  130. } fUI;
  131. #else
  132. friend class CarlaPluginClient;
  133. #endif
  134. const CarlaOscData* fOscData;
  135. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaBridgeClient)
  136. };
  137. CARLA_BRIDGE_END_NAMESPACE
  138. #endif // __CARLA_BRIDGE_CLIENT_HPP__