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.

170 lines
4.6KB

  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. // ---------------------------------------------------------------------
  59. // osc stuff
  60. void oscInit(const char* const url);
  61. bool oscIdle() const;
  62. void oscWait() const;
  63. void oscClose();
  64. bool isOscControlRegistered() const noexcept;
  65. void sendOscUpdate() const;
  66. #ifdef BUILD_BRIDGE_PLUGIN
  67. void sendOscBridgeUpdate() const;
  68. void sendOscBridgeError(const char* const error) const;
  69. #endif
  70. // ---------------------------------------------------------------------
  71. protected:
  72. void sendOscConfigure(const char* const key, const char* const value) const;
  73. void sendOscControl(const int32_t index, const float value) const;
  74. void sendOscProgram(const uint32_t index) const;
  75. void sendOscMidiProgram(const uint32_t index) const;
  76. void sendOscMidi(const uint8_t midiBuf[4]) const;
  77. void sendOscExiting() const;
  78. #ifdef BRIDGE_LV2
  79. void sendOscLv2AtomTransfer(const int32_t portIndex, const char* const atomBuf) const;
  80. void sendOscLv2UridMap(const uint32_t urid, const char* const uri) const;
  81. #endif
  82. // ---------------------------------------------------------------------
  83. #ifdef BUILD_BRIDGE_UI
  84. void* getContainerId();
  85. bool uiLibOpen(const char* const filename);
  86. bool uiLibClose();
  87. void* uiLibSymbol(const char* const symbol);
  88. const char* uiLibError();
  89. #endif
  90. // ---------------------------------------------------------------------
  91. private:
  92. CarlaBridgeOsc fOsc;
  93. const CarlaOscData& fOscData;
  94. #ifdef BUILD_BRIDGE_UI
  95. struct UI {
  96. CarlaBridgeToolkit* const toolkit;
  97. CarlaString filename;
  98. void* lib;
  99. bool quit;
  100. UI(CarlaBridgeToolkit* const toolkit_)
  101. : toolkit(toolkit_),
  102. lib(nullptr),
  103. quit(false)
  104. {
  105. CARLA_ASSERT(toolkit != nullptr);
  106. }
  107. ~UI()
  108. {
  109. delete toolkit;
  110. }
  111. void init()
  112. {
  113. toolkit->init();
  114. quit = false;
  115. }
  116. void close()
  117. {
  118. quit = true;
  119. toolkit->quit();
  120. }
  121. # ifdef CARLA_PROPER_CPP11_SUPPORT
  122. UI() = delete;
  123. UI(UI&) = delete;
  124. UI(const UI&) = delete;
  125. # endif
  126. } fUI;
  127. #else
  128. friend class CarlaPluginClient;
  129. friend class JackBridgeClient;
  130. #endif
  131. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaBridgeClient)
  132. };
  133. CARLA_BRIDGE_END_NAMESPACE
  134. #endif // CARLA_BRIDGE_CLIENT_HPP_INCLUDED