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-2014 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 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. // ---------------------------------------------------------------------
  38. // ui processing
  39. virtual void setParameter(const int32_t rindex, const float value) = 0;
  40. virtual void setProgram(const uint32_t index) = 0;
  41. virtual void setMidiProgram(const uint32_t bank, const uint32_t program) = 0;
  42. virtual void noteOn(const uint8_t channel, const uint8_t note, const uint8_t velo) = 0;
  43. virtual void noteOff(const uint8_t channel, const uint8_t note) = 0;
  44. // ---------------------------------------------------------------------
  45. // ui toolkit
  46. void toolkitShow();
  47. void toolkitHide();
  48. void toolkitResize(const int width, const int height);
  49. void toolkitExec(const bool showGui);
  50. void toolkitQuit();
  51. // ---------------------------------------------------------------------
  52. // osc stuff
  53. void oscInit(const char* const url);
  54. bool oscIdle(const bool onlyOnce = false) const;
  55. void oscClose();
  56. bool isOscControlRegistered() const noexcept;
  57. void sendOscUpdate() const;
  58. // ---------------------------------------------------------------------
  59. protected:
  60. void sendOscConfigure(const char* const key, const char* const value) const;
  61. void sendOscControl(const int32_t index, const float value) const;
  62. void sendOscProgram(const uint32_t index) const;
  63. void sendOscMidiProgram(const uint32_t index) const;
  64. void sendOscMidi(const uint8_t midiBuf[4]) const;
  65. void sendOscExiting() const;
  66. #ifdef BRIDGE_LV2
  67. void sendOscLv2AtomTransfer(const uint32_t portIndex, const char* const atomBuf) const;
  68. void sendOscLv2UridMap(const uint32_t urid, const char* const uri) const;
  69. #endif
  70. // ---------------------------------------------------------------------
  71. void* getContainerId();
  72. void* getContainerId2();
  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