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.

2071 lines
74KB

  1. /*
  2. * Carla Standalone
  3. * Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. // TODO:
  18. // Check carla_stderr2("Engine is not running"); <= prepend func name and args
  19. #include "CarlaHost.h"
  20. #include "CarlaMIDI.h"
  21. #include "CarlaEngine.hpp"
  22. #include "CarlaPlugin.hpp"
  23. #include "CarlaBackendUtils.hpp"
  24. #include "CarlaBase64Utils.hpp"
  25. #include "ThreadSafeFFTW.hpp"
  26. #ifdef BUILD_BRIDGE
  27. # include "water/files/File.h"
  28. #else
  29. # include "CarlaLogThread.hpp"
  30. #endif
  31. #ifdef USING_JUCE
  32. # if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
  33. # pragma GCC diagnostic push
  34. # pragma GCC diagnostic ignored "-Wconversion"
  35. # pragma GCC diagnostic ignored "-Weffc++"
  36. # pragma GCC diagnostic ignored "-Wsign-conversion"
  37. # pragma GCC diagnostic ignored "-Wundef"
  38. # endif
  39. # include "AppConfig.h"
  40. # include "juce_events/juce_events.h"
  41. # if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
  42. # pragma GCC diagnostic pop
  43. # endif
  44. #endif
  45. #define CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(cond, msg, ret) \
  46. if (! (cond)) { \
  47. carla_stderr2("%s: " msg, __FUNCTION__); \
  48. gStandalone.lastError = msg; \
  49. return ret; \
  50. }
  51. namespace CB = CarlaBackend;
  52. using CB::EngineOptions;
  53. // --------------------------------------------------------------------------------------------------------------------
  54. // Single, standalone engine
  55. struct CarlaBackendStandalone {
  56. CarlaEngine* engine;
  57. EngineCallbackFunc engineCallback;
  58. void* engineCallbackPtr;
  59. #ifndef BUILD_BRIDGE
  60. EngineOptions engineOptions;
  61. CarlaLogThread logThread;
  62. bool logThreadEnabled;
  63. #endif
  64. FileCallbackFunc fileCallback;
  65. void* fileCallbackPtr;
  66. CarlaString lastError;
  67. CarlaBackendStandalone() noexcept
  68. : engine(nullptr),
  69. engineCallback(nullptr),
  70. engineCallbackPtr(nullptr),
  71. #ifndef BUILD_BRIDGE
  72. engineOptions(),
  73. logThread(),
  74. logThreadEnabled(false),
  75. #endif
  76. fileCallback(nullptr),
  77. fileCallbackPtr(nullptr),
  78. lastError() {}
  79. ~CarlaBackendStandalone() noexcept
  80. {
  81. CARLA_SAFE_ASSERT(engine == nullptr);
  82. }
  83. CARLA_PREVENT_HEAP_ALLOCATION
  84. CARLA_DECLARE_NON_COPY_STRUCT(CarlaBackendStandalone)
  85. };
  86. CarlaBackendStandalone gStandalone;
  87. #ifdef CARLA_OS_UNIX
  88. static ThreadSafeFFTW sThreadSafeFFTW;
  89. #endif
  90. // --------------------------------------------------------------------------------------------------------------------
  91. // API
  92. #define CARLA_COMMON_NEED_CHECKSTRINGPTR
  93. #include "CarlaHostCommon.cpp"
  94. #undef CARLA_COMMON_NEED_CHECKSTRINGPTR
  95. // --------------------------------------------------------------------------------------------------------------------
  96. uint carla_get_engine_driver_count()
  97. {
  98. carla_debug("carla_get_engine_driver_count()");
  99. return CarlaEngine::getDriverCount();
  100. }
  101. const char* carla_get_engine_driver_name(uint index)
  102. {
  103. carla_debug("carla_get_engine_driver_name(%i)", index);
  104. return CarlaEngine::getDriverName(index);
  105. }
  106. const char* const* carla_get_engine_driver_device_names(uint index)
  107. {
  108. carla_debug("carla_get_engine_driver_device_names(%i)", index);
  109. return CarlaEngine::getDriverDeviceNames(index);
  110. }
  111. const EngineDriverDeviceInfo* carla_get_engine_driver_device_info(uint index, const char* name)
  112. {
  113. CARLA_SAFE_ASSERT_RETURN(name != nullptr, nullptr);
  114. static EngineDriverDeviceInfo retDevInfo;
  115. static const uint32_t nullBufferSizes[] = { 0 };
  116. static const double nullSampleRates[] = { 0.0 };
  117. carla_debug("carla_get_engine_driver_device_info(%i, \"%s\")", index, name);
  118. if (const EngineDriverDeviceInfo* const devInfo = CarlaEngine::getDriverDeviceInfo(index, name))
  119. {
  120. retDevInfo.hints = devInfo->hints;
  121. retDevInfo.bufferSizes = (devInfo->bufferSizes != nullptr) ? devInfo->bufferSizes : nullBufferSizes;
  122. retDevInfo.sampleRates = (devInfo->sampleRates != nullptr) ? devInfo->sampleRates : nullSampleRates;
  123. }
  124. else
  125. {
  126. retDevInfo.hints = 0x0;
  127. retDevInfo.bufferSizes = nullBufferSizes;
  128. retDevInfo.sampleRates = nullSampleRates;
  129. }
  130. return &retDevInfo;
  131. }
  132. // --------------------------------------------------------------------------------------------------------------------
  133. CarlaEngine* carla_get_engine()
  134. {
  135. carla_debug("carla_get_engine()");
  136. return gStandalone.engine;
  137. }
  138. // --------------------------------------------------------------------------------------------------------------------
  139. static void carla_engine_init_common(CarlaEngine* const engine)
  140. {
  141. engine->setCallback(gStandalone.engineCallback, gStandalone.engineCallbackPtr);
  142. engine->setFileCallback(gStandalone.fileCallback, gStandalone.fileCallbackPtr);
  143. #ifdef BUILD_BRIDGE
  144. using water::File;
  145. File waterBinaryDir(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory());
  146. /*
  147. if (const char* const uisAlwaysOnTop = std::getenv("ENGINE_OPTION_FORCE_STEREO"))
  148. engine->setOption(CB::ENGINE_OPTION_FORCE_STEREO, (std::strcmp(uisAlwaysOnTop, "true") == 0) ? 1 : 0, nullptr);
  149. if (const char* const uisAlwaysOnTop = std::getenv("ENGINE_OPTION_PREFER_PLUGIN_BRIDGES"))
  150. engine->setOption(CB::ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, (std::strcmp(uisAlwaysOnTop, "true") == 0) ? 1 : 0, nullptr);
  151. if (const char* const uisAlwaysOnTop = std::getenv("ENGINE_OPTION_PREFER_UI_BRIDGES"))
  152. engine->setOption(CB::ENGINE_OPTION_PREFER_UI_BRIDGES, (std::strcmp(uisAlwaysOnTop, "true") == 0) ? 1 : 0, nullptr);
  153. */
  154. if (const char* const uisAlwaysOnTop = std::getenv("ENGINE_OPTION_UIS_ALWAYS_ON_TOP"))
  155. engine->setOption(CB::ENGINE_OPTION_UIS_ALWAYS_ON_TOP, (std::strcmp(uisAlwaysOnTop, "true") == 0) ? 1 : 0, nullptr);
  156. if (const char* const maxParameters = std::getenv("ENGINE_OPTION_MAX_PARAMETERS"))
  157. engine->setOption(CB::ENGINE_OPTION_MAX_PARAMETERS, std::atoi(maxParameters), nullptr);
  158. if (const char* const uiBridgesTimeout = std::getenv("ENGINE_OPTION_UI_BRIDGES_TIMEOUT"))
  159. engine->setOption(CB::ENGINE_OPTION_UI_BRIDGES_TIMEOUT, std::atoi(uiBridgesTimeout), nullptr);
  160. if (const char* const pathLADSPA = std::getenv("ENGINE_OPTION_PLUGIN_PATH_LADSPA"))
  161. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_LADSPA, pathLADSPA);
  162. if (const char* const pathDSSI = std::getenv("ENGINE_OPTION_PLUGIN_PATH_DSSI"))
  163. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_DSSI, pathDSSI);
  164. if (const char* const pathLV2 = std::getenv("ENGINE_OPTION_PLUGIN_PATH_LV2"))
  165. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_LV2, pathLV2);
  166. if (const char* const pathVST2 = std::getenv("ENGINE_OPTION_PLUGIN_PATH_VST2"))
  167. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_VST2, pathVST2);
  168. if (const char* const pathVST3 = std::getenv("ENGINE_OPTION_PLUGIN_PATH_VST3"))
  169. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_VST3, pathVST3);
  170. if (const char* const pathSF2 = std::getenv("ENGINE_OPTION_PLUGIN_PATH_SF2"))
  171. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_SF2, pathSF2);
  172. if (const char* const pathSFZ = std::getenv("ENGINE_OPTION_PLUGIN_PATH_SFZ"))
  173. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_SFZ, pathSFZ);
  174. if (const char* const binaryDir = std::getenv("ENGINE_OPTION_PATH_BINARIES"))
  175. engine->setOption(CB::ENGINE_OPTION_PATH_BINARIES, 0, binaryDir);
  176. else
  177. engine->setOption(CB::ENGINE_OPTION_PATH_BINARIES, 0, waterBinaryDir.getFullPathName().toRawUTF8());
  178. if (const char* const resourceDir = std::getenv("ENGINE_OPTION_PATH_RESOURCES"))
  179. engine->setOption(CB::ENGINE_OPTION_PATH_RESOURCES, 0, resourceDir);
  180. else
  181. engine->setOption(CB::ENGINE_OPTION_PATH_RESOURCES, 0, waterBinaryDir.getChildFile("resources").getFullPathName().toRawUTF8());
  182. if (const char* const preventBadBehaviour = std::getenv("ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR"))
  183. engine->setOption(CB::ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR, (std::strcmp(preventBadBehaviour, "true") == 0) ? 1 : 0, nullptr);
  184. if (const char* const frontendWinId = std::getenv("ENGINE_OPTION_FRONTEND_WIN_ID"))
  185. engine->setOption(CB::ENGINE_OPTION_FRONTEND_WIN_ID, 0, frontendWinId);
  186. #else
  187. engine->setOption(CB::ENGINE_OPTION_FORCE_STEREO, gStandalone.engineOptions.forceStereo ? 1 : 0, nullptr);
  188. engine->setOption(CB::ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, gStandalone.engineOptions.preferPluginBridges ? 1 : 0, nullptr);
  189. engine->setOption(CB::ENGINE_OPTION_PREFER_UI_BRIDGES, gStandalone.engineOptions.preferUiBridges ? 1 : 0, nullptr);
  190. engine->setOption(CB::ENGINE_OPTION_UIS_ALWAYS_ON_TOP, gStandalone.engineOptions.uisAlwaysOnTop ? 1 : 0, nullptr);
  191. engine->setOption(CB::ENGINE_OPTION_MAX_PARAMETERS, static_cast<int>(gStandalone.engineOptions.maxParameters), nullptr);
  192. engine->setOption(CB::ENGINE_OPTION_UI_BRIDGES_TIMEOUT, static_cast<int>(gStandalone.engineOptions.uiBridgesTimeout), nullptr);
  193. engine->setOption(CB::ENGINE_OPTION_AUDIO_BUFFER_SIZE, static_cast<int>(gStandalone.engineOptions.audioBufferSize), nullptr);
  194. engine->setOption(CB::ENGINE_OPTION_AUDIO_SAMPLE_RATE, static_cast<int>(gStandalone.engineOptions.audioSampleRate), nullptr);
  195. engine->setOption(CB::ENGINE_OPTION_AUDIO_TRIPLE_BUFFER, gStandalone.engineOptions.audioTripleBuffer ? 1 : 0, nullptr);
  196. if (gStandalone.engineOptions.audioDevice != nullptr)
  197. engine->setOption(CB::ENGINE_OPTION_AUDIO_DEVICE, 0, gStandalone.engineOptions.audioDevice);
  198. engine->setOption(CB::ENGINE_OPTION_OSC_ENABLED, gStandalone.engineOptions.oscEnabled, nullptr);
  199. engine->setOption(CB::ENGINE_OPTION_OSC_PORT_TCP, gStandalone.engineOptions.oscPortTCP, nullptr);
  200. engine->setOption(CB::ENGINE_OPTION_OSC_PORT_UDP, gStandalone.engineOptions.oscPortUDP, nullptr);
  201. if (gStandalone.engineOptions.pathLADSPA != nullptr)
  202. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_LADSPA, gStandalone.engineOptions.pathLADSPA);
  203. if (gStandalone.engineOptions.pathDSSI != nullptr)
  204. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_DSSI, gStandalone.engineOptions.pathDSSI);
  205. if (gStandalone.engineOptions.pathLV2 != nullptr)
  206. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_LV2, gStandalone.engineOptions.pathLV2);
  207. if (gStandalone.engineOptions.pathVST2 != nullptr)
  208. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_VST2, gStandalone.engineOptions.pathVST2);
  209. if (gStandalone.engineOptions.pathVST3 != nullptr)
  210. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_VST3, gStandalone.engineOptions.pathVST3);
  211. if (gStandalone.engineOptions.pathSF2 != nullptr)
  212. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_SF2, gStandalone.engineOptions.pathSF2);
  213. if (gStandalone.engineOptions.pathSFZ != nullptr)
  214. engine->setOption(CB::ENGINE_OPTION_PLUGIN_PATH, CB::PLUGIN_SFZ, gStandalone.engineOptions.pathSFZ);
  215. if (gStandalone.engineOptions.binaryDir != nullptr && gStandalone.engineOptions.binaryDir[0] != '\0')
  216. engine->setOption(CB::ENGINE_OPTION_PATH_BINARIES, 0, gStandalone.engineOptions.binaryDir);
  217. if (gStandalone.engineOptions.resourceDir != nullptr && gStandalone.engineOptions.resourceDir[0] != '\0')
  218. engine->setOption(CB::ENGINE_OPTION_PATH_RESOURCES, 0, gStandalone.engineOptions.resourceDir);
  219. engine->setOption(CB::ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR, gStandalone.engineOptions.preventBadBehaviour ? 1 : 0, nullptr);
  220. engine->setOption(CB::ENGINE_OPTION_FRONTEND_UI_SCALE, static_cast<int>(gStandalone.engineOptions.uiScale * 1000.0f), nullptr);
  221. if (gStandalone.engineOptions.frontendWinId != 0)
  222. {
  223. char strBuf[STR_MAX+1];
  224. strBuf[STR_MAX] = '\0';
  225. std::snprintf(strBuf, STR_MAX, P_UINTPTR, gStandalone.engineOptions.frontendWinId);
  226. engine->setOption(CB::ENGINE_OPTION_FRONTEND_WIN_ID, 0, strBuf);
  227. }
  228. else
  229. {
  230. engine->setOption(CB::ENGINE_OPTION_FRONTEND_WIN_ID, 0, "0");
  231. }
  232. # ifndef CARLA_OS_WIN
  233. if (gStandalone.engineOptions.wine.executable != nullptr && gStandalone.engineOptions.wine.executable[0] != '\0')
  234. engine->setOption(CB::ENGINE_OPTION_WINE_EXECUTABLE, 0, gStandalone.engineOptions.wine.executable);
  235. engine->setOption(CB::ENGINE_OPTION_WINE_AUTO_PREFIX, gStandalone.engineOptions.wine.autoPrefix ? 1 : 0, nullptr);
  236. if (gStandalone.engineOptions.wine.fallbackPrefix != nullptr && gStandalone.engineOptions.wine.fallbackPrefix[0] != '\0')
  237. engine->setOption(CB::ENGINE_OPTION_WINE_FALLBACK_PREFIX, 0, gStandalone.engineOptions.wine.fallbackPrefix);
  238. engine->setOption(CB::ENGINE_OPTION_WINE_RT_PRIO_ENABLED, gStandalone.engineOptions.wine.rtPrio ? 1 : 0, nullptr);
  239. engine->setOption(CB::ENGINE_OPTION_WINE_BASE_RT_PRIO, gStandalone.engineOptions.wine.baseRtPrio, nullptr);
  240. engine->setOption(CB::ENGINE_OPTION_WINE_SERVER_RT_PRIO, gStandalone.engineOptions.wine.serverRtPrio, nullptr);
  241. # endif
  242. #endif
  243. }
  244. bool carla_engine_init(const char* driverName, const char* clientName)
  245. {
  246. CARLA_SAFE_ASSERT_RETURN(driverName != nullptr && driverName[0] != '\0', false);
  247. CARLA_SAFE_ASSERT_RETURN(clientName != nullptr && clientName[0] != '\0', false);
  248. carla_debug("carla_engine_init(\"%s\", \"%s\")", driverName, clientName);
  249. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine == nullptr, "Engine is already initialized", false);
  250. #ifdef CARLA_OS_WIN
  251. carla_setenv("WINEASIO_CLIENT_NAME", clientName);
  252. #endif
  253. #ifdef USING_JUCE
  254. juce::initialiseJuce_GUI();
  255. #endif
  256. CarlaEngine* const engine = CarlaEngine::newDriverByName(driverName);
  257. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(engine != nullptr, "The seleted audio driver is not available", false);
  258. gStandalone.engine = engine;
  259. #ifdef BUILD_BRIDGE
  260. if (std::getenv("CARLA_BRIDGE_DUMMY") != nullptr)
  261. {
  262. // engine->setOption(CB::ENGINE_OPTION_PROCESS_MODE, CB::ENGINE_PROCESS_MODE_PATCHBAY, nullptr);
  263. engine->setOption(CB::ENGINE_OPTION_PROCESS_MODE, CB::ENGINE_PROCESS_MODE_CONTINUOUS_RACK, nullptr);
  264. engine->setOption(CB::ENGINE_OPTION_TRANSPORT_MODE, CB::ENGINE_TRANSPORT_MODE_INTERNAL, nullptr);
  265. engine->setOption(CB::ENGINE_OPTION_AUDIO_BUFFER_SIZE, 4096, nullptr);
  266. engine->setOption(CB::ENGINE_OPTION_AUDIO_SAMPLE_RATE, 48000, nullptr);
  267. }
  268. else
  269. {
  270. engine->setOption(CB::ENGINE_OPTION_PROCESS_MODE, CB::ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, nullptr);
  271. engine->setOption(CB::ENGINE_OPTION_TRANSPORT_MODE, CB::ENGINE_TRANSPORT_MODE_JACK, nullptr);
  272. }
  273. engine->setOption(CB::ENGINE_OPTION_FORCE_STEREO, false, nullptr);
  274. engine->setOption(CB::ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, false, nullptr);
  275. engine->setOption(CB::ENGINE_OPTION_PREFER_UI_BRIDGES, false, nullptr);
  276. #else
  277. engine->setOption(CB::ENGINE_OPTION_PROCESS_MODE, static_cast<int>(gStandalone.engineOptions.processMode), nullptr);
  278. engine->setOption(CB::ENGINE_OPTION_TRANSPORT_MODE, static_cast<int>(gStandalone.engineOptions.transportMode), gStandalone.engineOptions.transportExtra);
  279. #endif
  280. carla_engine_init_common(engine);
  281. if (engine->init(clientName))
  282. {
  283. #ifndef BUILD_BRIDGE
  284. if (gStandalone.logThreadEnabled && std::getenv("CARLA_LOGS_DISABLED") == nullptr)
  285. gStandalone.logThread.init();
  286. #endif
  287. #ifdef CARLA_OS_UNIX
  288. sThreadSafeFFTW.init();
  289. #endif
  290. gStandalone.lastError = "No error";
  291. return true;
  292. }
  293. else
  294. {
  295. gStandalone.lastError = engine->getLastError();
  296. gStandalone.engine = nullptr;
  297. delete engine;
  298. #ifdef USING_JUCE
  299. juce::shutdownJuce_GUI();
  300. #endif
  301. return false;
  302. }
  303. }
  304. #ifdef BUILD_BRIDGE
  305. bool carla_engine_init_bridge(const char audioBaseName[6+1], const char rtClientBaseName[6+1], const char nonRtClientBaseName[6+1],
  306. const char nonRtServerBaseName[6+1], const char* clientName)
  307. {
  308. CARLA_SAFE_ASSERT_RETURN(audioBaseName != nullptr && audioBaseName[0] != '\0', false);
  309. CARLA_SAFE_ASSERT_RETURN(rtClientBaseName != nullptr && rtClientBaseName[0] != '\0', false);
  310. CARLA_SAFE_ASSERT_RETURN(nonRtClientBaseName != nullptr && nonRtClientBaseName[0] != '\0', false);
  311. CARLA_SAFE_ASSERT_RETURN(nonRtServerBaseName != nullptr && nonRtServerBaseName[0] != '\0', false);
  312. CARLA_SAFE_ASSERT_RETURN(clientName != nullptr && clientName[0] != '\0', false);
  313. carla_debug("carla_engine_init_bridge(\"%s\", \"%s\", \"%s\", \"%s\", \"%s\")", audioBaseName, rtClientBaseName, nonRtClientBaseName, nonRtServerBaseName, clientName);
  314. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine == nullptr, "Engine is already initialized", false);
  315. ScopedPointer<CarlaEngine> engine(CarlaEngine::newBridge(audioBaseName,
  316. rtClientBaseName,
  317. nonRtClientBaseName,
  318. nonRtServerBaseName));
  319. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(engine != nullptr, "The seleted audio driver is not available", false);
  320. engine->setOption(CB::ENGINE_OPTION_PROCESS_MODE, CB::ENGINE_PROCESS_MODE_BRIDGE, nullptr);
  321. engine->setOption(CB::ENGINE_OPTION_TRANSPORT_MODE, CB::ENGINE_TRANSPORT_MODE_BRIDGE, nullptr);
  322. carla_engine_init_common(engine);
  323. if (engine->init(clientName))
  324. {
  325. gStandalone.lastError = "No error";
  326. gStandalone.engine = engine.release();
  327. return true;
  328. }
  329. else
  330. {
  331. gStandalone.lastError = engine->getLastError();
  332. return false;
  333. }
  334. }
  335. #endif
  336. bool carla_engine_close()
  337. {
  338. carla_debug("carla_engine_close()");
  339. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  340. #ifdef CARLA_OS_UNIX
  341. const ThreadSafeFFTW::Deinitializer tsfftwde(sThreadSafeFFTW);
  342. #endif
  343. CarlaEngine* const engine = gStandalone.engine;
  344. engine->setAboutToClose();
  345. engine->removeAllPlugins();
  346. const bool closed = engine->close();
  347. if (! closed)
  348. gStandalone.lastError = engine->getLastError();
  349. #ifndef BUILD_BRIDGE
  350. gStandalone.logThread.stop();
  351. #endif
  352. gStandalone.engine = nullptr;
  353. delete engine;
  354. #ifdef USING_JUCE
  355. juce::shutdownJuce_GUI();
  356. #endif
  357. return closed;
  358. }
  359. void carla_engine_idle()
  360. {
  361. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  362. gStandalone.engine->idle();
  363. #if defined(USING_JUCE) && !(defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN))
  364. const juce::MessageManager* const msgMgr(juce::MessageManager::getInstanceWithoutCreating());
  365. CARLA_SAFE_ASSERT_RETURN(msgMgr != nullptr,);
  366. for (; msgMgr->dispatchNextMessageOnSystemQueue(true);) {}
  367. #endif
  368. }
  369. bool carla_is_engine_running()
  370. {
  371. return (gStandalone.engine != nullptr && gStandalone.engine->isRunning());
  372. }
  373. const CarlaRuntimeEngineInfo* carla_get_runtime_engine_info()
  374. {
  375. static CarlaRuntimeEngineInfo retInfo;
  376. // reset
  377. retInfo.load = 0.0f;
  378. retInfo.xruns = 0;
  379. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retInfo);
  380. retInfo.load = gStandalone.engine->getDSPLoad();
  381. retInfo.xruns = gStandalone.engine->getTotalXruns();
  382. return &retInfo;
  383. }
  384. void carla_clear_engine_xruns()
  385. {
  386. if (gStandalone.engine != nullptr)
  387. gStandalone.engine->clearXruns();
  388. }
  389. void carla_cancel_engine_action()
  390. {
  391. if (gStandalone.engine != nullptr)
  392. gStandalone.engine->setActionCanceled(true);
  393. }
  394. bool carla_set_engine_about_to_close()
  395. {
  396. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, true);
  397. carla_debug("carla_set_engine_about_to_close()");
  398. return gStandalone.engine->setAboutToClose();
  399. }
  400. void carla_set_engine_callback(EngineCallbackFunc func, void* ptr)
  401. {
  402. carla_debug("carla_set_engine_callback(%p, %p)", func, ptr);
  403. gStandalone.engineCallback = func;
  404. gStandalone.engineCallbackPtr = ptr;
  405. #ifndef BUILD_BRIDGE
  406. gStandalone.logThread.setCallback(func, ptr);
  407. #endif
  408. if (gStandalone.engine != nullptr)
  409. gStandalone.engine->setCallback(func, ptr);
  410. }
  411. #ifndef BUILD_BRIDGE
  412. void carla_set_engine_option(EngineOption option, int value, const char* valueStr)
  413. {
  414. carla_debug("carla_set_engine_option(%i:%s, %i, \"%s\")", option, CB::EngineOption2Str(option), value, valueStr);
  415. switch (option)
  416. {
  417. case CB::ENGINE_OPTION_DEBUG:
  418. break;
  419. case CB::ENGINE_OPTION_PROCESS_MODE:
  420. CARLA_SAFE_ASSERT_RETURN(value >= CB::ENGINE_PROCESS_MODE_SINGLE_CLIENT && value < CB::ENGINE_PROCESS_MODE_BRIDGE,);
  421. gStandalone.engineOptions.processMode = static_cast<CB::EngineProcessMode>(value);
  422. break;
  423. case CB::ENGINE_OPTION_TRANSPORT_MODE:
  424. CARLA_SAFE_ASSERT_RETURN(value >= CB::ENGINE_TRANSPORT_MODE_DISABLED && value <= CB::ENGINE_TRANSPORT_MODE_BRIDGE,);
  425. if (value != CB::ENGINE_TRANSPORT_MODE_JACK)
  426. {
  427. // jack transport cannot be disabled in multi-client
  428. if (gStandalone.engineCallback != nullptr)
  429. gStandalone.engineCallback(gStandalone.engineCallbackPtr,
  430. CB::ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED,
  431. 0,
  432. CB::ENGINE_TRANSPORT_MODE_JACK,
  433. 0, 0, 0.0f,
  434. gStandalone.engineOptions.transportExtra);
  435. CARLA_SAFE_ASSERT_RETURN(gStandalone.engineOptions.processMode != CB::ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS,);
  436. }
  437. gStandalone.engineOptions.transportMode = static_cast<CB::EngineTransportMode>(value);
  438. delete[] gStandalone.engineOptions.transportExtra;
  439. if (value != CB::ENGINE_TRANSPORT_MODE_DISABLED && valueStr != nullptr)
  440. gStandalone.engineOptions.transportExtra = carla_strdup_safe(valueStr);
  441. else
  442. gStandalone.engineOptions.transportExtra = nullptr;
  443. break;
  444. case CB::ENGINE_OPTION_FORCE_STEREO:
  445. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  446. gStandalone.engineOptions.forceStereo = (value != 0);
  447. break;
  448. case CB::ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
  449. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  450. gStandalone.engineOptions.preferPluginBridges = (value != 0);
  451. break;
  452. case CB::ENGINE_OPTION_PREFER_UI_BRIDGES:
  453. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  454. gStandalone.engineOptions.preferUiBridges = (value != 0);
  455. break;
  456. case CB::ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
  457. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  458. gStandalone.engineOptions.uisAlwaysOnTop = (value != 0);
  459. break;
  460. case CB::ENGINE_OPTION_MAX_PARAMETERS:
  461. CARLA_SAFE_ASSERT_RETURN(value >= 0,);
  462. gStandalone.engineOptions.maxParameters = static_cast<uint>(value);
  463. break;
  464. case CB::ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
  465. CARLA_SAFE_ASSERT_RETURN(value >= 0,);
  466. gStandalone.engineOptions.uiBridgesTimeout = static_cast<uint>(value);
  467. break;
  468. case CB::ENGINE_OPTION_AUDIO_BUFFER_SIZE:
  469. CARLA_SAFE_ASSERT_RETURN(value >= 8,);
  470. gStandalone.engineOptions.audioBufferSize = static_cast<uint>(value);
  471. break;
  472. case CB::ENGINE_OPTION_AUDIO_SAMPLE_RATE:
  473. CARLA_SAFE_ASSERT_RETURN(value >= 22050,);
  474. gStandalone.engineOptions.audioSampleRate = static_cast<uint>(value);
  475. break;
  476. case CB::ENGINE_OPTION_AUDIO_TRIPLE_BUFFER:
  477. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  478. gStandalone.engineOptions.audioTripleBuffer = (value != 0);
  479. break;
  480. case CB::ENGINE_OPTION_AUDIO_DEVICE:
  481. CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr,);
  482. if (gStandalone.engineOptions.audioDevice != nullptr)
  483. delete[] gStandalone.engineOptions.audioDevice;
  484. gStandalone.engineOptions.audioDevice = carla_strdup_safe(valueStr);
  485. break;
  486. case CB::ENGINE_OPTION_OSC_ENABLED:
  487. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  488. gStandalone.engineOptions.oscEnabled = (value != 0);
  489. break;
  490. case CB::ENGINE_OPTION_OSC_PORT_TCP:
  491. CARLA_SAFE_ASSERT_RETURN(value <= 0 || value >= 1024,);
  492. gStandalone.engineOptions.oscPortTCP = value;
  493. break;
  494. case CB::ENGINE_OPTION_OSC_PORT_UDP:
  495. CARLA_SAFE_ASSERT_RETURN(value <= 0 || value >= 1024,);
  496. gStandalone.engineOptions.oscPortUDP = value;
  497. break;
  498. case CB::ENGINE_OPTION_PLUGIN_PATH:
  499. CARLA_SAFE_ASSERT_RETURN(value > CB::PLUGIN_NONE,);
  500. CARLA_SAFE_ASSERT_RETURN(value <= CB::PLUGIN_SFZ,);
  501. CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr,);
  502. switch (value)
  503. {
  504. case CB::PLUGIN_LADSPA:
  505. if (gStandalone.engineOptions.pathLADSPA != nullptr)
  506. delete[] gStandalone.engineOptions.pathLADSPA;
  507. gStandalone.engineOptions.pathLADSPA = carla_strdup_safe(valueStr);
  508. break;
  509. case CB::PLUGIN_DSSI:
  510. if (gStandalone.engineOptions.pathDSSI != nullptr)
  511. delete[] gStandalone.engineOptions.pathDSSI;
  512. gStandalone.engineOptions.pathDSSI = carla_strdup_safe(valueStr);
  513. break;
  514. case CB::PLUGIN_LV2:
  515. if (gStandalone.engineOptions.pathLV2 != nullptr)
  516. delete[] gStandalone.engineOptions.pathLV2;
  517. gStandalone.engineOptions.pathLV2 = carla_strdup_safe(valueStr);
  518. break;
  519. case CB::PLUGIN_VST2:
  520. if (gStandalone.engineOptions.pathVST2 != nullptr)
  521. delete[] gStandalone.engineOptions.pathVST2;
  522. gStandalone.engineOptions.pathVST2 = carla_strdup_safe(valueStr);
  523. break;
  524. case CB::PLUGIN_VST3:
  525. if (gStandalone.engineOptions.pathVST3 != nullptr)
  526. delete[] gStandalone.engineOptions.pathVST3;
  527. gStandalone.engineOptions.pathVST3 = carla_strdup_safe(valueStr);
  528. break;
  529. case CB::PLUGIN_SF2:
  530. if (gStandalone.engineOptions.pathSF2 != nullptr)
  531. delete[] gStandalone.engineOptions.pathSF2;
  532. gStandalone.engineOptions.pathSF2 = carla_strdup_safe(valueStr);
  533. break;
  534. case CB::PLUGIN_SFZ:
  535. if (gStandalone.engineOptions.pathSFZ != nullptr)
  536. delete[] gStandalone.engineOptions.pathSFZ;
  537. gStandalone.engineOptions.pathSFZ = carla_strdup_safe(valueStr);
  538. break;
  539. }
  540. break;
  541. case CB::ENGINE_OPTION_PATH_BINARIES:
  542. CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
  543. if (gStandalone.engineOptions.binaryDir != nullptr)
  544. delete[] gStandalone.engineOptions.binaryDir;
  545. gStandalone.engineOptions.binaryDir = carla_strdup_safe(valueStr);
  546. break;
  547. case CB::ENGINE_OPTION_PATH_RESOURCES:
  548. CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
  549. if (gStandalone.engineOptions.resourceDir != nullptr)
  550. delete[] gStandalone.engineOptions.resourceDir;
  551. gStandalone.engineOptions.resourceDir = carla_strdup_safe(valueStr);
  552. break;
  553. case CB::ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR:
  554. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  555. gStandalone.engineOptions.preventBadBehaviour = (value != 0);
  556. break;
  557. case CB::ENGINE_OPTION_FRONTEND_UI_SCALE:
  558. CARLA_SAFE_ASSERT_RETURN(value > 0,);
  559. gStandalone.engineOptions.uiScale = static_cast<float>(value) / 1000;
  560. break;
  561. case CB::ENGINE_OPTION_FRONTEND_WIN_ID: {
  562. CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
  563. const long long winId(std::strtoll(valueStr, nullptr, 16));
  564. CARLA_SAFE_ASSERT_RETURN(winId >= 0,);
  565. gStandalone.engineOptions.frontendWinId = static_cast<uintptr_t>(winId);
  566. } break;
  567. #ifndef CARLA_OS_WIN
  568. case CB::ENGINE_OPTION_WINE_EXECUTABLE:
  569. CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
  570. if (gStandalone.engineOptions.wine.executable != nullptr)
  571. delete[] gStandalone.engineOptions.wine.executable;
  572. gStandalone.engineOptions.wine.executable = carla_strdup_safe(valueStr);
  573. break;
  574. case CB::ENGINE_OPTION_WINE_AUTO_PREFIX:
  575. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  576. gStandalone.engineOptions.wine.autoPrefix = (value != 0);
  577. break;
  578. case CB::ENGINE_OPTION_WINE_FALLBACK_PREFIX:
  579. CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
  580. if (gStandalone.engineOptions.wine.fallbackPrefix != nullptr)
  581. delete[] gStandalone.engineOptions.wine.fallbackPrefix;
  582. gStandalone.engineOptions.wine.fallbackPrefix = carla_strdup_safe(valueStr);
  583. break;
  584. case CB::ENGINE_OPTION_WINE_RT_PRIO_ENABLED:
  585. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  586. gStandalone.engineOptions.wine.rtPrio = (value != 0);
  587. break;
  588. case CB::ENGINE_OPTION_WINE_BASE_RT_PRIO:
  589. CARLA_SAFE_ASSERT_RETURN(value >= 1 && value <= 89,);
  590. gStandalone.engineOptions.wine.baseRtPrio = value;
  591. break;
  592. case CB::ENGINE_OPTION_WINE_SERVER_RT_PRIO:
  593. CARLA_SAFE_ASSERT_RETURN(value >= 1 && value <= 99,);
  594. gStandalone.engineOptions.wine.serverRtPrio = value;
  595. break;
  596. #endif
  597. case CB::ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT:
  598. gStandalone.logThreadEnabled = (value != 0);
  599. break;
  600. }
  601. if (gStandalone.engine != nullptr)
  602. gStandalone.engine->setOption(option, value, valueStr);
  603. }
  604. #endif
  605. void carla_set_file_callback(FileCallbackFunc func, void* ptr)
  606. {
  607. carla_debug("carla_set_file_callback(%p, %p)", func, ptr);
  608. gStandalone.fileCallback = func;
  609. gStandalone.fileCallbackPtr = ptr;
  610. if (gStandalone.engine != nullptr)
  611. gStandalone.engine->setFileCallback(func, ptr);
  612. }
  613. // --------------------------------------------------------------------------------------------------------------------
  614. bool carla_load_file(const char* filename)
  615. {
  616. CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
  617. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  618. carla_debug("carla_load_file(\"%s\")", filename);
  619. return gStandalone.engine->loadFile(filename);
  620. }
  621. bool carla_load_project(const char* filename)
  622. {
  623. CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
  624. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  625. carla_debug("carla_load_project(\"%s\")", filename);
  626. return gStandalone.engine->loadProject(filename, true);
  627. }
  628. bool carla_save_project(const char* filename)
  629. {
  630. CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
  631. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  632. carla_debug("carla_save_project(\"%s\")", filename);
  633. return gStandalone.engine->saveProject(filename, true);
  634. }
  635. #ifndef BUILD_BRIDGE
  636. void carla_clear_project_filename()
  637. {
  638. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  639. carla_debug("carla_clear_project_filename()");
  640. gStandalone.engine->clearCurrentProjectFilename();
  641. }
  642. // --------------------------------------------------------------------------------------------------------------------
  643. bool carla_patchbay_connect(bool external, uint groupIdA, uint portIdA, uint groupIdB, uint portIdB)
  644. {
  645. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  646. carla_debug("carla_patchbay_connect(%s, %u, %u, %u, %u)",
  647. bool2str(external), groupIdA, portIdA, groupIdB, portIdB);
  648. return gStandalone.engine->patchbayConnect(external, groupIdA, portIdA, groupIdB, portIdB);
  649. }
  650. bool carla_patchbay_disconnect(bool external, uint connectionId)
  651. {
  652. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  653. carla_debug("carla_patchbay_disconnect(%s, %i)", bool2str(external), connectionId);
  654. return gStandalone.engine->patchbayDisconnect(external, connectionId);
  655. }
  656. bool carla_patchbay_refresh(bool external)
  657. {
  658. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  659. carla_debug("carla_patchbay_refresh(%s)", bool2str(external));
  660. return gStandalone.engine->patchbayRefresh(true, false, external);
  661. }
  662. // --------------------------------------------------------------------------------------------------------------------
  663. void carla_transport_play()
  664. {
  665. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr && gStandalone.engine->isRunning(),);
  666. carla_debug("carla_transport_play()");
  667. gStandalone.engine->transportPlay();
  668. }
  669. void carla_transport_pause()
  670. {
  671. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr && gStandalone.engine->isRunning(),);
  672. carla_debug("carla_transport_pause()");
  673. gStandalone.engine->transportPause();
  674. }
  675. void carla_transport_bpm(double bpm)
  676. {
  677. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr && gStandalone.engine->isRunning(),);
  678. carla_debug("carla_transport_bpm(%f)", bpm);
  679. gStandalone.engine->transportBPM(bpm);
  680. }
  681. void carla_transport_relocate(uint64_t frame)
  682. {
  683. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr && gStandalone.engine->isRunning(),);
  684. carla_debug("carla_transport_relocate(%i)", frame);
  685. gStandalone.engine->transportRelocate(frame);
  686. }
  687. uint64_t carla_get_current_transport_frame()
  688. {
  689. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr && gStandalone.engine->isRunning(), 0);
  690. return gStandalone.engine->getTimeInfo().frame;
  691. }
  692. const CarlaTransportInfo* carla_get_transport_info()
  693. {
  694. static CarlaTransportInfo retTransInfo;
  695. retTransInfo.clear();
  696. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr && gStandalone.engine->isRunning(), &retTransInfo);
  697. const CB::EngineTimeInfo& timeInfo(gStandalone.engine->getTimeInfo());
  698. retTransInfo.playing = timeInfo.playing;
  699. retTransInfo.frame = timeInfo.frame;
  700. if (timeInfo.bbt.valid)
  701. {
  702. retTransInfo.bar = timeInfo.bbt.bar;
  703. retTransInfo.beat = timeInfo.bbt.beat;
  704. retTransInfo.tick = static_cast<int32_t>(timeInfo.bbt.tick + 0.5);
  705. retTransInfo.bpm = timeInfo.bbt.beatsPerMinute;
  706. }
  707. return &retTransInfo;
  708. }
  709. #endif
  710. // --------------------------------------------------------------------------------------------------------------------
  711. uint32_t carla_get_current_plugin_count()
  712. {
  713. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0);
  714. carla_debug("carla_get_current_plugin_count()");
  715. return gStandalone.engine->getCurrentPluginCount();
  716. }
  717. uint32_t carla_get_max_plugin_number()
  718. {
  719. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0);
  720. carla_debug("carla_get_max_plugin_number()");
  721. return gStandalone.engine->getMaxPluginNumber();
  722. }
  723. // --------------------------------------------------------------------------------------------------------------------
  724. bool carla_add_plugin(BinaryType btype, PluginType ptype,
  725. const char* filename, const char* name, const char* label, int64_t uniqueId,
  726. const void* extraPtr, uint options)
  727. {
  728. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  729. carla_debug("carla_add_plugin(%i:%s, %i:%s, \"%s\", \"%s\", \"%s\", " P_INT64 ", %p, %u)",
  730. btype, CB::BinaryType2Str(btype),
  731. ptype, CB::PluginType2Str(ptype),
  732. filename, name, label, uniqueId, extraPtr, options);
  733. return gStandalone.engine->addPlugin(btype, ptype, filename, name, label, uniqueId, extraPtr, options);
  734. }
  735. bool carla_remove_plugin(uint pluginId)
  736. {
  737. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  738. carla_debug("carla_remove_plugin(%i)", pluginId);
  739. return gStandalone.engine->removePlugin(pluginId);
  740. }
  741. bool carla_remove_all_plugins()
  742. {
  743. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  744. carla_debug("carla_remove_all_plugins()");
  745. return gStandalone.engine->removeAllPlugins();
  746. }
  747. #ifndef BUILD_BRIDGE
  748. bool carla_rename_plugin(uint pluginId, const char* newName)
  749. {
  750. CARLA_SAFE_ASSERT_RETURN(newName != nullptr && newName[0] != '\0', false);
  751. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  752. carla_debug("carla_rename_plugin(%i, \"%s\")", pluginId, newName);
  753. return gStandalone.engine->renamePlugin(pluginId, newName);
  754. }
  755. bool carla_clone_plugin(uint pluginId)
  756. {
  757. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  758. carla_debug("carla_clone_plugin(%i)", pluginId);
  759. return gStandalone.engine->clonePlugin(pluginId);
  760. }
  761. bool carla_replace_plugin(uint pluginId)
  762. {
  763. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  764. carla_debug("carla_replace_plugin(%i)", pluginId);
  765. return gStandalone.engine->replacePlugin(pluginId);
  766. }
  767. bool carla_switch_plugins(uint pluginIdA, uint pluginIdB)
  768. {
  769. CARLA_SAFE_ASSERT_RETURN(pluginIdA != pluginIdB, false);
  770. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  771. carla_debug("carla_switch_plugins(%i, %i)", pluginIdA, pluginIdB);
  772. return gStandalone.engine->switchPlugins(pluginIdA, pluginIdB);
  773. }
  774. #endif
  775. // --------------------------------------------------------------------------------------------------------------------
  776. bool carla_load_plugin_state(uint pluginId, const char* filename)
  777. {
  778. CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
  779. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr
  780. && gStandalone.engine->isRunning(), "Engine is not running", false);
  781. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  782. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(plugin != nullptr, "could not find requested plugin", false);
  783. carla_debug("carla_load_plugin_state(%i, \"%s\")", pluginId, filename);
  784. return plugin->loadStateFromFile(filename);
  785. }
  786. bool carla_save_plugin_state(uint pluginId, const char* filename)
  787. {
  788. CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
  789. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  790. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  791. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(plugin != nullptr, "could not find requested plugin", false);
  792. carla_debug("carla_save_plugin_state(%i, \"%s\")", pluginId, filename);
  793. return plugin->saveStateToFile(filename);
  794. }
  795. bool carla_export_plugin_lv2(uint pluginId, const char* lv2path)
  796. {
  797. CARLA_SAFE_ASSERT_RETURN(lv2path != nullptr && lv2path[0] != '\0', false);
  798. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(gStandalone.engine != nullptr, "Engine is not initialized", false);
  799. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  800. CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(plugin != nullptr, "could not find requested plugin", false);
  801. carla_debug("carla_export_plugin_lv2(%i, \"%s\")", pluginId, lv2path);
  802. return plugin->exportAsLV2(lv2path);
  803. }
  804. // --------------------------------------------------------------------------------------------------------------------
  805. const CarlaPluginInfo* carla_get_plugin_info(uint pluginId)
  806. {
  807. static CarlaPluginInfo retInfo;
  808. // reset
  809. retInfo.type = CB::PLUGIN_NONE;
  810. retInfo.category = CB::PLUGIN_CATEGORY_NONE;
  811. retInfo.hints = 0x0;
  812. retInfo.optionsAvailable = 0x0;
  813. retInfo.optionsEnabled = 0x0;
  814. retInfo.filename = gNullCharPtr;
  815. retInfo.name = gNullCharPtr;
  816. retInfo.iconName = gNullCharPtr;
  817. retInfo.uniqueId = 0;
  818. // cleanup
  819. if (retInfo.label != gNullCharPtr)
  820. {
  821. delete[] retInfo.label;
  822. retInfo.label = gNullCharPtr;
  823. }
  824. if (retInfo.maker != gNullCharPtr)
  825. {
  826. delete[] retInfo.maker;
  827. retInfo.maker = gNullCharPtr;
  828. }
  829. if (retInfo.copyright != gNullCharPtr)
  830. {
  831. delete[] retInfo.copyright;
  832. retInfo.copyright = gNullCharPtr;
  833. }
  834. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retInfo);
  835. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  836. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);
  837. carla_debug("carla_get_plugin_info(%i)", pluginId);
  838. char strBuf[STR_MAX+1];
  839. retInfo.type = plugin->getType();
  840. retInfo.category = plugin->getCategory();
  841. retInfo.hints = plugin->getHints();
  842. retInfo.filename = plugin->getFilename();
  843. retInfo.name = plugin->getName();
  844. retInfo.iconName = plugin->getIconName();
  845. retInfo.uniqueId = plugin->getUniqueId();
  846. retInfo.optionsAvailable = plugin->getOptionsAvailable();
  847. retInfo.optionsEnabled = plugin->getOptionsEnabled();
  848. carla_zeroChars(strBuf, STR_MAX+1);
  849. plugin->getLabel(strBuf);
  850. retInfo.label = carla_strdup_safe(strBuf);
  851. carla_zeroChars(strBuf, STR_MAX+1);
  852. plugin->getMaker(strBuf);
  853. retInfo.maker = carla_strdup_safe(strBuf);
  854. carla_zeroChars(strBuf, STR_MAX+1);
  855. plugin->getCopyright(strBuf);
  856. retInfo.copyright = carla_strdup_safe(strBuf);
  857. checkStringPtr(retInfo.filename);
  858. checkStringPtr(retInfo.name);
  859. checkStringPtr(retInfo.iconName);
  860. checkStringPtr(retInfo.label);
  861. checkStringPtr(retInfo.maker);
  862. checkStringPtr(retInfo.copyright);
  863. return &retInfo;
  864. }
  865. const CarlaPortCountInfo* carla_get_audio_port_count_info(uint pluginId)
  866. {
  867. static CarlaPortCountInfo retInfo;
  868. carla_zeroStruct(retInfo);
  869. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retInfo);
  870. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  871. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);
  872. carla_debug("carla_get_audio_port_count_info(%i)", pluginId);
  873. retInfo.ins = plugin->getAudioInCount();
  874. retInfo.outs = plugin->getAudioOutCount();
  875. return &retInfo;
  876. }
  877. const CarlaPortCountInfo* carla_get_midi_port_count_info(uint pluginId)
  878. {
  879. static CarlaPortCountInfo retInfo;
  880. carla_zeroStruct(retInfo);
  881. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retInfo);
  882. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  883. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);
  884. carla_debug("carla_get_midi_port_count_info(%i)", pluginId);
  885. retInfo.ins = plugin->getMidiInCount();
  886. retInfo.outs = plugin->getMidiOutCount();
  887. return &retInfo;
  888. }
  889. const CarlaPortCountInfo* carla_get_parameter_count_info(uint pluginId)
  890. {
  891. static CarlaPortCountInfo retInfo;
  892. carla_zeroStruct(retInfo);
  893. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retInfo);
  894. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  895. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);
  896. carla_debug("carla_get_parameter_count_info(%i)", pluginId);
  897. plugin->getParameterCountInfo(retInfo.ins, retInfo.outs);
  898. return &retInfo;
  899. }
  900. const CarlaParameterInfo* carla_get_parameter_info(uint pluginId, uint32_t parameterId)
  901. {
  902. static CarlaParameterInfo retInfo;
  903. // reset
  904. retInfo.scalePointCount = 0;
  905. // cleanup
  906. if (retInfo.name != gNullCharPtr)
  907. {
  908. delete[] retInfo.name;
  909. retInfo.name = gNullCharPtr;
  910. }
  911. if (retInfo.symbol != gNullCharPtr)
  912. {
  913. delete[] retInfo.symbol;
  914. retInfo.symbol = gNullCharPtr;
  915. }
  916. if (retInfo.unit != gNullCharPtr)
  917. {
  918. delete[] retInfo.unit;
  919. retInfo.unit = gNullCharPtr;
  920. }
  921. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retInfo);
  922. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  923. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);
  924. carla_debug("carla_get_parameter_info(%i, %i)", pluginId, parameterId);
  925. char strBuf[STR_MAX+1];
  926. retInfo.scalePointCount = plugin->getParameterScalePointCount(parameterId);
  927. carla_zeroChars(strBuf, STR_MAX+1);
  928. plugin->getParameterName(parameterId, strBuf);
  929. retInfo.name = carla_strdup_safe(strBuf);
  930. carla_zeroChars(strBuf, STR_MAX+1);
  931. plugin->getParameterSymbol(parameterId, strBuf);
  932. retInfo.symbol = carla_strdup_safe(strBuf);
  933. carla_zeroChars(strBuf, STR_MAX+1);
  934. plugin->getParameterUnit(parameterId, strBuf);
  935. retInfo.unit = carla_strdup_safe(strBuf);
  936. checkStringPtr(retInfo.name);
  937. checkStringPtr(retInfo.symbol);
  938. checkStringPtr(retInfo.unit);
  939. return &retInfo;
  940. }
  941. const CarlaScalePointInfo* carla_get_parameter_scalepoint_info(uint pluginId, uint32_t parameterId, uint32_t scalePointId)
  942. {
  943. CARLA_ASSERT(gStandalone.engine != nullptr);
  944. static CarlaScalePointInfo retInfo;
  945. // reset
  946. retInfo.value = 0.0f;
  947. // cleanup
  948. if (retInfo.label != gNullCharPtr)
  949. {
  950. delete[] retInfo.label;
  951. retInfo.label = gNullCharPtr;
  952. }
  953. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retInfo);
  954. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  955. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);
  956. carla_debug("carla_get_parameter_scalepoint_info(%i, %i, %i)", pluginId, parameterId, scalePointId);
  957. char strBuf[STR_MAX+1];
  958. retInfo.value = plugin->getParameterScalePointValue(parameterId, scalePointId);
  959. carla_zeroChars(strBuf, STR_MAX+1);
  960. plugin->getParameterScalePointLabel(parameterId, scalePointId, strBuf);
  961. retInfo.label = carla_strdup_safe(strBuf);
  962. checkStringPtr(retInfo.label);
  963. return &retInfo;
  964. }
  965. // --------------------------------------------------------------------------------------------------------------------
  966. const ParameterData* carla_get_parameter_data(uint pluginId, uint32_t parameterId)
  967. {
  968. static ParameterData retParamData;
  969. // reset
  970. retParamData.type = CB::PARAMETER_UNKNOWN;
  971. retParamData.hints = 0x0;
  972. retParamData.index = CB::PARAMETER_NULL;
  973. retParamData.rindex = -1;
  974. retParamData.midiCC = -1;
  975. retParamData.midiChannel = 0;
  976. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retParamData);
  977. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  978. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retParamData);
  979. carla_debug("carla_get_parameter_data(%i, %i)", pluginId, parameterId);
  980. CARLA_SAFE_ASSERT_RETURN(parameterId < plugin->getParameterCount(), &retParamData);
  981. const ParameterData& pluginParamData(plugin->getParameterData(parameterId));
  982. retParamData.type = pluginParamData.type;
  983. retParamData.hints = pluginParamData.hints;
  984. retParamData.index = pluginParamData.index;
  985. retParamData.rindex = pluginParamData.rindex;
  986. retParamData.midiCC = pluginParamData.midiCC;
  987. retParamData.midiChannel = pluginParamData.midiChannel;
  988. return &plugin->getParameterData(parameterId);
  989. }
  990. const ParameterRanges* carla_get_parameter_ranges(uint pluginId, uint32_t parameterId)
  991. {
  992. static ParameterRanges retParamRanges;
  993. // reset
  994. retParamRanges.def = 0.0f;
  995. retParamRanges.min = 0.0f;
  996. retParamRanges.max = 1.0f;
  997. retParamRanges.step = 0.01f;
  998. retParamRanges.stepSmall = 0.0001f;
  999. retParamRanges.stepLarge = 0.1f;
  1000. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retParamRanges);
  1001. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1002. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retParamRanges);
  1003. carla_debug("carla_get_parameter_ranges(%i, %i)", pluginId, parameterId);
  1004. CARLA_SAFE_ASSERT_RETURN(parameterId < plugin->getParameterCount(), &retParamRanges);
  1005. const ParameterRanges& pluginParamRanges(plugin->getParameterRanges(parameterId));
  1006. retParamRanges.def = pluginParamRanges.def;
  1007. retParamRanges.min = pluginParamRanges.min;
  1008. retParamRanges.max = pluginParamRanges.max;
  1009. retParamRanges.step = pluginParamRanges.step;
  1010. retParamRanges.stepSmall = pluginParamRanges.stepSmall;
  1011. retParamRanges.stepLarge = pluginParamRanges.stepLarge;
  1012. return &pluginParamRanges;
  1013. }
  1014. const MidiProgramData* carla_get_midi_program_data(uint pluginId, uint32_t midiProgramId)
  1015. {
  1016. static MidiProgramData retMidiProgData = { 0, 0, gNullCharPtr };
  1017. // reset
  1018. retMidiProgData.bank = 0;
  1019. retMidiProgData.program = 0;
  1020. if (retMidiProgData.name != gNullCharPtr)
  1021. {
  1022. delete[] retMidiProgData.name;
  1023. retMidiProgData.name = gNullCharPtr;
  1024. }
  1025. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retMidiProgData);
  1026. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1027. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retMidiProgData);
  1028. carla_debug("carla_get_midi_program_data(%i, %i)", pluginId, midiProgramId);
  1029. CARLA_SAFE_ASSERT_RETURN(midiProgramId < plugin->getMidiProgramCount(), &retMidiProgData);
  1030. const MidiProgramData& pluginMidiProgData(plugin->getMidiProgramData(midiProgramId));
  1031. retMidiProgData.bank = pluginMidiProgData.bank;
  1032. retMidiProgData.program = pluginMidiProgData.program;
  1033. if (pluginMidiProgData.name != nullptr)
  1034. {
  1035. retMidiProgData.name = carla_strdup_safe(pluginMidiProgData.name);
  1036. checkStringPtr(retMidiProgData.name);
  1037. }
  1038. else
  1039. {
  1040. retMidiProgData.name = gNullCharPtr;
  1041. }
  1042. return &retMidiProgData;
  1043. }
  1044. const CustomData* carla_get_custom_data(uint pluginId, uint32_t customDataId)
  1045. {
  1046. static CustomData retCustomData = { gNullCharPtr, gNullCharPtr, gNullCharPtr };
  1047. // reset
  1048. if (retCustomData.type != gNullCharPtr)
  1049. {
  1050. delete[] retCustomData.type;
  1051. retCustomData.type = gNullCharPtr;
  1052. }
  1053. if (retCustomData.key != gNullCharPtr)
  1054. {
  1055. delete[] retCustomData.key;
  1056. retCustomData.key = gNullCharPtr;
  1057. }
  1058. if (retCustomData.value != gNullCharPtr)
  1059. {
  1060. delete[] retCustomData.value;
  1061. retCustomData.value = gNullCharPtr;
  1062. }
  1063. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retCustomData);
  1064. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1065. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retCustomData);
  1066. carla_debug("carla_get_custom_data(%i, %i)", pluginId, customDataId);
  1067. CARLA_SAFE_ASSERT_RETURN(customDataId < plugin->getCustomDataCount(), &retCustomData)
  1068. const CustomData& pluginCustomData(plugin->getCustomData(customDataId));
  1069. retCustomData.type = carla_strdup_safe(pluginCustomData.type);
  1070. retCustomData.key = carla_strdup_safe(pluginCustomData.key);
  1071. retCustomData.value = carla_strdup_safe(pluginCustomData.value);
  1072. checkStringPtr(retCustomData.type);
  1073. checkStringPtr(retCustomData.key);
  1074. checkStringPtr(retCustomData.value);
  1075. return &retCustomData;
  1076. }
  1077. const char* carla_get_custom_data_value(uint pluginId, const char* type, const char* key)
  1078. {
  1079. CARLA_SAFE_ASSERT_RETURN(type != nullptr && type[0] != '\0', gNullCharPtr);
  1080. CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0', gNullCharPtr);
  1081. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, gNullCharPtr);
  1082. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1083. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);
  1084. carla_debug("carla_get_custom_data_value(%i, %s, %s)", pluginId, type, key);
  1085. const uint32_t count = plugin->getCustomDataCount();
  1086. if (count == 0)
  1087. return gNullCharPtr;
  1088. static CarlaString customDataValue;
  1089. for (uint32_t i=0; i<count; ++i)
  1090. {
  1091. const CustomData& pluginCustomData(plugin->getCustomData(i));
  1092. if (std::strcmp(pluginCustomData.type, type) != 0)
  1093. continue;
  1094. if (std::strcmp(pluginCustomData.key, key) != 0)
  1095. continue;
  1096. customDataValue = pluginCustomData.value;
  1097. return customDataValue.buffer();
  1098. }
  1099. return gNullCharPtr;
  1100. }
  1101. const char* carla_get_chunk_data(uint pluginId)
  1102. {
  1103. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, gNullCharPtr);
  1104. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1105. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);
  1106. carla_debug("carla_get_chunk_data(%i)", pluginId);
  1107. CARLA_SAFE_ASSERT_RETURN(plugin->getOptionsEnabled() & CB::PLUGIN_OPTION_USE_CHUNKS, gNullCharPtr);
  1108. void* data = nullptr;
  1109. const std::size_t dataSize(plugin->getChunkData(&data));
  1110. CARLA_SAFE_ASSERT_RETURN(data != nullptr && dataSize > 0, gNullCharPtr);
  1111. static CarlaString chunkData;
  1112. chunkData = CarlaString::asBase64(data, static_cast<std::size_t>(dataSize));
  1113. return chunkData.buffer();
  1114. }
  1115. // --------------------------------------------------------------------------------------------------------------------
  1116. uint32_t carla_get_parameter_count(uint pluginId)
  1117. {
  1118. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0);
  1119. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1120. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0);
  1121. carla_debug("carla_get_parameter_count(%i)", pluginId);
  1122. return plugin->getParameterCount();
  1123. }
  1124. uint32_t carla_get_program_count(uint pluginId)
  1125. {
  1126. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0);
  1127. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1128. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0);
  1129. carla_debug("carla_get_program_count(%i)", pluginId);
  1130. return plugin->getProgramCount();
  1131. }
  1132. uint32_t carla_get_midi_program_count(uint pluginId)
  1133. {
  1134. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0);
  1135. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1136. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0);
  1137. carla_debug("carla_get_midi_program_count(%i)", pluginId);
  1138. return plugin->getMidiProgramCount();
  1139. }
  1140. uint32_t carla_get_custom_data_count(uint pluginId)
  1141. {
  1142. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0);
  1143. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1144. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0);
  1145. carla_debug("carla_get_custom_data_count(%i)", pluginId);
  1146. return plugin->getCustomDataCount();
  1147. }
  1148. // --------------------------------------------------------------------------------------------------------------------
  1149. const char* carla_get_parameter_text(uint pluginId, uint32_t parameterId)
  1150. {
  1151. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, gNullCharPtr);
  1152. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1153. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);
  1154. carla_debug("carla_get_parameter_text(%i, %i)", pluginId, parameterId);
  1155. CARLA_SAFE_ASSERT_RETURN(parameterId < plugin->getParameterCount(), gNullCharPtr);
  1156. static char textBuf[STR_MAX+1];
  1157. carla_zeroChars(textBuf, STR_MAX+1);
  1158. plugin->getParameterText(parameterId, textBuf);
  1159. return textBuf;
  1160. }
  1161. const char* carla_get_program_name(uint pluginId, uint32_t programId)
  1162. {
  1163. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, nullptr);
  1164. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1165. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);
  1166. carla_debug("carla_get_program_name(%i, %i)", pluginId, programId);
  1167. CARLA_SAFE_ASSERT_RETURN(programId < plugin->getProgramCount(), gNullCharPtr);
  1168. static char programName[STR_MAX+1];
  1169. carla_zeroChars(programName, STR_MAX+1);
  1170. plugin->getProgramName(programId, programName);
  1171. return programName;
  1172. }
  1173. const char* carla_get_midi_program_name(uint pluginId, uint32_t midiProgramId)
  1174. {
  1175. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, gNullCharPtr);
  1176. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1177. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);
  1178. carla_debug("carla_get_midi_program_name(%i, %i)", pluginId, midiProgramId);
  1179. CARLA_SAFE_ASSERT_RETURN(midiProgramId < plugin->getMidiProgramCount(), gNullCharPtr);
  1180. static char midiProgramName[STR_MAX+1];
  1181. carla_zeroChars(midiProgramName, STR_MAX+1);
  1182. plugin->getMidiProgramName(midiProgramId, midiProgramName);
  1183. return midiProgramName;
  1184. }
  1185. const char* carla_get_real_plugin_name(uint pluginId)
  1186. {
  1187. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, gNullCharPtr);
  1188. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1189. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);
  1190. carla_debug("carla_get_real_plugin_name(%i)", pluginId);
  1191. static char realPluginName[STR_MAX+1];
  1192. carla_zeroChars(realPluginName, STR_MAX+1);
  1193. plugin->getRealName(realPluginName);
  1194. return realPluginName;
  1195. }
  1196. // --------------------------------------------------------------------------------------------------------------------
  1197. int32_t carla_get_current_program_index(uint pluginId)
  1198. {
  1199. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, -1);
  1200. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1201. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, -1);
  1202. carla_debug("carla_get_current_program_index(%i)", pluginId);
  1203. return plugin->getCurrentProgram();
  1204. }
  1205. int32_t carla_get_current_midi_program_index(uint pluginId)
  1206. {
  1207. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, -1);
  1208. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1209. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, -1);
  1210. carla_debug("carla_get_current_midi_program_index(%i)", pluginId);
  1211. return plugin->getCurrentMidiProgram();
  1212. }
  1213. // --------------------------------------------------------------------------------------------------------------------
  1214. float carla_get_default_parameter_value(uint pluginId, uint32_t parameterId)
  1215. {
  1216. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0.0f);
  1217. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1218. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0.0f);
  1219. carla_debug("carla_get_default_parameter_value(%i, %i)", pluginId, parameterId);
  1220. CARLA_SAFE_ASSERT_RETURN(parameterId < plugin->getParameterCount(), 0.0f);
  1221. return plugin->getParameterRanges(parameterId).def;
  1222. }
  1223. float carla_get_current_parameter_value(uint pluginId, uint32_t parameterId)
  1224. {
  1225. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0.0f);
  1226. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1227. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0.0f);
  1228. CARLA_SAFE_ASSERT_RETURN(parameterId < plugin->getParameterCount(), 0.0f);
  1229. return plugin->getParameterValue(parameterId);
  1230. }
  1231. float carla_get_internal_parameter_value(uint pluginId, int32_t parameterId)
  1232. {
  1233. #ifdef BUILD_BRIDGE
  1234. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0.0f);
  1235. #else
  1236. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, (parameterId == CB::PARAMETER_CTRL_CHANNEL) ? -1.0f : 0.0f);
  1237. #endif
  1238. CARLA_SAFE_ASSERT_RETURN(parameterId != CB::PARAMETER_NULL && parameterId > CB::PARAMETER_MAX, 0.0f);
  1239. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1240. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0.0f);
  1241. carla_debug("carla_get_internal_parameter_value(%i, %i)", pluginId, parameterId);
  1242. return plugin->getInternalParameterValue(parameterId);
  1243. }
  1244. // --------------------------------------------------------------------------------------------------------------------
  1245. const float* carla_get_peak_values(uint pluginId)
  1246. {
  1247. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, nullptr);
  1248. return gStandalone.engine->getPeaks(pluginId);
  1249. }
  1250. float carla_get_input_peak_value(uint pluginId, bool isLeft)
  1251. {
  1252. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0.0f);
  1253. return gStandalone.engine->getInputPeak(pluginId, isLeft);
  1254. }
  1255. float carla_get_output_peak_value(uint pluginId, bool isLeft)
  1256. {
  1257. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0.0f);
  1258. return gStandalone.engine->getOutputPeak(pluginId, isLeft);
  1259. }
  1260. // --------------------------------------------------------------------------------------------------------------------
  1261. CARLA_BACKEND_START_NAMESPACE
  1262. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  1263. // defined in CarlaPluginInternal.cpp
  1264. const void* carla_render_inline_display_internal(CarlaPlugin* plugin, uint32_t width, uint32_t height);
  1265. #endif
  1266. // defined in CarlaPluginLV2.cpp
  1267. const void* carla_render_inline_display_lv2(CarlaPlugin* plugin, uint32_t width, uint32_t height);
  1268. CARLA_BACKEND_END_NAMESPACE
  1269. const CarlaInlineDisplayImageSurface* carla_render_inline_display(uint pluginId, uint32_t width, uint32_t height)
  1270. {
  1271. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, nullptr);
  1272. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1273. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, nullptr);
  1274. carla_debug("carla_render_inline_display(%i, %i, %i)", pluginId, width, height);
  1275. switch (plugin->getType())
  1276. {
  1277. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  1278. case CB::PLUGIN_INTERNAL:
  1279. return (const CarlaInlineDisplayImageSurface*)CB::carla_render_inline_display_internal(plugin, width, height);
  1280. #endif
  1281. case CB::PLUGIN_LV2:
  1282. return (const CarlaInlineDisplayImageSurface*)CB::carla_render_inline_display_lv2(plugin, width, height);
  1283. default:
  1284. return nullptr;
  1285. }
  1286. }
  1287. // --------------------------------------------------------------------------------------------------------------------
  1288. void carla_set_active(uint pluginId, bool onOff)
  1289. {
  1290. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1291. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1292. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1293. carla_debug("carla_set_active(%i, %s)", pluginId, bool2str(onOff));
  1294. return plugin->setActive(onOff, true, false);
  1295. }
  1296. #ifndef BUILD_BRIDGE
  1297. void carla_set_drywet(uint pluginId, float value)
  1298. {
  1299. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1300. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1301. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1302. carla_debug("carla_set_drywet(%i, %f)", pluginId, value);
  1303. return plugin->setDryWet(value, true, false);
  1304. }
  1305. void carla_set_volume(uint pluginId, float value)
  1306. {
  1307. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1308. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1309. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1310. carla_debug("carla_set_volume(%i, %f)", pluginId, value);
  1311. return plugin->setVolume(value, true, false);
  1312. }
  1313. void carla_set_balance_left(uint pluginId, float value)
  1314. {
  1315. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1316. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1317. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1318. carla_debug("carla_set_balance_left(%i, %f)", pluginId, value);
  1319. return plugin->setBalanceLeft(value, true, false);
  1320. }
  1321. void carla_set_balance_right(uint pluginId, float value)
  1322. {
  1323. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1324. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1325. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1326. carla_debug("carla_set_balance_right(%i, %f)", pluginId, value);
  1327. return plugin->setBalanceRight(value, true, false);
  1328. }
  1329. void carla_set_panning(uint pluginId, float value)
  1330. {
  1331. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1332. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1333. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1334. carla_debug("carla_set_panning(%i, %f)", pluginId, value);
  1335. return plugin->setPanning(value, true, false);
  1336. }
  1337. void carla_set_ctrl_channel(uint pluginId, int8_t channel)
  1338. {
  1339. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1340. CARLA_SAFE_ASSERT_RETURN(channel >= -1 && channel < MAX_MIDI_CHANNELS,);
  1341. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1342. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1343. carla_debug("carla_set_ctrl_channel(%i, %i)", pluginId, channel);
  1344. return plugin->setCtrlChannel(channel, true, false);
  1345. }
  1346. #endif
  1347. void carla_set_option(uint pluginId, uint option, bool yesNo)
  1348. {
  1349. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1350. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1351. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1352. carla_debug("carla_set_option(%i, %i, %s)", pluginId, option, bool2str(yesNo));
  1353. return plugin->setOption(option, yesNo, false);
  1354. }
  1355. // --------------------------------------------------------------------------------------------------------------------
  1356. void carla_set_parameter_value(uint pluginId, uint32_t parameterId, float value)
  1357. {
  1358. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1359. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1360. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1361. carla_debug("carla_set_parameter_value(%i, %i, %f)", pluginId, parameterId, value);
  1362. CARLA_SAFE_ASSERT_RETURN(parameterId < plugin->getParameterCount(),);
  1363. return plugin->setParameterValue(parameterId, value, true, true, false);
  1364. }
  1365. #ifndef BUILD_BRIDGE
  1366. void carla_set_parameter_midi_channel(uint pluginId, uint32_t parameterId, uint8_t channel)
  1367. {
  1368. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1369. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  1370. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1371. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1372. carla_debug("carla_set_parameter_midi_channel(%i, %i, %i)", pluginId, parameterId, channel);
  1373. CARLA_SAFE_ASSERT_RETURN(parameterId < plugin->getParameterCount(),);
  1374. return plugin->setParameterMidiChannel(parameterId, channel, true, false);
  1375. }
  1376. void carla_set_parameter_midi_cc(uint pluginId, uint32_t parameterId, int16_t cc)
  1377. {
  1378. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1379. CARLA_SAFE_ASSERT_RETURN(cc >= -1 && cc < MAX_MIDI_CONTROL,);
  1380. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1381. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1382. carla_debug("carla_set_parameter_midi_cc(%i, %i, %i)", pluginId, parameterId, cc);
  1383. CARLA_SAFE_ASSERT_RETURN(parameterId < plugin->getParameterCount(),);
  1384. return plugin->setParameterMidiCC(parameterId, cc, true, false);
  1385. }
  1386. void carla_set_parameter_touch(uint pluginId, uint32_t parameterId, bool touch)
  1387. {
  1388. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1389. carla_debug("carla_set_parameter_touch(%i, %i, %s)", pluginId, parameterId, bool2str(touch));
  1390. return gStandalone.engine->touchPluginParameter(pluginId, parameterId, touch);
  1391. }
  1392. #endif
  1393. // --------------------------------------------------------------------------------------------------------------------
  1394. void carla_set_program(uint pluginId, uint32_t programId)
  1395. {
  1396. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1397. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1398. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1399. carla_debug("carla_set_program(%i, %i)", pluginId, programId);
  1400. CARLA_SAFE_ASSERT_RETURN(programId < plugin->getProgramCount(),);
  1401. return plugin->setProgram(static_cast<int32_t>(programId), true, true, false);
  1402. }
  1403. void carla_set_midi_program(uint pluginId, uint32_t midiProgramId)
  1404. {
  1405. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1406. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1407. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1408. carla_debug("carla_set_midi_program(%i, %i)", pluginId, midiProgramId);
  1409. CARLA_SAFE_ASSERT_RETURN(midiProgramId < plugin->getMidiProgramCount(),);
  1410. return plugin->setMidiProgram(static_cast<int32_t>(midiProgramId), true, true, false);
  1411. }
  1412. // --------------------------------------------------------------------------------------------------------------------
  1413. void carla_set_custom_data(uint pluginId, const char* type, const char* key, const char* value)
  1414. {
  1415. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1416. CARLA_SAFE_ASSERT_RETURN(type != nullptr && type[0] != '\0',);
  1417. CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',);
  1418. CARLA_SAFE_ASSERT_RETURN(value != nullptr,);
  1419. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1420. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1421. carla_debug("carla_set_custom_data(%i, \"%s\", \"%s\", \"%s\")", pluginId, type, key, value);
  1422. return plugin->setCustomData(type, key, value, true);
  1423. }
  1424. void carla_set_chunk_data(uint pluginId, const char* chunkData)
  1425. {
  1426. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1427. CARLA_SAFE_ASSERT_RETURN(chunkData != nullptr && chunkData[0] != '\0',);
  1428. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1429. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1430. carla_debug("carla_set_chunk_data(%i, \"%s\")", pluginId, chunkData);
  1431. CARLA_SAFE_ASSERT_RETURN(plugin->getOptionsEnabled() & CB::PLUGIN_OPTION_USE_CHUNKS,);
  1432. std::vector<uint8_t> chunk(carla_getChunkFromBase64String(chunkData));
  1433. #ifdef CARLA_PROPER_CPP11_SUPPORT
  1434. return plugin->setChunkData(chunk.data(), chunk.size());
  1435. #else
  1436. return plugin->setChunkData(&chunk.front(), chunk.size());
  1437. #endif
  1438. }
  1439. // --------------------------------------------------------------------------------------------------------------------
  1440. void carla_prepare_for_save(uint pluginId)
  1441. {
  1442. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1443. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1444. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1445. carla_debug("carla_prepare_for_save(%i)", pluginId);
  1446. return plugin->prepareForSave();
  1447. }
  1448. void carla_reset_parameters(uint pluginId)
  1449. {
  1450. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1451. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1452. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1453. carla_debug("carla_reset_parameters(%i)", pluginId);
  1454. return plugin->resetParameters();
  1455. }
  1456. void carla_randomize_parameters(uint pluginId)
  1457. {
  1458. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1459. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1460. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1461. carla_debug("carla_randomize_parameters(%i)", pluginId);
  1462. return plugin->randomizeParameters();
  1463. }
  1464. #ifndef BUILD_BRIDGE
  1465. void carla_send_midi_note(uint pluginId, uint8_t channel, uint8_t note, uint8_t velocity)
  1466. {
  1467. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr && gStandalone.engine->isRunning(),);
  1468. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1469. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1470. carla_debug("carla_send_midi_note(%i, %i, %i, %i)", pluginId, channel, note, velocity);
  1471. return plugin->sendMidiSingleNote(channel, note, velocity, true, true, false);
  1472. }
  1473. #endif
  1474. void carla_show_custom_ui(uint pluginId, bool yesNo)
  1475. {
  1476. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,);
  1477. CarlaPlugin* const plugin(gStandalone.engine->getPlugin(pluginId));
  1478. CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
  1479. carla_debug("carla_show_custom_ui(%i, %s)", pluginId, bool2str(yesNo));
  1480. return plugin->showCustomUI(yesNo);
  1481. }
  1482. // --------------------------------------------------------------------------------------------------------------------
  1483. uint32_t carla_get_buffer_size()
  1484. {
  1485. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0);
  1486. carla_debug("carla_get_buffer_size()");
  1487. return gStandalone.engine->getBufferSize();
  1488. }
  1489. double carla_get_sample_rate()
  1490. {
  1491. CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0.0);
  1492. carla_debug("carla_get_sample_rate()");
  1493. return gStandalone.engine->getSampleRate();
  1494. }
  1495. // --------------------------------------------------------------------------------------------------------------------
  1496. const char* carla_get_last_error()
  1497. {
  1498. carla_debug("carla_get_last_error()");
  1499. if (gStandalone.engine != nullptr)
  1500. return gStandalone.engine->getLastError();
  1501. return gStandalone.lastError;
  1502. }
  1503. const char* carla_get_host_osc_url_tcp()
  1504. {
  1505. carla_debug("carla_get_host_osc_url_tcp()");
  1506. #if defined(HAVE_LIBLO) && !defined(BUILD_BRIDGE)
  1507. if (gStandalone.engine == nullptr)
  1508. {
  1509. carla_stderr2("carla_get_host_osc_url_tcp() failed, engine is not running");
  1510. gStandalone.lastError = "Engine is not running";
  1511. return gNullCharPtr;
  1512. }
  1513. const char* const path = gStandalone.engine->getOscServerPathTCP();
  1514. if (path != nullptr && path[0] != '\0')
  1515. return path;
  1516. static const char* const notAvailable = "(OSC TCP port not available)";
  1517. return notAvailable;
  1518. #else
  1519. return gNullCharPtr;
  1520. #endif
  1521. }
  1522. const char* carla_get_host_osc_url_udp()
  1523. {
  1524. carla_debug("carla_get_host_osc_url_udp()");
  1525. #if defined(HAVE_LIBLO) && !defined(BUILD_BRIDGE)
  1526. if (gStandalone.engine == nullptr)
  1527. {
  1528. carla_stderr2("carla_get_host_osc_url_udp() failed, engine is not running");
  1529. gStandalone.lastError = "Engine is not running";
  1530. return gNullCharPtr;
  1531. }
  1532. const char* const path = gStandalone.engine->getOscServerPathUDP();
  1533. if (path != nullptr && path[0] != '\0')
  1534. return path;
  1535. static const char* const notAvailable = "(OSC UDP port not available)";
  1536. return notAvailable;
  1537. #else
  1538. return gNullCharPtr;
  1539. #endif
  1540. }
  1541. // --------------------------------------------------------------------------------------------------------------------
  1542. #define CARLA_PLUGIN_UI_CLASS_PREFIX Standalone
  1543. #include "CarlaPluginUI.cpp"
  1544. #undef CARLA_PLUGIN_UI_CLASS_PREFIX
  1545. #include "CarlaDssiUtils.cpp"
  1546. #include "CarlaMacUtils.cpp"
  1547. #include "CarlaPatchbayUtils.cpp"
  1548. #include "CarlaPipeUtils.cpp"
  1549. #include "CarlaStateUtils.cpp"
  1550. // --------------------------------------------------------------------------------------------------------------------