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 doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_BRIDGE_CLIENT_HPP_INCLUDED
  18. #define CARLA_BRIDGE_CLIENT_HPP_INCLUDED
  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 fOsc;
  99. const CarlaOscData& fOscData;
  100. #ifdef BUILD_BRIDGE_UI
  101. struct UI {
  102. CarlaBridgeToolkit* const toolkit;
  103. CarlaString filename;
  104. void* lib;
  105. bool quit;
  106. UI(CarlaBridgeToolkit* const toolkit_)
  107. : toolkit(toolkit_),
  108. lib(nullptr),
  109. quit(false)
  110. {
  111. CARLA_ASSERT(toolkit != nullptr);
  112. }
  113. ~UI()
  114. {
  115. delete toolkit;
  116. }
  117. void init()
  118. {
  119. toolkit->init();
  120. quit = false;
  121. }
  122. void close()
  123. {
  124. quit = true;
  125. toolkit->quit();
  126. }
  127. # ifdef CARLA_PROPER_CPP11_SUPPORT
  128. UI() = delete;
  129. UI(UI&) = delete;
  130. UI(const UI&) = delete;
  131. # endif
  132. } fUI;
  133. #else
  134. friend class CarlaPluginClient;
  135. #endif
  136. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaBridgeClient)
  137. };
  138. CARLA_BRIDGE_END_NAMESPACE
  139. #endif // CARLA_BRIDGE_CLIENT_HPP_INCLUDED