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.

CarlaStandalone.cpp 72KB

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