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.

235 lines
6.3KB

  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. #undef RTOSC_INVALID_MIDI
  49. #undef MAX_UNHANDLED_PATH
  50. #include "zynaddsubfx/rtosc/cpp/ports.cpp"
  51. #undef __builtin_expect
  52. #include "zynaddsubfx/rtosc/cpp/subtree-serialize.cpp"
  53. #include "zynaddsubfx/rtosc/cpp/thread-link.cpp"
  54. #undef off_t
  55. #undef static
  56. #include "zynaddsubfx/rtosc/cpp/undo-history.cpp"
  57. // zynaddsubfx ui includes
  58. #include "zynaddsubfx/UI/NioUI.cpp"
  59. #include "zynaddsubfx/UI/WidgetPDial.cpp"
  60. #include "zynaddsubfx/UI/ADnoteUI.cpp"
  61. #include "zynaddsubfx/UI/BankUI.cpp"
  62. #include "zynaddsubfx/UI/BankView.cpp"
  63. #include "zynaddsubfx/UI/ConfigUI.cpp"
  64. // #include "zynaddsubfx/UI/Connection.cpp"
  65. #include "zynaddsubfx/UI/EffUI.cpp"
  66. #include "zynaddsubfx/UI/EnvelopeFreeEdit.cpp"
  67. #include "zynaddsubfx/UI/EnvelopeUI.cpp"
  68. #include "zynaddsubfx/UI/FilterUI.cpp"
  69. #include "zynaddsubfx/UI/Fl_EQGraph.cpp"
  70. #include "zynaddsubfx/UI/Fl_Osc_Button.cpp"
  71. #include "zynaddsubfx/UI/Fl_Osc_Check.cpp"
  72. #include "zynaddsubfx/UI/Fl_Osc_Choice.cpp"
  73. #include "zynaddsubfx/UI/Fl_Osc_Counter.cpp"
  74. #include "zynaddsubfx/UI/Fl_Osc_Dial.cpp"
  75. #include "zynaddsubfx/UI/Fl_Osc_DialF.cpp"
  76. #include "zynaddsubfx/UI/Fl_Osc_Input.cpp"
  77. #include "zynaddsubfx/UI/Fl_Osc_ListView.cpp"
  78. #include "zynaddsubfx/UI/Fl_Osc_Output.cpp"
  79. #include "zynaddsubfx/UI/Fl_Osc_Pane.cpp"
  80. #include "zynaddsubfx/UI/Fl_Osc_Roller.cpp"
  81. #include "zynaddsubfx/UI/Fl_Osc_Slider.cpp"
  82. #include "zynaddsubfx/UI/Fl_Osc_Value.cpp"
  83. #include "zynaddsubfx/UI/Fl_Osc_VSlider.cpp"
  84. #include "zynaddsubfx/UI/Fl_Osc_Widget.cpp"
  85. #include "zynaddsubfx/UI/Fl_Resonance_Graph.cpp"
  86. #include "zynaddsubfx/UI/FormantFilterGraph.cpp"
  87. #include "zynaddsubfx/UI/LFOUI.cpp"
  88. #include "zynaddsubfx/UI/MasterUI.cpp"
  89. #include "zynaddsubfx/UI/MicrotonalUI.cpp"
  90. #include "zynaddsubfx/UI/OscilGenUI.cpp"
  91. #include "zynaddsubfx/UI/PADnoteUI.cpp"
  92. #include "zynaddsubfx/UI/PartNameButton.cpp"
  93. #include "zynaddsubfx/UI/PartUI.cpp"
  94. #include "zynaddsubfx/UI/PresetsUI.cpp"
  95. #include "zynaddsubfx/UI/ResonanceUI.cpp"
  96. #include "zynaddsubfx/UI/SUBnoteUI.cpp"
  97. #include "zynaddsubfx/UI/VirKeyboard.cpp"
  98. #include "zynaddsubfx/UI/guimain.cpp"
  99. class ZynPipeClient : public CarlaPipeClient
  100. {
  101. public:
  102. ZynPipeClient() noexcept
  103. : CarlaPipeClient(),
  104. fQuitReceived(false) {}
  105. ~ZynPipeClient() noexcept override
  106. {
  107. if (fQuitReceived)
  108. return;
  109. const CarlaMutexLocker cml(getPipeLock());
  110. writeMessage("exiting\n");
  111. flushMessages();
  112. }
  113. protected:
  114. bool msgReceived(const char* const msg) noexcept override
  115. {
  116. if (std::strcmp(msg, "control") == 0)
  117. {
  118. uint index;
  119. float value;
  120. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(index), true);
  121. CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
  122. // TODO
  123. return true;
  124. }
  125. if (std::strcmp(msg, "show") == 0)
  126. {
  127. try {
  128. GUI::raiseUi(gui, "/show", "i", 1);
  129. } CARLA_SAFE_EXCEPTION("msgReceived show");
  130. return true;
  131. }
  132. if (std::strcmp(msg, "hide") == 0)
  133. {
  134. try {
  135. GUI::raiseUi(gui, "/hide", "");
  136. } CARLA_SAFE_EXCEPTION("msgReceived hide");
  137. return true;
  138. }
  139. if (std::strcmp(msg, "focus") == 0)
  140. {
  141. try {
  142. GUI::raiseUi(gui, "/focus", "");
  143. } CARLA_SAFE_EXCEPTION("msgReceived focus");
  144. return true;
  145. }
  146. if (std::strcmp(msg, "uiTitle") == 0)
  147. {
  148. const char* uiTitle;
  149. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(uiTitle), true);
  150. try {
  151. GUI::raiseUi(gui, "/title", "s", uiTitle);
  152. } CARLA_SAFE_EXCEPTION("msgReceived uiTitle");
  153. return true;
  154. }
  155. if (std::strcmp(msg, "quit") == 0)
  156. {
  157. fQuitReceived = true;
  158. try {
  159. GUI::raiseUi(gui, "/close-ui", "");
  160. } CARLA_SAFE_EXCEPTION("msgReceived quit");
  161. return true;
  162. }
  163. carla_stderr("ZynPipeClient::msgReceived : %s", msg);
  164. return false;
  165. }
  166. private:
  167. bool fQuitReceived;
  168. };
  169. int main(int argc, const char* argv[])
  170. {
  171. ZynPipeClient pipe;
  172. const char* uiTitle = nullptr;
  173. if (argc > 1)
  174. {
  175. sendtourl = argv[1];
  176. uiTitle = argv[2];
  177. if (! pipe.initPipeClient(argv))
  178. return 1;
  179. server = lo_server_new_with_proto(NULL, LO_UDP, liblo_error_cb);
  180. lo_server_add_method(server, NULL, NULL, handler_function, 0);
  181. }
  182. gui = GUI::createUi(new UI_Interface(), &Pexitprogram);
  183. if (argc == 1)
  184. GUI::raiseUi(gui, "/show", "i", 1);
  185. for (; Pexitprogram == 0;)
  186. {
  187. if (server != nullptr) {
  188. for (; lo_server_recv_noblock(server, 0);) {}
  189. }
  190. pipe.idlePipe();
  191. GUI::tickUi(gui);
  192. }
  193. GUI::destroyUi(gui);
  194. gui = nullptr;
  195. return 0;
  196. }
  197. // --------------------------------------------------------------------------------------------