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