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.

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