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.

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