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.

151 lines
4.4KB

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