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.

1904 lines
62KB

  1. /*
  2. * Carla Standalone
  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 GPL.txt file
  16. */
  17. #include "CarlaStandalone.hpp"
  18. #include "CarlaBackendUtils.hpp"
  19. #include "CarlaEngine.hpp"
  20. #include "CarlaPlugin.hpp"
  21. #include "CarlaMIDI.h"
  22. #include "CarlaNative.h"
  23. #if 0
  24. extern "C" {
  25. #include "siginfo.c"
  26. }
  27. #endif
  28. using CarlaBackend::CarlaEngine;
  29. using CarlaBackend::CarlaPlugin;
  30. using CarlaBackend::CallbackFunc;
  31. using CarlaBackend::EngineOptions;
  32. // -------------------------------------------------------------------------------------------------------------------
  33. // Single, standalone engine
  34. struct CarlaBackendStandalone {
  35. CallbackFunc callback;
  36. void* callbackPtr;
  37. CarlaEngine* engine;
  38. CarlaString lastError;
  39. CarlaString procName;
  40. EngineOptions options;
  41. CarlaBackendStandalone()
  42. : callback(nullptr),
  43. callbackPtr(nullptr),
  44. engine(nullptr) {}
  45. } standalone;
  46. // -------------------------------------------------------------------------------------------------------------------
  47. // Helpers
  48. CarlaEngine* carla_get_standalone_engine()
  49. {
  50. return standalone.engine;
  51. }
  52. // -------------------------------------------------------------------------------------------------------------------
  53. // API
  54. const char* carla_get_extended_license_text()
  55. {
  56. carla_debug("carla_get_extended_license_text()");
  57. static CarlaString retText;
  58. if (retText.isEmpty())
  59. {
  60. retText = "<p>This current Carla build is using the following features and 3rd-party code:</p>";
  61. retText += "<ul>";
  62. #ifdef WANT_LADSPA
  63. retText += "<li>LADSPA plugin support, http://www.ladspa.org/</li>";
  64. #endif
  65. #ifdef WANT_DSSI
  66. retText += "<li>DSSI plugin support, http://dssi.sourceforge.net/</li>";
  67. #endif
  68. #ifdef WANT_LV2
  69. retText += "<li>LV2 plugin support, http://lv2plug.in/</li>";
  70. #endif
  71. #ifdef WANT_VST
  72. # ifdef VESTIGE_HEADER
  73. retText += "<li>VST plugin support, using VeSTige header by Javier Serrano Polo</li>";
  74. # else
  75. retText += "<li>VST plugin support, using official VST SDK 2.4 (trademark of Steinberg Media Technologies GmbH)</li>";
  76. # endif
  77. #endif
  78. #ifdef WANT_ZYNADDSUBFX
  79. retText += "<li>ZynAddSubFX plugin code, http://zynaddsubfx.sf.net/</li>";
  80. #endif
  81. #ifdef WANT_FLUIDSYNTH
  82. retText += "<li>FluidSynth library for SF2 support, http://www.fluidsynth.org/</li>";
  83. #endif
  84. #ifdef WANT_LINUXSAMPLER
  85. retText += "<li>LinuxSampler library for GIG and SFZ support*, http://www.linuxsampler.org/</li>";
  86. #endif
  87. retText += "<li>liblo library for OSC support, http://liblo.sourceforge.net/</li>";
  88. #ifdef WANT_LV2
  89. retText += "<li>serd, sord, sratom and lilv libraries for LV2 discovery, http://drobilla.net/software/lilv/</li>";
  90. #endif
  91. #ifdef CARLA_ENGINE_RTAUDIO
  92. retText += "<li>RtAudio and RtMidi libraries for extra Audio and MIDI support, http://www.music.mcgill.ca/~gary/rtaudio/</li>";
  93. #endif
  94. retText += "</ul>";
  95. #ifdef WANT_LINUXSAMPLER
  96. retText += "<p>(*) Using LinuxSampler code in commercial hardware or software products is not allowed without prior written authorization by the authors.</p>";
  97. #endif
  98. }
  99. return retText;
  100. }
  101. // -------------------------------------------------------------------------------------------------------------------
  102. unsigned int carla_get_engine_driver_count()
  103. {
  104. carla_debug("carla_get_engine_driver_count()");
  105. return CarlaEngine::getDriverCount();
  106. }
  107. const char* carla_get_engine_driver_name(unsigned int index)
  108. {
  109. carla_debug("carla_get_engine_driver_name(%i)", index);
  110. return CarlaEngine::getDriverName(index);
  111. }
  112. // -------------------------------------------------------------------------------------------------------------------
  113. unsigned int carla_get_internal_plugin_count()
  114. {
  115. carla_debug("carla_get_internal_plugin_count()");
  116. return static_cast<unsigned int>(CarlaPlugin::getNativePluginCount());
  117. }
  118. const CarlaNativePluginInfo* carla_get_internal_plugin_info(unsigned int internalPluginId)
  119. {
  120. carla_debug("carla_get_internal_plugin_info(%i)", internalPluginId);
  121. static CarlaNativePluginInfo info;
  122. const PluginDescriptor* const nativePlugin = CarlaPlugin::getNativePluginDescriptor(internalPluginId);
  123. // as internal plugin, this must never fail
  124. CARLA_ASSERT(nativePlugin != nullptr);
  125. if (nativePlugin == nullptr)
  126. return nullptr;
  127. info.category = static_cast<CarlaPluginCategory>(nativePlugin->category);
  128. info.hints = 0x0;
  129. if (nativePlugin->hints & PLUGIN_IS_RTSAFE)
  130. info.hints |= CarlaBackend::PLUGIN_IS_RTSAFE;
  131. if (nativePlugin->hints & PLUGIN_IS_SYNTH)
  132. info.hints |= CarlaBackend::PLUGIN_IS_SYNTH;
  133. if (nativePlugin->hints & PLUGIN_HAS_GUI)
  134. info.hints |= CarlaBackend::PLUGIN_HAS_GUI;
  135. if (nativePlugin->hints & PLUGIN_USES_SINGLE_THREAD)
  136. info.hints |= CarlaBackend::PLUGIN_USES_SINGLE_THREAD;
  137. info.audioIns = nativePlugin->audioIns;
  138. info.audioOuts = nativePlugin->audioOuts;
  139. info.midiIns = nativePlugin->midiIns;
  140. info.midiOuts = nativePlugin->midiOuts;
  141. info.parameterIns = nativePlugin->parameterIns;
  142. info.parameterOuts = nativePlugin->parameterOuts;
  143. info.name = nativePlugin->name;
  144. info.label = nativePlugin->label;
  145. info.maker = nativePlugin->maker;
  146. info.copyright = nativePlugin->copyright;
  147. return &info;
  148. }
  149. // -------------------------------------------------------------------------------------------------------------------
  150. bool carla_engine_init(const char* driverName, const char* clientName)
  151. {
  152. carla_debug("carla_engine_init(\"%s\", \"%s\")", driverName, clientName);
  153. CARLA_ASSERT(standalone.engine == nullptr);
  154. CARLA_ASSERT(driverName != nullptr);
  155. CARLA_ASSERT(clientName != nullptr);
  156. #if 0
  157. static bool sigInfoInitiated = false;
  158. if (! sigInfoInitiated)
  159. {
  160. setup_siginfo();
  161. sigInfoInitiated = true;
  162. }
  163. #endif
  164. standalone.engine = CarlaEngine::newDriverByName(driverName);
  165. if (standalone.engine == nullptr)
  166. {
  167. standalone.lastError = "The seleted audio driver is not available!";
  168. return false;
  169. }
  170. #ifndef Q_OS_WIN
  171. // TODO: make this an option, put somewhere else
  172. if (getenv("WINE_RT") == nullptr)
  173. {
  174. carla_setenv("WINE_RT", "15");
  175. carla_setenv("WINE_SVR_RT", "10");
  176. }
  177. #endif
  178. if (standalone.callback != nullptr)
  179. standalone.engine->setCallback(standalone.callback, nullptr);
  180. #ifndef BUILD_BRIDGE
  181. standalone.engine->setOption(CarlaBackend::OPTION_PROCESS_MODE, static_cast<int>(standalone.options.processMode), nullptr);
  182. standalone.engine->setOption(CarlaBackend::OPTION_FORCE_STEREO, standalone.options.forceStereo ? 1 : 0, nullptr);
  183. standalone.engine->setOption(CarlaBackend::OPTION_PREFER_PLUGIN_BRIDGES, standalone.options.preferPluginBridges ? 1 : 0, nullptr);
  184. standalone.engine->setOption(CarlaBackend::OPTION_PREFER_UI_BRIDGES, standalone.options.preferUiBridges ? 1 : 0, nullptr);
  185. # ifdef WANT_DSSI
  186. standalone.engine->setOption(CarlaBackend::OPTION_USE_DSSI_VST_CHUNKS, standalone.options.useDssiVstChunks ? 1 : 0, nullptr);
  187. # endif
  188. standalone.engine->setOption(CarlaBackend::OPTION_MAX_PARAMETERS, static_cast<int>(standalone.options.maxParameters), nullptr);
  189. standalone.engine->setOption(CarlaBackend::OPTION_PREFERRED_BUFFER_SIZE, static_cast<int>(standalone.options.preferredBufferSize), nullptr);
  190. standalone.engine->setOption(CarlaBackend::OPTION_PREFERRED_SAMPLE_RATE, static_cast<int>(standalone.options.preferredSampleRate), nullptr);
  191. standalone.engine->setOption(CarlaBackend::OPTION_OSC_UI_TIMEOUT, static_cast<int>(standalone.options.oscUiTimeout), nullptr);
  192. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_NATIVE, 0, standalone.options.bridge_native);
  193. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_POSIX32, 0, standalone.options.bridge_posix32);
  194. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_POSIX64, 0, standalone.options.bridge_posix64);
  195. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_WIN32, 0, standalone.options.bridge_win32);
  196. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_WIN64, 0, standalone.options.bridge_win64);
  197. # ifdef WANT_LV2
  198. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_LV2_GTK2, 0, standalone.options.bridge_lv2gtk2);
  199. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_LV2_GTK3, 0, standalone.options.bridge_lv2gtk3);
  200. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_LV2_QT4, 0, standalone.options.bridge_lv2qt4);
  201. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_LV2_QT5, 0, standalone.options.bridge_lv2qt5);
  202. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_LV2_COCOA, 0, standalone.options.bridge_lv2cocoa);
  203. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_LV2_WINDOWS, 0, standalone.options.bridge_lv2win);
  204. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_LV2_X11, 0, standalone.options.bridge_lv2qt4);
  205. # endif
  206. # ifdef WANT_VST
  207. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_VST_COCOA, 0, standalone.options.bridge_vstcocoa);
  208. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_VST_HWND, 0, standalone.options.bridge_vsthwnd);
  209. standalone.engine->setOption(CarlaBackend::OPTION_PATH_BRIDGE_VST_X11, 0, standalone.options.bridge_vstx11);
  210. # endif
  211. if (standalone.procName.isNotEmpty())
  212. standalone.engine->setOption(CarlaBackend::OPTION_PROCESS_NAME, 0, standalone.procName);
  213. #endif
  214. const bool initiated = standalone.engine->init(clientName);
  215. if (initiated)
  216. {
  217. standalone.lastError = "no error";
  218. }
  219. else
  220. {
  221. standalone.lastError = standalone.engine->getLastError();
  222. delete standalone.engine;
  223. standalone.engine = nullptr;
  224. }
  225. return initiated;
  226. }
  227. bool carla_engine_close()
  228. {
  229. carla_debug("carla_engine_close()");
  230. CARLA_ASSERT(standalone.engine != nullptr);
  231. if (standalone.engine == nullptr)
  232. {
  233. standalone.lastError = "Engine is not started";
  234. return false;
  235. }
  236. standalone.engine->setAboutToClose();
  237. standalone.engine->removeAllPlugins();
  238. const bool closed = standalone.engine->close();
  239. delete standalone.engine;
  240. standalone.engine = nullptr;
  241. return closed;
  242. }
  243. void carla_engine_idle()
  244. {
  245. CARLA_ASSERT(standalone.engine != nullptr);
  246. if (standalone.engine != nullptr)
  247. standalone.engine->idle();
  248. }
  249. bool carla_is_engine_running()
  250. {
  251. carla_debug("carla_is_engine_running()");
  252. return (standalone.engine != nullptr && standalone.engine->isRunning());
  253. }
  254. void carla_set_engine_about_to_close()
  255. {
  256. carla_debug("carla_set_engine_about_to_close()");
  257. CARLA_ASSERT(standalone.engine != nullptr);
  258. if (standalone.engine != nullptr)
  259. standalone.engine->setAboutToClose();
  260. }
  261. void carla_set_engine_callback(CarlaBackend::CallbackFunc func, void* ptr)
  262. {
  263. carla_debug("carla_set_engine_callback(%p)", func);
  264. standalone.callback = func;
  265. standalone.callbackPtr = ptr;
  266. if (standalone.engine != nullptr)
  267. standalone.engine->setCallback(func, ptr);
  268. }
  269. void carla_set_engine_option(CarlaBackend::OptionsType option, int value, const char* valueStr)
  270. {
  271. carla_debug("carla_set_engine_option(%s, %i, \"%s\")", CarlaBackend::OptionsType2Str(option), value, valueStr);
  272. #ifndef BUILD_BRIDGE
  273. if (standalone.engine != nullptr)
  274. standalone.engine->setOption(option, value, valueStr);
  275. #endif
  276. switch (option)
  277. {
  278. case CarlaBackend::OPTION_PROCESS_NAME:
  279. standalone.procName = valueStr;
  280. break;
  281. case CarlaBackend::OPTION_PROCESS_MODE:
  282. if (value < CarlaBackend::PROCESS_MODE_SINGLE_CLIENT || value > CarlaBackend::PROCESS_MODE_PATCHBAY)
  283. return carla_stderr2("carla_set_engine_option(OPTION_PROCESS_MODE, %i, \"%s\") - invalid value", value, valueStr);
  284. standalone.options.processMode = static_cast<CarlaBackend::ProcessMode>(value);
  285. break;
  286. case CarlaBackend::OPTION_FORCE_STEREO:
  287. standalone.options.forceStereo = (value != 0);
  288. break;
  289. case CarlaBackend::OPTION_PREFER_PLUGIN_BRIDGES:
  290. standalone.options.preferPluginBridges = (value != 0);
  291. break;
  292. case CarlaBackend::OPTION_PREFER_UI_BRIDGES:
  293. standalone.options.preferUiBridges = (value != 0);
  294. break;
  295. #ifdef WANT_DSSI
  296. case CarlaBackend::OPTION_USE_DSSI_VST_CHUNKS:
  297. standalone.options.useDssiVstChunks = (value != 0);
  298. break;
  299. #endif
  300. case CarlaBackend::OPTION_MAX_PARAMETERS:
  301. standalone.options.maxParameters = (value > 0) ? static_cast<unsigned int>(value) : CarlaBackend::MAX_DEFAULT_PARAMETERS;
  302. break;
  303. case CarlaBackend::OPTION_OSC_UI_TIMEOUT:
  304. standalone.options.oscUiTimeout = static_cast<unsigned int>(value);
  305. break;
  306. case CarlaBackend::OPTION_PREFERRED_BUFFER_SIZE:
  307. standalone.options.preferredBufferSize = static_cast<unsigned int>(value);
  308. break;
  309. case CarlaBackend::OPTION_PREFERRED_SAMPLE_RATE:
  310. standalone.options.preferredSampleRate = static_cast<unsigned int>(value);
  311. break;
  312. #ifndef BUILD_BRIDGE
  313. case CarlaBackend::OPTION_PATH_BRIDGE_NATIVE:
  314. standalone.options.bridge_native = valueStr;
  315. break;
  316. case CarlaBackend::OPTION_PATH_BRIDGE_POSIX32:
  317. standalone.options.bridge_posix32 = valueStr;
  318. break;
  319. case CarlaBackend::OPTION_PATH_BRIDGE_POSIX64:
  320. standalone.options.bridge_posix64 = valueStr;
  321. break;
  322. case CarlaBackend::OPTION_PATH_BRIDGE_WIN32:
  323. standalone.options.bridge_win32 = valueStr;
  324. break;
  325. case CarlaBackend::OPTION_PATH_BRIDGE_WIN64:
  326. standalone.options.bridge_win64 = valueStr;
  327. break;
  328. #endif
  329. #ifdef WANT_LV2
  330. case CarlaBackend::OPTION_PATH_BRIDGE_LV2_GTK2:
  331. standalone.options.bridge_lv2gtk2 = valueStr;
  332. break;
  333. case CarlaBackend::OPTION_PATH_BRIDGE_LV2_GTK3:
  334. standalone.options.bridge_lv2gtk3 = valueStr;
  335. break;
  336. case CarlaBackend::OPTION_PATH_BRIDGE_LV2_QT4:
  337. standalone.options.bridge_lv2qt4 = valueStr;
  338. break;
  339. case CarlaBackend::OPTION_PATH_BRIDGE_LV2_QT5:
  340. standalone.options.bridge_lv2qt5 = valueStr;
  341. break;
  342. case CarlaBackend::OPTION_PATH_BRIDGE_LV2_COCOA:
  343. standalone.options.bridge_lv2cocoa = valueStr;
  344. break;
  345. case CarlaBackend::OPTION_PATH_BRIDGE_LV2_WINDOWS:
  346. standalone.options.bridge_lv2win = valueStr;
  347. break;
  348. case CarlaBackend::OPTION_PATH_BRIDGE_LV2_X11:
  349. standalone.options.bridge_lv2x11 = valueStr;
  350. break;
  351. #endif
  352. #ifdef WANT_VST
  353. case CarlaBackend::OPTION_PATH_BRIDGE_VST_COCOA:
  354. standalone.options.bridge_vstcocoa = valueStr;
  355. break;
  356. case CarlaBackend::OPTION_PATH_BRIDGE_VST_HWND:
  357. standalone.options.bridge_vsthwnd = valueStr;
  358. break;
  359. case CarlaBackend::OPTION_PATH_BRIDGE_VST_X11:
  360. standalone.options.bridge_vstx11 = valueStr;
  361. break;
  362. #endif
  363. }
  364. }
  365. // -------------------------------------------------------------------------------------------------------------------
  366. bool carla_load_project(const char* filename)
  367. {
  368. carla_debug("carla_load_project(\"%s\")", filename);
  369. CARLA_ASSERT(standalone.engine != nullptr);
  370. CARLA_ASSERT(filename != nullptr);
  371. if (standalone.engine != nullptr)
  372. return standalone.engine->loadProject(filename);
  373. standalone.lastError = "Engine is not started";
  374. return false;
  375. }
  376. bool carla_save_project(const char* filename)
  377. {
  378. carla_debug("carla_save_project(\"%s\")", filename);
  379. CARLA_ASSERT(standalone.engine != nullptr);
  380. CARLA_ASSERT(filename != nullptr);
  381. if (standalone.engine != nullptr)
  382. return standalone.engine->saveProject(filename);
  383. standalone.lastError = "Engine is not started";
  384. return false;
  385. }
  386. // -------------------------------------------------------------------------------------------------------------------
  387. bool carla_add_plugin(CarlaBackend::BinaryType btype, CarlaBackend::PluginType ptype, const char* filename, const char* const name, const char* label, const void* extraStuff)
  388. {
  389. carla_debug("carla_add_plugin(%s, %s, \"%s\", \"%s\", \"%s\", %p)", CarlaBackend::BinaryType2Str(btype), CarlaBackend::PluginType2Str(ptype), filename, name, label, extraStuff);
  390. CARLA_ASSERT(standalone.engine != nullptr);
  391. if (standalone.engine != nullptr && standalone.engine->isRunning())
  392. return standalone.engine->addPlugin(btype, ptype, filename, name, label, extraStuff);
  393. standalone.lastError = "Engine is not started";
  394. return false;
  395. }
  396. bool carla_remove_plugin(unsigned int pluginId)
  397. {
  398. carla_debug("carla_remove_plugin(%i)", pluginId);
  399. CARLA_ASSERT(standalone.engine != nullptr);
  400. if (standalone.engine != nullptr && standalone.engine->isRunning())
  401. return standalone.engine->removePlugin(pluginId);
  402. standalone.lastError = "Engine is not started";
  403. return false;
  404. }
  405. void carla_remove_all_plugins()
  406. {
  407. carla_debug("carla_remove_all_plugins()");
  408. CARLA_ASSERT(standalone.engine != nullptr);
  409. if (standalone.engine != nullptr && standalone.engine->isRunning())
  410. standalone.engine->removeAllPlugins();
  411. }
  412. // -------------------------------------------------------------------------------------------------------------------
  413. const CarlaPluginInfo* carla_get_plugin_info(unsigned int pluginId)
  414. {
  415. carla_debug("carla_get_plugin_info(%i)", pluginId);
  416. CARLA_ASSERT(standalone.engine != nullptr);
  417. static CarlaPluginInfo info;
  418. // reset
  419. info.type = CarlaBackend::PLUGIN_NONE;
  420. info.category = CarlaBackend::PLUGIN_CATEGORY_NONE;
  421. info.hints = 0x0;
  422. info.hints = 0x0;
  423. info.binary = nullptr;
  424. info.name = nullptr;
  425. info.uniqueId = 0;
  426. info.latency = 0;
  427. info.optionsAvailable = 0x0;
  428. info.optionsEnabled = 0x0;
  429. // cleanup
  430. if (info.label != nullptr)
  431. {
  432. delete[] info.label;
  433. info.label = nullptr;
  434. }
  435. if (info.maker != nullptr)
  436. {
  437. delete[] info.maker;
  438. info.maker = nullptr;
  439. }
  440. if (info.copyright != nullptr)
  441. {
  442. delete[] info.copyright;
  443. info.copyright = nullptr;
  444. }
  445. if (standalone.engine == nullptr)
  446. return &info;
  447. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  448. {
  449. char strBufLabel[STR_MAX] = { 0 };
  450. char strBufMaker[STR_MAX] = { 0 };
  451. char strBufCopyright[STR_MAX] = { 0 };
  452. info.type = plugin->type();
  453. info.category = plugin->category();
  454. info.hints = plugin->hints();
  455. info.binary = plugin->filename();
  456. info.name = plugin->name();
  457. info.uniqueId = plugin->uniqueId();
  458. info.latency = plugin->latency();
  459. info.optionsAvailable = plugin->availableOptions();
  460. info.optionsEnabled = plugin->options();
  461. plugin->getLabel(strBufLabel);
  462. info.label = carla_strdup(strBufLabel);
  463. plugin->getMaker(strBufMaker);
  464. info.maker = carla_strdup(strBufMaker);
  465. plugin->getCopyright(strBufCopyright);
  466. info.copyright = carla_strdup(strBufCopyright);
  467. return &info;
  468. }
  469. carla_stderr2("carla_get_plugin_info(%i) - could not find plugin", pluginId);
  470. return &info;
  471. }
  472. const CarlaPortCountInfo* carla_get_audio_port_count_info(unsigned int pluginId)
  473. {
  474. carla_debug("carla_get_audio_port_count_info(%i)", pluginId);
  475. CARLA_ASSERT(standalone.engine != nullptr);
  476. static CarlaPortCountInfo info;
  477. // reset
  478. info.ins = 0;
  479. info.outs = 0;
  480. info.total = 0;
  481. if (standalone.engine == nullptr)
  482. return &info;
  483. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  484. {
  485. info.ins = plugin->audioInCount();
  486. info.outs = plugin->audioOutCount();
  487. info.total = info.ins + info.outs;
  488. return &info;
  489. }
  490. carla_stderr2("carla_get_audio_port_count_info(%i) - could not find plugin", pluginId);
  491. return &info;
  492. }
  493. const CarlaPortCountInfo* carla_get_midi_port_count_info(unsigned int pluginId)
  494. {
  495. carla_debug("carla_get_midi_port_count_info(%i)", pluginId);
  496. CARLA_ASSERT(standalone.engine != nullptr);
  497. static CarlaPortCountInfo info;
  498. // reset
  499. info.ins = 0;
  500. info.outs = 0;
  501. info.total = 0;
  502. if (standalone.engine == nullptr)
  503. return &info;
  504. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  505. {
  506. info.ins = plugin->midiInCount();
  507. info.outs = plugin->midiOutCount();
  508. info.total = info.ins + info.outs;
  509. return &info;
  510. }
  511. carla_stderr2("carla_get_midi_port_count_info(%i) - could not find plugin", pluginId);
  512. return &info;
  513. }
  514. const CarlaPortCountInfo* carla_get_parameter_count_info(unsigned int pluginId)
  515. {
  516. carla_debug("carla_get_parameter_count_info(%i)", pluginId);
  517. CARLA_ASSERT(standalone.engine != nullptr);
  518. static CarlaPortCountInfo info;
  519. // reset
  520. info.ins = 0;
  521. info.outs = 0;
  522. info.total = 0;
  523. if (standalone.engine == nullptr)
  524. return &info;
  525. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  526. {
  527. plugin->getParameterCountInfo(&info.ins, &info.outs, &info.total);
  528. return &info;
  529. }
  530. carla_stderr2("carla_get_parameter_count_info(%i) - could not find plugin", pluginId);
  531. return &info;
  532. }
  533. const CarlaParameterInfo* carla_get_parameter_info(unsigned int pluginId, uint32_t parameterId)
  534. {
  535. carla_debug("carla_get_parameter_info(%i, %i)", pluginId, parameterId);
  536. CARLA_ASSERT(standalone.engine != nullptr);
  537. static CarlaParameterInfo info;
  538. // reset
  539. info.scalePointCount = 0;
  540. // cleanup
  541. if (info.name != nullptr)
  542. {
  543. delete[] info.name;
  544. info.name = nullptr;
  545. }
  546. if (info.symbol != nullptr)
  547. {
  548. delete[] info.symbol;
  549. info.symbol = nullptr;
  550. }
  551. if (info.unit != nullptr)
  552. {
  553. delete[] info.unit;
  554. info.unit = nullptr;
  555. }
  556. if (standalone.engine == nullptr)
  557. return &info;
  558. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  559. {
  560. if (parameterId < plugin->parameterCount())
  561. {
  562. char strBufName[STR_MAX] = { 0 };
  563. char strBufSymbol[STR_MAX] = { 0 };
  564. char strBufUnit[STR_MAX] = { 0 };
  565. info.scalePointCount = plugin->parameterScalePointCount(parameterId);
  566. plugin->getParameterName(parameterId, strBufName);
  567. info.name = carla_strdup(strBufName);
  568. plugin->getParameterSymbol(parameterId, strBufSymbol);
  569. info.symbol = carla_strdup(strBufSymbol);
  570. plugin->getParameterUnit(parameterId, strBufUnit);
  571. info.unit = carla_strdup(strBufUnit);
  572. }
  573. else
  574. carla_stderr2("carla_get_parameter_info(%i, %i) - parameterId out of bounds", pluginId, parameterId);
  575. return &info;
  576. }
  577. carla_stderr2("carla_get_parameter_info(%i, %i) - could not find plugin", pluginId, parameterId);
  578. return &info;
  579. }
  580. const CarlaScalePointInfo* carla_get_parameter_scalepoint_info(unsigned int pluginId, uint32_t parameterId, uint32_t scalePointId)
  581. {
  582. carla_debug("carla_get_parameter_scalepoint_info(%i, %i, %i)", pluginId, parameterId, scalePointId);
  583. CARLA_ASSERT(standalone.engine != nullptr);
  584. static CarlaScalePointInfo info;
  585. // reset
  586. info.value = 0.0f;
  587. // cleanup
  588. if (info.label != nullptr)
  589. {
  590. delete[] info.label;
  591. info.label = nullptr;
  592. }
  593. if (standalone.engine == nullptr)
  594. return &info;
  595. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  596. {
  597. if (parameterId < plugin->parameterCount())
  598. {
  599. if (scalePointId < plugin->parameterScalePointCount(parameterId))
  600. {
  601. char strBufLabel[STR_MAX] = { 0 };
  602. info.value = plugin->getParameterScalePointValue(parameterId, scalePointId);
  603. plugin->getParameterScalePointLabel(parameterId, scalePointId, strBufLabel);
  604. info.label = carla_strdup(strBufLabel);
  605. }
  606. else
  607. carla_stderr2("carla_get_parameter_scalepoint_info(%i, %i, %i) - scalePointId out of bounds", pluginId, parameterId, scalePointId);
  608. }
  609. else
  610. carla_stderr2("carla_get_parameter_scalepoint_info(%i, %i, %i) - parameterId out of bounds", pluginId, parameterId, scalePointId);
  611. return &info;
  612. }
  613. carla_stderr2("carla_get_parameter_scalepoint_info(%i, %i, %i) - could not find plugin", pluginId, parameterId, scalePointId);
  614. return &info;
  615. }
  616. // -------------------------------------------------------------------------------------------------------------------
  617. const CarlaBackend::ParameterData* carla_get_parameter_data(unsigned int pluginId, uint32_t parameterId)
  618. {
  619. carla_debug("carla_get_parameter_data(%i, %i)", pluginId, parameterId);
  620. CARLA_ASSERT(standalone.engine != nullptr);
  621. static CarlaBackend::ParameterData data;
  622. if (standalone.engine == nullptr)
  623. return &data;
  624. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  625. {
  626. if (parameterId < plugin->parameterCount())
  627. return &plugin->parameterData(parameterId);
  628. carla_stderr2("carla_get_parameter_data(%i, %i) - parameterId out of bounds", pluginId, parameterId);
  629. return &data;
  630. }
  631. carla_stderr2("carla_get_parameter_data(%i, %i) - could not find plugin", pluginId, parameterId);
  632. return &data;
  633. }
  634. const CarlaBackend::ParameterRanges* carla_get_parameter_ranges(unsigned int pluginId, uint32_t parameterId)
  635. {
  636. carla_debug("carla_get_parameter_ranges(%i, %i)", pluginId, parameterId);
  637. CARLA_ASSERT(standalone.engine != nullptr);
  638. static CarlaBackend::ParameterRanges ranges;
  639. if (standalone.engine == nullptr)
  640. return &ranges;
  641. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  642. {
  643. if (parameterId < plugin->parameterCount())
  644. return &plugin->parameterRanges(parameterId);
  645. carla_stderr2("carla_get_parameter_ranges(%i, %i) - parameterId out of bounds", pluginId, parameterId);
  646. return &ranges;
  647. }
  648. carla_stderr2("carla_get_parameter_ranges(%i, %i) - could not find plugin", pluginId, parameterId);
  649. return &ranges;
  650. }
  651. const CarlaBackend::MidiProgramData* carla_get_midi_program_data(unsigned int pluginId, uint32_t midiProgramId)
  652. {
  653. carla_debug("carla_get_midi_program_data(%i, %i)", pluginId, midiProgramId);
  654. CARLA_ASSERT(standalone.engine != nullptr);
  655. static CarlaBackend::MidiProgramData data;
  656. if (standalone.engine == nullptr)
  657. return &data;
  658. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  659. {
  660. if (midiProgramId < plugin->midiProgramCount())
  661. return &plugin->midiProgramData(midiProgramId);
  662. carla_stderr2("carla_get_midi_program_data(%i, %i) - midiProgramId out of bounds", pluginId, midiProgramId);
  663. return &data;
  664. }
  665. carla_stderr2("carla_get_midi_program_data(%i, %i) - could not find plugin", pluginId, midiProgramId);
  666. return &data;
  667. }
  668. const CarlaBackend::CustomData* carla_get_custom_data(unsigned int pluginId, uint32_t customDataId)
  669. {
  670. carla_debug("carla_get_custom_data(%i, %i)", pluginId, customDataId);
  671. CARLA_ASSERT(standalone.engine != nullptr);
  672. static CarlaBackend::CustomData data;
  673. if (standalone.engine == nullptr)
  674. return &data;
  675. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  676. {
  677. if (customDataId < plugin->customDataCount())
  678. return &plugin->customData(customDataId);
  679. carla_stderr2("carla_get_custom_data(%i, %i) - customDataId out of bounds", pluginId, customDataId);
  680. return &data;
  681. }
  682. carla_stderr2("carla_get_custom_data(%i, %i) - could not find plugin", pluginId, customDataId);
  683. return &data;
  684. }
  685. const char* carla_get_chunk_data(unsigned int pluginId)
  686. {
  687. carla_debug("carla_get_chunk_data(%i)", pluginId);
  688. CARLA_ASSERT(standalone.engine != nullptr);
  689. if (standalone.engine == nullptr)
  690. return nullptr;
  691. static CarlaString chunkData;
  692. // cleanup
  693. chunkData.clear();
  694. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  695. {
  696. if (plugin->hints() & CarlaBackend::PLUGIN_USES_CHUNKS)
  697. {
  698. void* data = nullptr;
  699. const int32_t dataSize = plugin->chunkData(&data);
  700. if (data != nullptr && dataSize >= 4)
  701. {
  702. chunkData.importBinaryAsBase64((const uint8_t*)data, static_cast<size_t>(dataSize));
  703. return (const char*)chunkData;
  704. }
  705. else
  706. carla_stderr2("carla_get_chunk_data(%i) - got invalid chunk data", pluginId);
  707. }
  708. else
  709. carla_stderr2("carla_get_chunk_data(%i) - plugin does not support chunks", pluginId);
  710. return nullptr;
  711. }
  712. carla_stderr2("carla_get_chunk_data(%i) - could not find plugin", pluginId);
  713. return nullptr;
  714. }
  715. // -------------------------------------------------------------------------------------------------------------------
  716. uint32_t carla_get_parameter_count(unsigned int pluginId)
  717. {
  718. carla_debug("carla_get_parameter_count(%i)", pluginId);
  719. CARLA_ASSERT(standalone.engine != nullptr);
  720. if (standalone.engine == nullptr)
  721. return 0;
  722. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  723. return plugin->parameterCount();
  724. carla_stderr2("carla_get_parameter_count(%i) - could not find plugin", pluginId);
  725. return 0;
  726. }
  727. uint32_t carla_get_program_count(unsigned int pluginId)
  728. {
  729. carla_debug("carla_get_program_count(%i)", pluginId);
  730. CARLA_ASSERT(standalone.engine != nullptr);
  731. if (standalone.engine == nullptr)
  732. return 0;
  733. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  734. return plugin->programCount();
  735. carla_stderr2("carla_get_program_count(%i) - could not find plugin", pluginId);
  736. return 0;
  737. }
  738. uint32_t carla_get_midi_program_count(unsigned int pluginId)
  739. {
  740. carla_debug("carla_get_midi_program_count(%i)", pluginId);
  741. CARLA_ASSERT(standalone.engine != nullptr);
  742. if (standalone.engine == nullptr)
  743. return 0;
  744. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  745. return plugin->midiProgramCount();
  746. carla_stderr2("carla_get_midi_program_count(%i) - could not find plugin", pluginId);
  747. return 0;
  748. }
  749. uint32_t carla_get_custom_data_count(unsigned int pluginId)
  750. {
  751. carla_debug("carla_get_custom_data_count(%i)", pluginId);
  752. CARLA_ASSERT(standalone.engine != nullptr);
  753. if (standalone.engine == nullptr)
  754. return 0;
  755. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  756. return plugin->customDataCount();
  757. carla_stderr2("carla_get_custom_data_count(%i) - could not find plugin", pluginId);
  758. return 0;
  759. }
  760. // -------------------------------------------------------------------------------------------------------------------
  761. const char* carla_get_parameter_text(unsigned int pluginId, uint32_t parameterId)
  762. {
  763. carla_debug("carla_get_parameter_text(%i, %i)", pluginId, parameterId);
  764. CARLA_ASSERT(standalone.engine != nullptr);
  765. if (standalone.engine == nullptr)
  766. return nullptr;
  767. static char textBuf[STR_MAX];
  768. carla_zeroMem(textBuf, sizeof(char)*STR_MAX);
  769. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  770. {
  771. if (parameterId < plugin->parameterCount())
  772. {
  773. plugin->getParameterText(parameterId, textBuf);
  774. return textBuf;
  775. }
  776. carla_stderr2("carla_get_parameter_text(%i, %i) - parameterId out of bounds", pluginId, parameterId);
  777. return nullptr;
  778. }
  779. carla_stderr2("carla_get_parameter_text(%i, %i) - could not find plugin", pluginId, parameterId);
  780. return nullptr;
  781. }
  782. const char* carla_get_program_name(unsigned int pluginId, uint32_t programId)
  783. {
  784. carla_debug("carla_get_program_name(%i, %i)", pluginId, programId);
  785. CARLA_ASSERT(standalone.engine != nullptr);
  786. if (standalone.engine == nullptr)
  787. return nullptr;
  788. static char programName[STR_MAX];
  789. carla_zeroMem(programName, sizeof(char)*STR_MAX);
  790. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  791. {
  792. if (programId < plugin->programCount())
  793. {
  794. plugin->getProgramName(programId, programName);
  795. return programName;
  796. }
  797. carla_stderr2("carla_get_program_name(%i, %i) - programId out of bounds", pluginId, programId);
  798. return nullptr;
  799. }
  800. carla_stderr2("carla_get_program_name(%i, %i) - could not find plugin", pluginId, programId);
  801. return nullptr;
  802. }
  803. const char* carla_get_midi_program_name(unsigned int pluginId, uint32_t midiProgramId)
  804. {
  805. carla_debug("carla_get_midi_program_name(%i, %i)", pluginId, midiProgramId);
  806. CARLA_ASSERT(standalone.engine != nullptr);
  807. if (standalone.engine == nullptr)
  808. return nullptr;
  809. static char midiProgramName[STR_MAX];
  810. carla_zeroMem(midiProgramName, sizeof(char)*STR_MAX);
  811. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  812. {
  813. if (midiProgramId < plugin->midiProgramCount())
  814. {
  815. plugin->getMidiProgramName(midiProgramId, midiProgramName);
  816. return midiProgramName;
  817. }
  818. carla_stderr2("carla_get_midi_program_name(%i, %i) - midiProgramId out of bounds", pluginId, midiProgramId);
  819. return nullptr;
  820. }
  821. carla_stderr2("carla_get_midi_program_name(%i, %i) - could not find plugin", pluginId, midiProgramId);
  822. return nullptr;
  823. }
  824. const char* carla_get_real_plugin_name(unsigned int pluginId)
  825. {
  826. carla_debug("carla_get_real_plugin_name(%i)", pluginId);
  827. CARLA_ASSERT(standalone.engine != nullptr);
  828. if (standalone.engine == nullptr)
  829. return nullptr;
  830. static char realPluginName[STR_MAX];
  831. carla_zeroMem(realPluginName, sizeof(char)*STR_MAX);
  832. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  833. {
  834. plugin->getRealName(realPluginName);
  835. return realPluginName;
  836. }
  837. carla_stderr2("carla_get_real_plugin_name(%i) - could not find plugin", pluginId);
  838. return nullptr;
  839. }
  840. // -------------------------------------------------------------------------------------------------------------------
  841. int32_t carla_get_current_program_index(unsigned int pluginId)
  842. {
  843. carla_debug("carla_get_current_program_index(%i)", pluginId);
  844. CARLA_ASSERT(standalone.engine != nullptr);
  845. if (standalone.engine == nullptr)
  846. return -1;
  847. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  848. return plugin->currentProgram();
  849. carla_stderr2("carla_get_current_program_index(%i) - could not find plugin", pluginId);
  850. return -1;
  851. }
  852. int32_t carla_get_current_midi_program_index(unsigned int pluginId)
  853. {
  854. carla_debug("carla_get_current_midi_program_index(%i)", pluginId);
  855. CARLA_ASSERT(standalone.engine != nullptr);
  856. if (standalone.engine == nullptr)
  857. return -1;
  858. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  859. return plugin->currentMidiProgram();
  860. carla_stderr2("carla_get_current_midi_program_index(%i) - could not find plugin", pluginId);
  861. return -1;
  862. }
  863. // -------------------------------------------------------------------------------------------------------------------
  864. float carla_get_default_parameter_value(unsigned int pluginId, uint32_t parameterId)
  865. {
  866. carla_debug("carla_get_default_parameter_value(%i, %i)", pluginId, parameterId);
  867. CARLA_ASSERT(standalone.engine != nullptr);
  868. if (standalone.engine == nullptr)
  869. return 0.0f;
  870. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  871. {
  872. if (parameterId < plugin->parameterCount())
  873. return plugin->parameterRanges(parameterId).def;
  874. carla_stderr2("carla_get_default_parameter_value(%i, %i) - parameterId out of bounds", pluginId, parameterId);
  875. return 0.0f;
  876. }
  877. carla_stderr2("carla_get_default_parameter_value(%i, %i) - could not find plugin", pluginId, parameterId);
  878. return 0.0f;
  879. }
  880. float carla_get_current_parameter_value(unsigned int pluginId, uint32_t parameterId)
  881. {
  882. carla_debug("carla_get_current_parameter_value(%i, %i)", pluginId, parameterId);
  883. CARLA_ASSERT(standalone.engine != nullptr);
  884. if (standalone.engine == nullptr)
  885. return 0.0f;
  886. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  887. {
  888. if (parameterId < plugin->parameterCount())
  889. return plugin->getParameterValue(parameterId);
  890. carla_stderr2("carla_get_current_parameter_value(%i, %i) - parameterId out of bounds", pluginId, parameterId);
  891. return 0.0f;
  892. }
  893. carla_stderr2("carla_get_current_parameter_value(%i, %i) - could not find plugin", pluginId, parameterId);
  894. return 0.0f;
  895. }
  896. // -------------------------------------------------------------------------------------------------------------------
  897. float carla_get_input_peak_value(unsigned int pluginId, unsigned short portId)
  898. {
  899. CARLA_ASSERT(standalone.engine != nullptr);
  900. CARLA_ASSERT(portId == 1 || portId == 2);
  901. if (standalone.engine == nullptr)
  902. return 0.0f;
  903. if (pluginId >= standalone.engine->currentPluginCount())
  904. {
  905. carla_stderr2("carla_get_input_peak_value(%i, %i) - invalid plugin value", pluginId, portId);
  906. return 0.0f;
  907. }
  908. if (portId == 1 || portId == 2)
  909. return standalone.engine->getInputPeak(pluginId, portId);
  910. carla_stderr2("carla_get_input_peak_value(%i, %i) - invalid port value", pluginId, portId);
  911. return 0.0f;
  912. }
  913. float carla_get_output_peak_value(unsigned int pluginId, unsigned short portId)
  914. {
  915. CARLA_ASSERT(standalone.engine != nullptr);
  916. CARLA_ASSERT(portId == 1 || portId == 2);
  917. if (standalone.engine == nullptr)
  918. return 0.0f;
  919. if (pluginId >= standalone.engine->currentPluginCount())
  920. {
  921. carla_stderr2("carla_get_input_peak_value(%i, %i) - invalid plugin value", pluginId, portId);
  922. return 0.0f;
  923. }
  924. if (portId == 1 || portId == 2)
  925. return standalone.engine->getOutputPeak(pluginId, portId);
  926. carla_stderr2("carla_get_output_peak_value(%i, %i) - invalid port value", pluginId, portId);
  927. return 0.0f;
  928. }
  929. // -------------------------------------------------------------------------------------------------------------------
  930. void carla_set_option(unsigned int pluginId, unsigned int option, bool yesNo)
  931. {
  932. carla_debug("carla_set_option(%i, %i, %s)", pluginId, option, bool2str(yesNo));
  933. CARLA_ASSERT(standalone.engine != nullptr);
  934. if (standalone.engine == nullptr)
  935. return;
  936. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  937. return plugin->setOption(option, yesNo);
  938. carla_stderr2("carla_set_option(%i, %i, %s) - could not find plugin", pluginId, option, bool2str(yesNo));
  939. }
  940. void carla_set_active(unsigned int pluginId, bool onOff)
  941. {
  942. carla_debug("carla_set_active(%i, %s)", pluginId, bool2str(onOff));
  943. CARLA_ASSERT(standalone.engine != nullptr);
  944. if (standalone.engine == nullptr)
  945. return;
  946. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  947. return plugin->setActive(onOff, true, false);
  948. carla_stderr2("carla_set_active(%i, %s) - could not find plugin", pluginId, bool2str(onOff));
  949. }
  950. void carla_set_drywet(unsigned int pluginId, float value)
  951. {
  952. carla_debug("carla_set_drywet(%i, %f)", pluginId, value);
  953. CARLA_ASSERT(standalone.engine != nullptr);
  954. if (standalone.engine == nullptr)
  955. return;
  956. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  957. return plugin->setDryWet(value, true, false);
  958. carla_stderr2("carla_set_drywet(%i, %f) - could not find plugin", pluginId, value);
  959. }
  960. void carla_set_volume(unsigned int pluginId, float value)
  961. {
  962. carla_debug("carla_set_volume(%i, %f)", pluginId, value);
  963. CARLA_ASSERT(standalone.engine != nullptr);
  964. if (standalone.engine == nullptr)
  965. return;
  966. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  967. return plugin->setVolume(value, true, false);
  968. carla_stderr2("carla_set_volume(%i, %f) - could not find plugin", pluginId, value);
  969. }
  970. void carla_set_balance_left(unsigned int pluginId, float value)
  971. {
  972. carla_debug("carla_set_balance_left(%i, %f)", pluginId, value);
  973. CARLA_ASSERT(standalone.engine != nullptr);
  974. if (standalone.engine == nullptr)
  975. return;
  976. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  977. return plugin->setBalanceLeft(value, true, false);
  978. carla_stderr2("carla_set_balance_left(%i, %f) - could not find plugin", pluginId, value);
  979. }
  980. void carla_set_balance_right(unsigned int pluginId, float value)
  981. {
  982. carla_debug("carla_set_balance_right(%i, %f)", pluginId, value);
  983. CARLA_ASSERT(standalone.engine != nullptr);
  984. if (standalone.engine == nullptr)
  985. return;
  986. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  987. return plugin->setBalanceRight(value, true, false);
  988. carla_stderr2("carla_set_balance_right(%i, %f) - could not find plugin", pluginId, value);
  989. }
  990. void carla_set_panning(unsigned int pluginId, float value)
  991. {
  992. carla_debug("carla_set_panning(%i, %f)", pluginId, value);
  993. CARLA_ASSERT(standalone.engine != nullptr);
  994. if (standalone.engine == nullptr)
  995. return;
  996. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  997. return plugin->setPanning(value, true, false);
  998. carla_stderr2("carla_set_panning(%i, %f) - could not find plugin", pluginId, value);
  999. }
  1000. void carla_set_ctrl_channel(unsigned int pluginId, int8_t channel)
  1001. {
  1002. carla_debug("carla_set_ctrl_channel(%i, %i)", pluginId, channel);
  1003. CARLA_ASSERT(standalone.engine != nullptr);
  1004. if (standalone.engine == nullptr)
  1005. return;
  1006. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  1007. return plugin->setCtrlChannel(channel, true, false);
  1008. carla_stderr2("carla_set_ctrl_channel(%i, %i) - could not find plugin", pluginId, channel);
  1009. }
  1010. // -------------------------------------------------------------------------------------------------------------------
  1011. void carla_set_parameter_value(unsigned int pluginId, uint32_t parameterId, float value)
  1012. {
  1013. carla_debug("carla_set_parameter_value(%i, %i, %f)", pluginId, parameterId, value);
  1014. CARLA_ASSERT(standalone.engine != nullptr);
  1015. if (standalone.engine == nullptr)
  1016. return;
  1017. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  1018. {
  1019. if (parameterId < plugin->parameterCount())
  1020. return plugin->setParameterValue(parameterId, value, true, true, false);
  1021. carla_stderr2("carla_set_parameter_value(%i, %i, %f) - parameterId out of bounds", pluginId, parameterId, value);
  1022. return;
  1023. }
  1024. carla_stderr2("carla_set_parameter_value(%i, %i, %f) - could not find plugin", pluginId, parameterId, value);
  1025. }
  1026. void carla_set_parameter_midi_channel(unsigned int pluginId, uint32_t parameterId, uint8_t channel)
  1027. {
  1028. carla_debug("carla_set_parameter_midi_channel(%i, %i, %i)", pluginId, parameterId, channel);
  1029. CARLA_ASSERT(standalone.engine != nullptr);
  1030. CARLA_ASSERT(channel < MAX_MIDI_CHANNELS);
  1031. if (channel >= MAX_MIDI_CHANNELS)
  1032. {
  1033. carla_stderr2("carla_set_parameter_midi_channel(%i, %i, %i) - invalid channel number", pluginId, parameterId, channel);
  1034. return;
  1035. }
  1036. if (standalone.engine == nullptr)
  1037. return;
  1038. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  1039. {
  1040. if (parameterId < plugin->parameterCount())
  1041. return plugin->setParameterMidiChannel(parameterId, channel, true, false);
  1042. carla_stderr2("carla_set_parameter_midi_channel(%i, %i, %i) - parameterId out of bounds", pluginId, parameterId, channel);
  1043. return;
  1044. }
  1045. carla_stderr2("carla_set_parameter_midi_channel(%i, %i, %i) - could not find plugin", pluginId, parameterId, channel);
  1046. }
  1047. void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameterId, int16_t cc)
  1048. {
  1049. carla_debug("carla_set_parameter_midi_cc(%i, %i, %i)", pluginId, parameterId, cc);
  1050. CARLA_ASSERT(standalone.engine != nullptr);
  1051. CARLA_ASSERT(cc >= -1 && cc <= 0x5F);
  1052. if (cc < -1)
  1053. {
  1054. cc = -1;
  1055. }
  1056. else if (cc > 0x5F) // 95
  1057. {
  1058. carla_stderr2("carla_set_parameter_midi_cc(%i, %i, %i) - invalid cc number", pluginId, parameterId, cc);
  1059. return;
  1060. }
  1061. if (standalone.engine == nullptr)
  1062. return;
  1063. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  1064. {
  1065. if (parameterId < plugin->parameterCount())
  1066. return plugin->setParameterMidiCC(parameterId, cc, true, false);
  1067. carla_stderr2("carla_set_parameter_midi_cc(%i, %i, %i) - parameterId out of bounds", pluginId, parameterId, cc);
  1068. return;
  1069. }
  1070. carla_stderr2("carla_set_parameter_midi_cc(%i, %i, %i) - could not find plugin", pluginId, parameterId, cc);
  1071. }
  1072. void carla_set_program(unsigned int pluginId, uint32_t programId)
  1073. {
  1074. carla_debug("carla_set_program(%i, %i)", pluginId, programId);
  1075. CARLA_ASSERT(standalone.engine != nullptr);
  1076. if (standalone.engine == nullptr)
  1077. return;
  1078. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  1079. {
  1080. if (programId < plugin->programCount())
  1081. return plugin->setProgram(static_cast<int32_t>(programId), true, true, false, true);
  1082. carla_stderr2("carla_set_program(%i, %i) - programId out of bounds", pluginId, programId);
  1083. return;
  1084. }
  1085. carla_stderr2("carla_set_program(%i, %i) - could not find plugin", pluginId, programId);
  1086. }
  1087. void carla_set_midi_program(unsigned int pluginId, uint32_t midiProgramId)
  1088. {
  1089. carla_debug("carla_set_midi_program(%i, %i)", pluginId, midiProgramId);
  1090. CARLA_ASSERT(standalone.engine != nullptr);
  1091. if (standalone.engine == nullptr)
  1092. return;
  1093. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  1094. {
  1095. if (midiProgramId < plugin->midiProgramCount())
  1096. return plugin->setMidiProgram(static_cast<int32_t>(midiProgramId), true, true, false, true);
  1097. carla_stderr2("carla_set_midi_program(%i, %i) - midiProgramId out of bounds", pluginId, midiProgramId);
  1098. return;
  1099. }
  1100. carla_stderr2("carla_set_midi_program(%i, %i) - could not find plugin", pluginId, midiProgramId);
  1101. }
  1102. // -------------------------------------------------------------------------------------------------------------------
  1103. void carla_set_custom_data(unsigned int pluginId, const char* type, const char* key, const char* value)
  1104. {
  1105. carla_debug("carla_set_custom_data(%i, \"%s\", \"%s\", \"%s\")", pluginId, type, key, value);
  1106. CARLA_ASSERT(standalone.engine != nullptr);
  1107. if (standalone.engine == nullptr)
  1108. return;
  1109. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  1110. return plugin->setCustomData(type, key, value, true);
  1111. carla_stderr2("carla_set_custom_data(%i, \"%s\", \"%s\", \"%s\") - could not find plugin", pluginId, type, key, value);
  1112. }
  1113. void carla_set_chunk_data(unsigned int pluginId, const char* chunkData)
  1114. {
  1115. carla_debug("carla_set_chunk_data(%i, \"%s\")", pluginId, chunkData);
  1116. CARLA_ASSERT(standalone.engine != nullptr);
  1117. if (standalone.engine == nullptr)
  1118. return;
  1119. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  1120. {
  1121. if (plugin->hints() & CarlaBackend::PLUGIN_USES_CHUNKS)
  1122. return plugin->setChunkData(chunkData);
  1123. carla_stderr2("carla_set_chunk_data(%i, \"%s\") - plugin does not support chunks", pluginId, chunkData);
  1124. return;
  1125. }
  1126. carla_stderr2("carla_set_chunk_data(%i, \"%s\") - could not find plugin", pluginId, chunkData);
  1127. }
  1128. // -------------------------------------------------------------------------------------------------------------------
  1129. void carla_prepare_for_save(unsigned int pluginId)
  1130. {
  1131. carla_debug("carla_prepare_for_save(%i)", pluginId);
  1132. CARLA_ASSERT(standalone.engine != nullptr);
  1133. if (standalone.engine == nullptr)
  1134. return;
  1135. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  1136. return plugin->prepareForSave();
  1137. carla_stderr2("carla_prepare_for_save(%i) - could not find plugin", pluginId);
  1138. }
  1139. void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, uint8_t velocity)
  1140. {
  1141. carla_debug("carla_send_midi_note(%i, %i, %i, %i)", pluginId, channel, note, velocity);
  1142. CARLA_ASSERT(standalone.engine != nullptr);
  1143. if (standalone.engine == nullptr || ! standalone.engine->isRunning())
  1144. return;
  1145. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  1146. return plugin->sendMidiSingleNote(channel, note, velocity, true, true, false);
  1147. carla_stderr2("carla_send_midi_note(%i, %i, %i, %i) - could not find plugin", pluginId, channel, note, velocity);
  1148. }
  1149. void carla_show_gui(unsigned int pluginId, bool yesno)
  1150. {
  1151. carla_debug("carla_show_gui(%i, %s)", pluginId, bool2str(yesno));
  1152. CARLA_ASSERT(standalone.engine != nullptr);
  1153. if (standalone.engine == nullptr)
  1154. return;
  1155. if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId))
  1156. return plugin->showGui(yesno);
  1157. carla_stderr2("carla_show_gui(%i, %s) - could not find plugin", pluginId, bool2str(yesno));
  1158. }
  1159. // -------------------------------------------------------------------------------------------------------------------
  1160. uint32_t carla_get_buffer_size()
  1161. {
  1162. carla_debug("carla_get_buffer_size()");
  1163. CARLA_ASSERT(standalone.engine != nullptr);
  1164. if (standalone.engine == nullptr)
  1165. return 0;
  1166. return standalone.engine->getBufferSize();
  1167. }
  1168. double carla_get_sample_rate()
  1169. {
  1170. carla_debug("carla_get_sample_rate()");
  1171. CARLA_ASSERT(standalone.engine != nullptr);
  1172. if (standalone.engine == nullptr)
  1173. return 0.0;
  1174. return standalone.engine->getSampleRate();
  1175. }
  1176. // -------------------------------------------------------------------------------------------------------------------
  1177. const char* carla_get_last_error()
  1178. {
  1179. carla_debug("carla_get_last_error()");
  1180. if (standalone.engine != nullptr)
  1181. return standalone.engine->getLastError();
  1182. return standalone.lastError;
  1183. }
  1184. const char* carla_get_host_osc_url()
  1185. {
  1186. carla_debug("carla_get_host_osc_url()");
  1187. CARLA_ASSERT(standalone.engine != nullptr);
  1188. if (standalone.engine == nullptr)
  1189. return nullptr;
  1190. return standalone.engine->getOscServerPathTCP();
  1191. }
  1192. #if 0
  1193. // -------------------------------------------------------------------------------------------------------------------
  1194. #define NSM_API_VERSION_MAJOR 1
  1195. #define NSM_API_VERSION_MINOR 0
  1196. class CarlaNSM
  1197. {
  1198. public:
  1199. CarlaNSM()
  1200. {
  1201. m_controlAddr = nullptr;
  1202. m_serverThread = nullptr;
  1203. m_isOpened = false;
  1204. m_isSaved = false;
  1205. }
  1206. ~CarlaNSM()
  1207. {
  1208. if (m_controlAddr)
  1209. lo_address_free(m_controlAddr);
  1210. if (m_serverThread)
  1211. {
  1212. lo_server_thread_stop(m_serverThread);
  1213. lo_server_thread_del_method(m_serverThread, "/reply", "ssss");
  1214. lo_server_thread_del_method(m_serverThread, "/nsm/client/open", "sss");
  1215. lo_server_thread_del_method(m_serverThread, "/nsm/client/save", "");
  1216. lo_server_thread_free(m_serverThread);
  1217. }
  1218. }
  1219. void announce(const char* const url, const int pid)
  1220. {
  1221. lo_address addr = lo_address_new_from_url(url);
  1222. int proto = lo_address_get_protocol(addr);
  1223. if (! m_serverThread)
  1224. {
  1225. // create new OSC thread
  1226. m_serverThread = lo_server_thread_new_with_proto(nullptr, proto, error_handler);
  1227. // register message handlers and start OSC thread
  1228. lo_server_thread_add_method(m_serverThread, "/reply", "ssss", _reply_handler, this);
  1229. lo_server_thread_add_method(m_serverThread, "/nsm/client/open", "sss", _nsm_open_handler, this);
  1230. lo_server_thread_add_method(m_serverThread, "/nsm/client/save", "", _nsm_save_handler, this);
  1231. lo_server_thread_start(m_serverThread);
  1232. }
  1233. lo_send_from(addr, lo_server_thread_get_server(m_serverThread), LO_TT_IMMEDIATE, "/nsm/server/announce", "sssiii",
  1234. "Carla", ":switch:", "carla", NSM_API_VERSION_MAJOR, NSM_API_VERSION_MINOR, pid);
  1235. lo_address_free(addr);
  1236. }
  1237. void replyOpen()
  1238. {
  1239. m_isOpened = true;
  1240. }
  1241. void replySave()
  1242. {
  1243. m_isSaved = true;
  1244. }
  1245. protected:
  1246. int reply_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg)
  1247. {
  1248. carla_debug("CarlaNSM::reply_handler(%s, %i, %p, %s, %p)", path, argc, argv, types, msg);
  1249. m_controlAddr = lo_address_new_from_url(lo_address_get_url(lo_message_get_source(msg)));
  1250. const char* const method = &argv[0]->s;
  1251. if (strcmp(method, "/nsm/server/announce") == 0 && standalone.callback)
  1252. standalone.callback(nullptr, CarlaBackend::CALLBACK_NSM_ANNOUNCE, 0, 0, 0, 0.0, nullptr); // FIXME?
  1253. return 0;
  1254. }
  1255. int nsm_open_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg)
  1256. {
  1257. carla_debug("CarlaNSM::nsm_open_handler(\"%s\", \"%s\", %p, %i, %p)", path, types, argv, argc, msg);
  1258. if (! standalone.callback)
  1259. return 1;
  1260. const char* const projectPath = &argv[0]->s;
  1261. const char* const clientId = &argv[2]->s;
  1262. standalone.callback(nullptr, CarlaBackend::CALLBACK_NSM_OPEN1, 0, 0, 0, 0.0, clientId);
  1263. standalone.callback(nullptr, CarlaBackend::CALLBACK_NSM_OPEN2, 0, 0, 0, 0.0, projectPath);
  1264. for (int i=0; i < 30 && ! m_isOpened; i++)
  1265. carla_msleep(100);
  1266. if (m_controlAddr)
  1267. lo_send_from(m_controlAddr, lo_server_thread_get_server(m_serverThread), LO_TT_IMMEDIATE, "/reply", "ss", "/nsm/client/open", "OK");
  1268. return 0;
  1269. }
  1270. int nsm_save_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg)
  1271. {
  1272. carla_debug("CarlaNSM::nsm_save_handler(\"%s\", \"%s\", %p, %i, %p)", path, types, argv, argc, msg);
  1273. if (! standalone.callback)
  1274. return 1;
  1275. standalone.callback(nullptr, CarlaBackend::CALLBACK_NSM_SAVE, 0, 0, 0, 0.0, nullptr);
  1276. for (int i=0; i < 30 && ! m_isSaved; i++)
  1277. carla_msleep(100);
  1278. if (m_controlAddr)
  1279. lo_send_from(m_controlAddr, lo_server_thread_get_server(m_serverThread), LO_TT_IMMEDIATE, "/reply", "ss", "/nsm/client/save", "OK");
  1280. return 0;
  1281. }
  1282. private:
  1283. lo_address m_controlAddr;
  1284. lo_server_thread m_serverThread;
  1285. bool m_isOpened, m_isSaved;
  1286. static int _reply_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg, void* const data)
  1287. {
  1288. CARLA_ASSERT(data);
  1289. CarlaNSM* const _this_ = (CarlaNSM*)data;
  1290. return _this_->reply_handler(path, types, argv, argc, msg);
  1291. }
  1292. static int _nsm_open_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg, void* const data)
  1293. {
  1294. CARLA_ASSERT(data);
  1295. CarlaNSM* const _this_ = (CarlaNSM*)data;
  1296. return _this_->nsm_open_handler(path, types, argv, argc, msg);
  1297. }
  1298. static int _nsm_save_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg, void* const data)
  1299. {
  1300. CARLA_ASSERT(data);
  1301. CarlaNSM* const _this_ = (CarlaNSM*)data;
  1302. return _this_->nsm_save_handler(path, types, argv, argc, msg);
  1303. }
  1304. static void error_handler(const int num, const char* const msg, const char* const path)
  1305. {
  1306. carla_stderr2("CarlaNSM::error_handler(%i, \"%s\", \"%s\")", num, msg, path);
  1307. }
  1308. };
  1309. static CarlaNSM carlaNSM;
  1310. void carla_nsm_announce(const char* url, int pid)
  1311. {
  1312. carlaNSM.announce(url, pid);
  1313. }
  1314. void carla_nsm_reply_open()
  1315. {
  1316. carlaNSM.replyOpen();
  1317. }
  1318. void carla_nsm_reply_save()
  1319. {
  1320. carlaNSM.replySave();
  1321. }
  1322. #endif
  1323. // -------------------------------------------------------------------------------------------------------------------
  1324. #if 0
  1325. //def QTCREATOR_TEST
  1326. #include <QtGui/QApplication>
  1327. #include <QtGui/QDialog>
  1328. QDialog* vstGui = nullptr;
  1329. void main_callback(void* ptr, CarlaBackend::CallbackType action, unsigned int pluginId, int value1, int value2, double value3)
  1330. {
  1331. switch (action)
  1332. {
  1333. case CarlaBackend::CALLBACK_SHOW_GUI:
  1334. if (vstGui && ! value1)
  1335. vstGui->close();
  1336. break;
  1337. case CarlaBackend::CALLBACK_RESIZE_GUI:
  1338. vstGui->setFixedSize(value1, value2);
  1339. break;
  1340. default:
  1341. break;
  1342. }
  1343. Q_UNUSED(ptr);
  1344. Q_UNUSED(pluginId);
  1345. Q_UNUSED(value3);
  1346. }
  1347. void run_tests_standalone(short idMax)
  1348. {
  1349. for (short id = 0; id <= idMax; id++)
  1350. {
  1351. carla_debug("------------------- TEST @%i: non-parameter calls --------------------", id);
  1352. get_plugin_info(id);
  1353. get_audio_port_count_info(id);
  1354. get_midi_port_count_info(id);
  1355. get_parameter_count_info(id);
  1356. get_gui_info(id);
  1357. get_chunk_data(id);
  1358. get_parameter_count(id);
  1359. get_program_count(id);
  1360. get_midi_program_count(id);
  1361. get_custom_data_count(id);
  1362. get_real_plugin_name(id);
  1363. get_current_program_index(id);
  1364. get_current_midi_program_index(id);
  1365. carla_debug("------------------- TEST @%i: parameter calls [-1] --------------------", id);
  1366. get_parameter_info(id, -1);
  1367. get_parameter_scalepoint_info(id, -1, -1);
  1368. get_parameter_data(id, -1);
  1369. get_parameter_ranges(id, -1);
  1370. get_midi_program_data(id, -1);
  1371. get_custom_data(id, -1);
  1372. get_parameter_text(id, -1);
  1373. get_program_name(id, -1);
  1374. get_midi_program_name(id, -1);
  1375. get_default_parameter_value(id, -1);
  1376. get_current_parameter_value(id, -1);
  1377. get_input_peak_value(id, -1);
  1378. get_output_peak_value(id, -1);
  1379. carla_debug("------------------- TEST @%i: parameter calls [0] --------------------", id);
  1380. get_parameter_info(id, 0);
  1381. get_parameter_scalepoint_info(id, 0, -1);
  1382. get_parameter_scalepoint_info(id, 0, 0);
  1383. get_parameter_data(id, 0);
  1384. get_parameter_ranges(id, 0);
  1385. get_midi_program_data(id, 0);
  1386. get_custom_data(id, 0);
  1387. get_parameter_text(id, 0);
  1388. get_program_name(id, 0);
  1389. get_midi_program_name(id, 0);
  1390. get_default_parameter_value(id, 0);
  1391. get_current_parameter_value(id, 0);
  1392. get_input_peak_value(id, 0);
  1393. get_input_peak_value(id, 1);
  1394. get_input_peak_value(id, 2);
  1395. get_output_peak_value(id, 0);
  1396. get_output_peak_value(id, 1);
  1397. get_output_peak_value(id, 2);
  1398. carla_debug("------------------- TEST @%i: set extra data --------------------", id);
  1399. set_custom_data(id, CarlaBackend::CUSTOM_DATA_STRING, "", "");
  1400. set_chunk_data(id, nullptr);
  1401. set_gui_container(id, (uintptr_t)1);
  1402. carla_debug("------------------- TEST @%i: gui stuff --------------------", id);
  1403. show_gui(id, false);
  1404. show_gui(id, true);
  1405. show_gui(id, true);
  1406. idle_guis();
  1407. idle_guis();
  1408. idle_guis();
  1409. carla_debug("------------------- TEST @%i: other --------------------", id);
  1410. send_midi_note(id, 15, 127, 127);
  1411. send_midi_note(id, 0, 0, 0);
  1412. prepare_for_save(id);
  1413. prepare_for_save(id);
  1414. prepare_for_save(id);
  1415. }
  1416. }
  1417. int main(int argc, char* argv[])
  1418. {
  1419. using namespace CarlaBackend;
  1420. // Qt app
  1421. QApplication app(argc, argv);
  1422. // Qt gui (for vst)
  1423. vstGui = new QDialog(nullptr);
  1424. // set callback and options
  1425. set_callback_function(main_callback);
  1426. set_option(OPTION_PREFER_UI_BRIDGES, 0, nullptr);
  1427. //set_option(OPTION_PROCESS_MODE, PROCESS_MODE_CONTINUOUS_RACK, nullptr);
  1428. // start engine
  1429. if (! engine_init("JACK", "carla_demo"))
  1430. {
  1431. carla_stderr2("failed to start backend engine, reason:\n%s", get_last_error());
  1432. delete vstGui;
  1433. return 1;
  1434. }
  1435. short id_ladspa = add_plugin(BINARY_NATIVE, PLUGIN_LADSPA, "/usr/lib/ladspa/LEET_eqbw2x2.so", "LADSPA plug name, test long name - "
  1436. "------- name ------------ name2 ----------- name3 ------------ name4 ------------ name5 ---------- name6", "leet_equalizer_bw2x2", nullptr);
  1437. short id_dssi = add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/fluidsynth-dssi.so", "DSSI pname, short-utf8 _ \xAE", "FluidSynth-DSSI", (void*)"/usr/lib/dssi/fluidsynth-dssi/FluidSynth-DSSI_gtk");
  1438. short id_native = add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, "", "ZynHere", "zynaddsubfx", nullptr);
  1439. //short id_lv2 = add_plugin(BINARY_NATIVE, PLUGIN_LV2, "FILENAME", "HAHA name!!!", "http://studionumbersix.com/foo/lv2/yc20", nullptr);
  1440. //short id_vst = add_plugin(BINARY_NATIVE, PLUGIN_LV2, "FILENAME", "HAHA name!!!", "http://studionumbersix.com/foo/lv2/yc20", nullptr);
  1441. if (id_ladspa < 0 || id_dssi < 0 || id_native < 0)
  1442. {
  1443. carla_stderr2("failed to start load plugins, reason:\n%s", get_last_error());
  1444. delete vstGui;
  1445. return 1;
  1446. }
  1447. //const GuiInfo* const guiInfo = get_gui_info(id);
  1448. //if (guiInfo->type == CarlaBackend::GUI_INTERNAL_QT4 || guiInfo->type == CarlaBackend::GUI_INTERNAL_X11)
  1449. //{
  1450. // set_gui_data(id, 0, (uintptr_t)gui);
  1451. //gui->show();
  1452. //}
  1453. // activate
  1454. set_active(id_ladspa, true);
  1455. set_active(id_dssi, true);
  1456. set_active(id_native, true);
  1457. // start guis
  1458. show_gui(id_dssi, true);
  1459. carla_sleep(1);
  1460. // do tests
  1461. run_tests_standalone(id_dssi+1);
  1462. // lock
  1463. app.exec();
  1464. delete vstGui;
  1465. vstGui = nullptr;
  1466. remove_plugin(id_ladspa);
  1467. remove_plugin(id_dssi);
  1468. remove_plugin(id_native);
  1469. engine_close();
  1470. return 0;
  1471. }
  1472. #endif