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.

230 lines
6.2KB

  1. /*
  2. * Carla Native Plugins
  3. * Copyright (C) 2012-2015 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. #include "CarlaPipeUtils.cpp"
  18. #ifdef CARLA_OS_WIN
  19. # define errx(...)
  20. # define warnx(...)
  21. #else
  22. # include <err.h>
  23. #endif
  24. #define PLUGINVERSION
  25. #define SOURCE_DIR "/usr/share/zynaddsubfx"
  26. #undef override
  27. #ifdef NTK_GUI
  28. # include <dlfcn.h>
  29. static CarlaString getResourceDir()
  30. {
  31. Dl_info exeInfo;
  32. dladdr((void*)getResourceDir, &exeInfo);
  33. CarlaString filename(exeInfo.dli_fname);
  34. return filename.truncate(filename.rfind("-ui"));
  35. }
  36. CarlaString gUiPixmapPath(getResourceDir());
  37. #endif
  38. // base c-style headers
  39. #include "zynaddsubfx/rtosc/rtosc.h"
  40. // rtosc c includes
  41. extern "C" {
  42. #include "zynaddsubfx/rtosc/dispatch.c"
  43. #include "zynaddsubfx/rtosc/rtosc.c"
  44. }
  45. // rtosc c++ includes
  46. #include "zynaddsubfx/rtosc/cpp/midimapper.cpp"
  47. #include "zynaddsubfx/rtosc/cpp/miditable.cpp"
  48. #include "zynaddsubfx/rtosc/cpp/ports.cpp"
  49. #include "zynaddsubfx/rtosc/cpp/subtree-serialize.cpp"
  50. #include "zynaddsubfx/rtosc/cpp/thread-link.cpp"
  51. #include "zynaddsubfx/rtosc/cpp/undo-history.cpp"
  52. // zynaddsubfx ui includes
  53. #include "zynaddsubfx/UI/NioUI.cpp"
  54. #include "zynaddsubfx/UI/WidgetPDial.cpp"
  55. #include "zynaddsubfx/UI/ADnoteUI.cpp"
  56. #include "zynaddsubfx/UI/BankUI.cpp"
  57. #include "zynaddsubfx/UI/BankView.cpp"
  58. #include "zynaddsubfx/UI/ConfigUI.cpp"
  59. // #include "zynaddsubfx/UI/Connection.cpp"
  60. #include "zynaddsubfx/UI/EffUI.cpp"
  61. #include "zynaddsubfx/UI/EnvelopeFreeEdit.cpp"
  62. #include "zynaddsubfx/UI/EnvelopeUI.cpp"
  63. #include "zynaddsubfx/UI/FilterUI.cpp"
  64. #include "zynaddsubfx/UI/Fl_EQGraph.cpp"
  65. #include "zynaddsubfx/UI/Fl_Osc_Button.cpp"
  66. #include "zynaddsubfx/UI/Fl_Osc_Check.cpp"
  67. #include "zynaddsubfx/UI/Fl_Osc_Choice.cpp"
  68. #include "zynaddsubfx/UI/Fl_Osc_Counter.cpp"
  69. #include "zynaddsubfx/UI/Fl_Osc_Dial.cpp"
  70. #include "zynaddsubfx/UI/Fl_Osc_DialF.cpp"
  71. #include "zynaddsubfx/UI/Fl_Osc_Input.cpp"
  72. #include "zynaddsubfx/UI/Fl_Osc_ListView.cpp"
  73. #include "zynaddsubfx/UI/Fl_Osc_Output.cpp"
  74. #include "zynaddsubfx/UI/Fl_Osc_Pane.cpp"
  75. #include "zynaddsubfx/UI/Fl_Osc_Roller.cpp"
  76. #include "zynaddsubfx/UI/Fl_Osc_Slider.cpp"
  77. #include "zynaddsubfx/UI/Fl_Osc_Value.cpp"
  78. #include "zynaddsubfx/UI/Fl_Osc_VSlider.cpp"
  79. #include "zynaddsubfx/UI/Fl_Osc_Widget.cpp"
  80. #include "zynaddsubfx/UI/Fl_Resonance_Graph.cpp"
  81. #include "zynaddsubfx/UI/FormantFilterGraph.cpp"
  82. #include "zynaddsubfx/UI/LFOUI.cpp"
  83. #include "zynaddsubfx/UI/MasterUI.cpp"
  84. #include "zynaddsubfx/UI/MicrotonalUI.cpp"
  85. #include "zynaddsubfx/UI/OscilGenUI.cpp"
  86. #include "zynaddsubfx/UI/PADnoteUI.cpp"
  87. #include "zynaddsubfx/UI/PartNameButton.cpp"
  88. #include "zynaddsubfx/UI/PartUI.cpp"
  89. #include "zynaddsubfx/UI/PresetsUI.cpp"
  90. #include "zynaddsubfx/UI/ResonanceUI.cpp"
  91. #include "zynaddsubfx/UI/SUBnoteUI.cpp"
  92. #include "zynaddsubfx/UI/VirKeyboard.cpp"
  93. #include "zynaddsubfx/UI/guimain.cpp"
  94. class ZynPipeClient : public CarlaPipeClient
  95. {
  96. public:
  97. ZynPipeClient() noexcept
  98. : CarlaPipeClient(),
  99. fQuitReceived(false) {}
  100. ~ZynPipeClient() noexcept override
  101. {
  102. if (fQuitReceived)
  103. return;
  104. const CarlaMutexLocker cml(getPipeLock());
  105. writeMessage("exiting\n");
  106. flushMessages();
  107. }
  108. protected:
  109. bool msgReceived(const char* const msg) noexcept override
  110. {
  111. if (std::strcmp(msg, "control") == 0)
  112. {
  113. uint index;
  114. float value;
  115. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(index), true);
  116. CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
  117. // TODO
  118. return true;
  119. }
  120. if (std::strcmp(msg, "show") == 0)
  121. {
  122. try {
  123. GUI::raiseUi(gui, "/show", "i", 1);
  124. } CARLA_SAFE_EXCEPTION("msgReceived show");
  125. return true;
  126. }
  127. if (std::strcmp(msg, "hide") == 0)
  128. {
  129. try {
  130. GUI::raiseUi(gui, "/hide", "");
  131. } CARLA_SAFE_EXCEPTION("msgReceived hide");
  132. return true;
  133. }
  134. if (std::strcmp(msg, "focus") == 0)
  135. {
  136. try {
  137. GUI::raiseUi(gui, "/focus", "");
  138. } CARLA_SAFE_EXCEPTION("msgReceived focus");
  139. return true;
  140. }
  141. if (std::strcmp(msg, "uiTitle") == 0)
  142. {
  143. const char* uiTitle;
  144. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(uiTitle), true);
  145. try {
  146. GUI::raiseUi(gui, "/title", "s", uiTitle);
  147. } CARLA_SAFE_EXCEPTION("msgReceived uiTitle");
  148. return true;
  149. }
  150. if (std::strcmp(msg, "quit") == 0)
  151. {
  152. fQuitReceived = true;
  153. try {
  154. GUI::raiseUi(gui, "/close-ui", "");
  155. } CARLA_SAFE_EXCEPTION("msgReceived quit");
  156. return true;
  157. }
  158. carla_stderr("ZynPipeClient::msgReceived : %s", msg);
  159. return false;
  160. }
  161. private:
  162. bool fQuitReceived;
  163. };
  164. int main(int argc, const char* argv[])
  165. {
  166. ZynPipeClient pipe;
  167. const char* uiTitle = nullptr;
  168. if (argc > 1)
  169. {
  170. sendtourl = argv[1];
  171. uiTitle = argv[2];
  172. if (! pipe.initPipeClient(argv))
  173. return 1;
  174. server = lo_server_new_with_proto(NULL, LO_UDP, liblo_error_cb);
  175. lo_server_add_method(server, NULL, NULL, handler_function, 0);
  176. }
  177. gui = GUI::createUi(new UI_Interface(), &Pexitprogram);
  178. if (argc == 1)
  179. GUI::raiseUi(gui, "/show", "i", 1);
  180. for (; Pexitprogram == 0;)
  181. {
  182. if (server != nullptr) {
  183. for (; lo_server_recv_noblock(server, 0);) {}
  184. }
  185. pipe.idlePipe();
  186. GUI::tickUi(gui);
  187. }
  188. GUI::destroyUi(gui);
  189. gui = nullptr;
  190. return 0;
  191. }
  192. // --------------------------------------------------------------------------------------------