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.

169 lines
4.7KB

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