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.

CarlaEngineNative.cpp 109KB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134
  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2023 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "CarlaDefines.h"
  18. #ifdef BUILD_BRIDGE_ALTERNATIVE_ARCH
  19. # error This file should not be compiled if building alternative-arch bridges
  20. #endif
  21. #ifdef CARLA_OS_WASM
  22. # define CARLA_ENGINE_WITHOUT_UI
  23. #endif
  24. #include "CarlaEngineInit.hpp"
  25. #include "CarlaEngineInternal.hpp"
  26. #include "CarlaPlugin.hpp"
  27. #include "CarlaBackendUtils.hpp"
  28. #include "CarlaBase64Utils.hpp"
  29. #include "CarlaBinaryUtils.hpp"
  30. #include "CarlaMathUtils.hpp"
  31. #include "CarlaStateUtils.hpp"
  32. #include "CarlaExternalUI.hpp"
  33. #include "CarlaHost.h"
  34. #include "CarlaNative.hpp"
  35. #include "CarlaNativePlugin.h"
  36. #include "water/files/File.h"
  37. #include "water/streams/MemoryOutputStream.h"
  38. #include "water/xml/XmlDocument.h"
  39. #include "water/xml/XmlElement.h"
  40. #ifdef USING_JUCE
  41. # include "carla_juce/carla_juce.h"
  42. #endif
  43. using water::File;
  44. using water::MemoryOutputStream;
  45. using water::String;
  46. using water::XmlDocument;
  47. using water::XmlElement;
  48. CARLA_BACKEND_START_NAMESPACE
  49. static const uint32_t kNumInParams = 100;
  50. static const uint32_t kNumOutParams = 10;
  51. static const uint16_t kUiWidth = 1024;
  52. static const uint16_t kUiHeight = 712;
  53. // -----------------------------------------------------------------------
  54. #ifndef CARLA_ENGINE_WITHOUT_UI
  55. class CarlaEngineNative;
  56. class CarlaEngineNativeUI : public CarlaExternalUI
  57. {
  58. public:
  59. CarlaEngineNativeUI(CarlaEngineNative* const engine)
  60. : fEngine(engine)
  61. {
  62. carla_debug("CarlaEngineNativeUI::CarlaEngineNativeUI(%p)", engine);
  63. }
  64. ~CarlaEngineNativeUI() noexcept override
  65. {
  66. carla_debug("CarlaEngineNativeUI::~CarlaEngineNativeUI()");
  67. }
  68. protected:
  69. bool msgReceived(const char* const msg) noexcept override;
  70. private:
  71. CarlaEngineNative* const fEngine;
  72. void _updateParamValues(const CarlaPluginPtr& plugin,
  73. uint32_t pluginId,
  74. bool sendCallback, bool sendPluginHost) const noexcept;
  75. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineNativeUI)
  76. };
  77. #endif
  78. // -----------------------------------------------------------------------
  79. class CarlaEngineNative : public CarlaEngine
  80. {
  81. public:
  82. CarlaEngineNative(const NativeHostDescriptor* const host, const bool isPatchbay, const bool withMidiOut,
  83. const uint32_t inChan = 2, uint32_t outChan = 2,
  84. const uint32_t cvIns = 0, const uint32_t cvOuts = 0)
  85. : CarlaEngine(),
  86. pHost(host),
  87. #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
  88. // if not running inside Carla, we will have to run event loop ourselves
  89. kNeedsJuceEvents(host->dispatcher(pHost->handle,
  90. NATIVE_HOST_OPCODE_INTERNAL_PLUGIN, 0, 0, nullptr, 0.0f) == 0),
  91. fJuceMsgMgr(),
  92. fJuceMsgMutex(),
  93. #endif
  94. kIsPatchbay(isPatchbay),
  95. kHasMidiOut(withMidiOut),
  96. fIsActive(false),
  97. fIsRunning(false),
  98. fUsesEmbed(false),
  99. #ifndef CARLA_ENGINE_WITHOUT_UI
  100. fUiServer(this),
  101. #endif
  102. fLastScaleFactor(1.0f),
  103. fLastProjectFolder(),
  104. fPluginDeleterMutex(),
  105. fOptionsForced(false)
  106. {
  107. carla_debug("CarlaEngineNative::CarlaEngineNative()");
  108. carla_zeroFloats(fParameters, kNumInParams+kNumOutParams);
  109. #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
  110. if (kNeedsJuceEvents)
  111. fJuceMsgMgr.incRef();
  112. #endif
  113. pData->bufferSize = pHost->get_buffer_size(pHost->handle);
  114. pData->sampleRate = pHost->get_sample_rate(pHost->handle);
  115. pData->initTime(nullptr);
  116. #ifndef BUILD_BRIDGE
  117. // Forced OSC setup when running as plugin
  118. pData->options.oscEnabled = true;
  119. pData->options.oscPortTCP = -1;
  120. pData->options.oscPortUDP = 0;
  121. #endif
  122. if (outChan == 0)
  123. outChan = inChan;
  124. // set-up engine
  125. if (kIsPatchbay)
  126. {
  127. pData->options.processMode = ENGINE_PROCESS_MODE_PATCHBAY;
  128. pData->options.transportMode = ENGINE_TRANSPORT_MODE_PLUGIN;
  129. pData->options.forceStereo = false;
  130. pData->options.preferPluginBridges = false;
  131. pData->options.preferUiBridges = false;
  132. init("Carla-Patchbay");
  133. pData->graph.create(inChan, outChan, cvIns, cvOuts);
  134. }
  135. else
  136. {
  137. CARLA_SAFE_ASSERT(inChan == 2);
  138. CARLA_SAFE_ASSERT(outChan == 2);
  139. pData->options.processMode = ENGINE_PROCESS_MODE_CONTINUOUS_RACK;
  140. pData->options.transportMode = ENGINE_TRANSPORT_MODE_PLUGIN;
  141. pData->options.forceStereo = true;
  142. pData->options.preferPluginBridges = false;
  143. pData->options.preferUiBridges = false;
  144. init("Carla-Rack");
  145. pData->graph.create(0, 0, 0, 0); // FIXME?
  146. }
  147. if (pData->options.resourceDir != nullptr)
  148. delete[] pData->options.resourceDir;
  149. if (pData->options.binaryDir != nullptr)
  150. delete[] pData->options.binaryDir;
  151. const water::String binaryDir(File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName());
  152. pData->options.resourceDir = carla_strdup(pHost->resourceDir);
  153. pData->options.binaryDir = carla_strdup(binaryDir.toRawUTF8());
  154. }
  155. ~CarlaEngineNative() override
  156. {
  157. CARLA_SAFE_ASSERT(! fIsActive);
  158. carla_debug("CarlaEngineNative::~CarlaEngineNative() - START");
  159. pData->aboutToClose = true;
  160. fIsRunning = false;
  161. {
  162. #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
  163. const ScopedJuceMessageThreadRunner sjmtr(*this, true);
  164. #endif
  165. removeAllPlugins();
  166. //runPendingRtEvents();
  167. close();
  168. pData->graph.destroy();
  169. }
  170. #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
  171. if (kNeedsJuceEvents)
  172. fJuceMsgMgr.decRef();
  173. #endif
  174. carla_debug("CarlaEngineNative::~CarlaEngineNative() - END");
  175. }
  176. // -------------------------------------
  177. // CarlaEngine virtual calls
  178. bool init(const char* const clientName) override
  179. {
  180. carla_debug("CarlaEngineNative::init(\"%s\")", clientName);
  181. fIsRunning = true;
  182. if (! pData->init(clientName))
  183. {
  184. close();
  185. setLastError("Failed to init internal data");
  186. return false;
  187. }
  188. pData->bufferSize = pHost->get_buffer_size(pHost->handle);
  189. pData->sampleRate = pHost->get_sample_rate(pHost->handle);
  190. return true;
  191. }
  192. bool close() override
  193. {
  194. fIsRunning = false;
  195. CarlaEngine::close();
  196. return true;
  197. }
  198. bool hasIdleOnMainThread() const noexcept override
  199. {
  200. return false;
  201. }
  202. bool isRunning() const noexcept override
  203. {
  204. return fIsRunning;
  205. }
  206. bool isOffline() const noexcept override
  207. {
  208. return pHost->is_offline(pHost->handle);
  209. }
  210. bool usesConstantBufferSize() const noexcept override
  211. {
  212. // TODO LV2 hosts can report this, till then we allow this
  213. return true;
  214. }
  215. EngineType getType() const noexcept override
  216. {
  217. return kEngineTypePlugin;
  218. }
  219. const char* getCurrentDriverName() const noexcept override
  220. {
  221. return "Plugin";
  222. }
  223. const char* getCurrentProjectFolder() const noexcept override
  224. {
  225. CARLA_SAFE_ASSERT_RETURN(pHost != nullptr, nullptr);
  226. static char filetype[] = "carla\0";
  227. try {
  228. return (const char*)(uintptr_t)pHost->dispatcher(pHost->handle,
  229. NATIVE_HOST_OPCODE_GET_FILE_PATH,
  230. 0, 0,
  231. (void*)filetype,
  232. 0.0f);
  233. } CARLA_SAFE_EXCEPTION_RETURN("get_file_path", nullptr);
  234. }
  235. void callback(const bool sendHost, const bool sendOsc,
  236. const EngineCallbackOpcode action, const uint pluginId,
  237. const int value1, const int value2, const int value3,
  238. const float valuef, const char* const valueStr) noexcept override
  239. {
  240. CarlaEngine::callback(sendHost, sendOsc, action, pluginId, value1, value2, value3, valuef, valueStr);
  241. #ifndef CARLA_ENGINE_WITHOUT_UI
  242. if (sendHost)
  243. uiServerCallback(action, pluginId, value1, value2, value3, valuef, valueStr);
  244. #endif
  245. switch (action)
  246. {
  247. case ENGINE_CALLBACK_IDLE:
  248. if (! pData->aboutToClose)
  249. pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_HOST_IDLE, 0, 0, nullptr, 0.0f);
  250. break;
  251. case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  252. if (sendHost && value1 >= 0)
  253. {
  254. uint32_t rindex = static_cast<uint32_t>(value1);
  255. if (_getRealIndexForPluginParameter(pluginId, rindex))
  256. {
  257. fParameters[rindex] = valuef;
  258. if (fUsesEmbed
  259. #ifndef CARLA_ENGINE_WITHOUT_UI
  260. || fUiServer.isPipeRunning()
  261. #endif
  262. )
  263. {
  264. pHost->ui_parameter_changed(pHost->handle, rindex, valuef);
  265. }
  266. else
  267. {
  268. static uint last_pluginId = pluginId;
  269. static int last_value1 = value1;
  270. static bool init = true;
  271. if (init || last_pluginId != pluginId || last_value1 != value1)
  272. {
  273. init = false;
  274. last_pluginId = pluginId;
  275. last_value1 = value1;
  276. carla_stdout("Plugin with id %d triggered parameter %d update while UI is hidden",
  277. pluginId, value1);
  278. }
  279. }
  280. }
  281. }
  282. break;
  283. case ENGINE_CALLBACK_UI_STATE_CHANGED:
  284. if (sendHost && fUsesEmbed)
  285. pHost->ui_closed(pHost->handle);
  286. break;
  287. default:
  288. break;
  289. }
  290. }
  291. const char* runFileCallback(FileCallbackOpcode action,
  292. bool isDir, const char* title, const char* filter) noexcept override
  293. {
  294. switch (action)
  295. {
  296. case FILE_CALLBACK_DEBUG:
  297. return nullptr;
  298. case FILE_CALLBACK_OPEN:
  299. return pHost->ui_open_file(pHost->handle, isDir, title, filter);
  300. case FILE_CALLBACK_SAVE:
  301. return pHost->ui_save_file(pHost->handle, isDir, title, filter);
  302. }
  303. return nullptr;
  304. }
  305. // -------------------------------------------------------------------
  306. void touchPluginParameter(const uint id, const uint32_t parameterId, const bool touch) noexcept override
  307. {
  308. setParameterTouchFromUI(id, parameterId, touch);
  309. }
  310. // -------------------------------------------------------------------
  311. void setParameterValueFromUI(const uint32_t pluginId, const uint32_t index, const float value)
  312. {
  313. uint32_t rindex = index;
  314. if (_getRealIndexForPluginParameter(pluginId, rindex))
  315. {
  316. fParameters[rindex] = value;
  317. pHost->ui_parameter_changed(pHost->handle, rindex, value);
  318. }
  319. }
  320. void setParameterTouchFromUI(const uint32_t pluginId, const uint32_t index, const bool touch)
  321. {
  322. uint32_t rindex = index;
  323. if (_getRealIndexForPluginParameter(pluginId, rindex))
  324. {
  325. pHost->dispatcher(pHost->handle,
  326. NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER,
  327. static_cast<int32_t>(rindex),
  328. touch ? 1 : 0,
  329. nullptr, 0.0f);
  330. }
  331. }
  332. void reloadFromUI()
  333. {
  334. carla_zeroFloats(fParameters, kNumInParams+kNumOutParams);
  335. pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_RELOAD_PARAMETERS, 0, 0, nullptr, 0.0f);
  336. }
  337. protected:
  338. // -------------------------------------------------------------------
  339. void bufferSizeChanged(const uint32_t newBufferSize)
  340. {
  341. if (pData->bufferSize == newBufferSize)
  342. return;
  343. #ifndef CARLA_ENGINE_WITHOUT_UI
  344. {
  345. const CarlaMutexLocker cml(fUiServer.getPipeLock());
  346. if (fUiServer.writeMessage("buffer-size\n"))
  347. {
  348. char tmpBuf[STR_MAX+1];
  349. carla_zeroChars(tmpBuf, STR_MAX+1);
  350. std::snprintf(tmpBuf, STR_MAX, "%i\n", newBufferSize);
  351. if (fUiServer.writeMessage(tmpBuf))
  352. fUiServer.flushMessages();
  353. }
  354. }
  355. #endif
  356. pData->bufferSize = newBufferSize;
  357. CarlaEngine::bufferSizeChanged(newBufferSize);
  358. }
  359. void sampleRateChanged(const double newSampleRate)
  360. {
  361. if (carla_isEqual(pData->sampleRate, newSampleRate))
  362. return;
  363. #ifndef CARLA_ENGINE_WITHOUT_UI
  364. {
  365. const CarlaMutexLocker cml(fUiServer.getPipeLock());
  366. if (fUiServer.writeMessage("sample-rate\n"))
  367. {
  368. char tmpBuf[STR_MAX+1];
  369. carla_zeroChars(tmpBuf, STR_MAX+1);
  370. {
  371. const CarlaScopedLocale csl;
  372. std::snprintf(tmpBuf, STR_MAX, "%.12g\n", newSampleRate);
  373. }
  374. if (fUiServer.writeMessage(tmpBuf))
  375. fUiServer.flushMessages();
  376. }
  377. }
  378. #endif
  379. pData->sampleRate = newSampleRate;
  380. CarlaEngine::sampleRateChanged(newSampleRate);
  381. }
  382. #ifndef CARLA_ENGINE_WITHOUT_UI
  383. // -------------------------------------------------------------------
  384. void uiServerSendPluginInfo(const CarlaPluginPtr& plugin)
  385. {
  386. char tmpBuf[STR_MAX+1];
  387. carla_zeroChars(tmpBuf, STR_MAX+1);
  388. const CarlaMutexLocker cml(fUiServer.getPipeLock());
  389. const uint pluginId(plugin->getId());
  390. std::snprintf(tmpBuf, STR_MAX, "PLUGIN_INFO_%i\n", pluginId);
  391. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  392. std::snprintf(tmpBuf, STR_MAX, "%i:%i:%i:" P_INT64 ":%i:%i\n",
  393. plugin->getType(), plugin->getCategory(),
  394. plugin->getHints(), plugin->getUniqueId(),
  395. plugin->getOptionsAvailable(), plugin->getOptionsEnabled());
  396. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  397. if (const char* const filename = plugin->getFilename())
  398. {
  399. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(filename),);
  400. }
  401. else
  402. {
  403. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  404. }
  405. if (const char* const name = plugin->getName())
  406. {
  407. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(name),);
  408. }
  409. else
  410. {
  411. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  412. }
  413. if (const char* const iconName = plugin->getIconName())
  414. {
  415. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(iconName),);
  416. }
  417. else
  418. {
  419. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  420. }
  421. if (plugin->getRealName(tmpBuf)) {
  422. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
  423. } else {
  424. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  425. }
  426. if (plugin->getLabel(tmpBuf)) {
  427. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
  428. } else {
  429. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  430. }
  431. if (plugin->getMaker(tmpBuf)) {
  432. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
  433. } else {
  434. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  435. }
  436. if (plugin->getCopyright(tmpBuf)) {
  437. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
  438. } else {
  439. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  440. }
  441. std::snprintf(tmpBuf, STR_MAX, "AUDIO_COUNT_%i:%i:%i\n",
  442. pluginId, plugin->getAudioInCount(), plugin->getAudioOutCount());
  443. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  444. std::snprintf(tmpBuf, STR_MAX, "MIDI_COUNT_%i:%i:%i\n",
  445. pluginId, plugin->getMidiInCount(), plugin->getMidiOutCount());
  446. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  447. fUiServer.flushMessages();
  448. }
  449. void uiServerSendPluginParameters(const CarlaPluginPtr& plugin)
  450. {
  451. char tmpBuf[STR_MAX+1];
  452. carla_zeroChars(tmpBuf, STR_MAX+1);
  453. const CarlaMutexLocker cml(fUiServer.getPipeLock());
  454. const CarlaScopedLocale csl;
  455. const uint pluginId(plugin->getId());
  456. for (int32_t i=PARAMETER_ACTIVE; i>PARAMETER_MAX; --i)
  457. {
  458. std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%u:%i\n", pluginId, i);
  459. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  460. std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(plugin->getInternalParameterValue(i)));
  461. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  462. fUiServer.flushMessages();
  463. }
  464. uint32_t ins, outs, count;
  465. plugin->getParameterCountInfo(ins, outs);
  466. count = plugin->getParameterCount();
  467. std::snprintf(tmpBuf, STR_MAX, "PARAMETER_COUNT_%i:%i:%i:%i\n", pluginId, ins, outs, count);
  468. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  469. for (uint32_t i=0; i<count; ++i)
  470. {
  471. const ParameterData& paramData(plugin->getParameterData(i));
  472. const ParameterRanges& paramRanges(plugin->getParameterRanges(i));
  473. std::snprintf(tmpBuf, STR_MAX, "PARAMETER_DATA_%i:%i\n", pluginId, i);
  474. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  475. std::snprintf(tmpBuf, STR_MAX, "%i:%i:%i:%i\n", paramData.type, paramData.hints,
  476. paramData.mappedControlIndex, paramData.midiChannel);
  477. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  478. std::snprintf(tmpBuf, STR_MAX, "%.12g:%.12g\n", static_cast<double>(paramData.mappedMinimum),
  479. static_cast<double>(paramData.mappedMaximum));
  480. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  481. if (plugin->getParameterName(i, tmpBuf)) {
  482. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
  483. } else {
  484. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  485. }
  486. if (plugin->getParameterUnit(i, tmpBuf)) {
  487. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
  488. } else {
  489. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  490. }
  491. if (plugin->getParameterComment(i, tmpBuf)) {
  492. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
  493. } else {
  494. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  495. }
  496. if (plugin->getParameterGroupName(i, tmpBuf)) {
  497. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
  498. } else {
  499. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  500. }
  501. std::snprintf(tmpBuf, STR_MAX, "PARAMETER_RANGES_%i:%i\n", pluginId, i);
  502. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  503. std::snprintf(tmpBuf, STR_MAX, "%.12g:%.12g:%.12g:%.12g:%.12g:%.12g\n",
  504. static_cast<double>(paramRanges.def),
  505. static_cast<double>(paramRanges.min),
  506. static_cast<double>(paramRanges.max),
  507. static_cast<double>(paramRanges.step),
  508. static_cast<double>(paramRanges.stepSmall),
  509. static_cast<double>(paramRanges.stepLarge));
  510. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  511. std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%u:%u\n", pluginId, i);
  512. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  513. std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(plugin->getParameterValue(i)));
  514. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  515. }
  516. fUiServer.flushMessages();
  517. }
  518. void uiServerSendPluginPrograms(const CarlaPluginPtr& plugin)
  519. {
  520. char tmpBuf[STR_MAX+1];
  521. carla_zeroChars(tmpBuf, STR_MAX+1);
  522. const CarlaMutexLocker cml(fUiServer.getPipeLock());
  523. const uint pluginId(plugin->getId());
  524. uint32_t count = plugin->getProgramCount();
  525. std::snprintf(tmpBuf, STR_MAX, "PROGRAM_COUNT_%i:%i:%i\n", pluginId, count, plugin->getCurrentProgram());
  526. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  527. for (uint32_t i=0; i<count; ++i)
  528. {
  529. std::snprintf(tmpBuf, STR_MAX, "PROGRAM_NAME_%i:%i\n", pluginId, i);
  530. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  531. if (plugin->getProgramName(i, tmpBuf)) {
  532. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
  533. } else {
  534. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  535. }
  536. }
  537. fUiServer.flushMessages();
  538. count = plugin->getMidiProgramCount();
  539. std::snprintf(tmpBuf, STR_MAX, "MIDI_PROGRAM_COUNT_%i:%i:%i\n",
  540. pluginId, count, plugin->getCurrentMidiProgram());
  541. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  542. for (uint32_t i=0; i<count; ++i)
  543. {
  544. std::snprintf(tmpBuf, STR_MAX, "MIDI_PROGRAM_DATA_%i:%i\n", pluginId, i);
  545. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  546. const MidiProgramData& mpData(plugin->getMidiProgramData(i));
  547. std::snprintf(tmpBuf, STR_MAX, "%i:%i\n", mpData.bank, mpData.program);
  548. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  549. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(mpData.name),);
  550. }
  551. fUiServer.flushMessages();
  552. }
  553. void uiServerSendPluginProperties(const CarlaPluginPtr& plugin)
  554. {
  555. char tmpBuf[STR_MAX+1];
  556. carla_zeroChars(tmpBuf, STR_MAX+1);
  557. const CarlaMutexLocker cml(fUiServer.getPipeLock());
  558. const uint pluginId(plugin->getId());
  559. uint32_t count = plugin->getCustomDataCount();
  560. std::snprintf(tmpBuf, STR_MAX, "CUSTOM_DATA_COUNT_%i:%i\n", pluginId, count);
  561. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  562. for (uint32_t i=0; i<count; ++i)
  563. {
  564. const CustomData& customData(plugin->getCustomData(i));
  565. CARLA_SAFE_ASSERT_CONTINUE(customData.isValid());
  566. if (std::strcmp(customData.type, CUSTOM_DATA_TYPE_PROPERTY) != 0)
  567. continue;
  568. std::snprintf(tmpBuf, STR_MAX, "CUSTOM_DATA_%i:%i\n", pluginId, i);
  569. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  570. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(customData.type),);
  571. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(customData.key),);
  572. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(customData.value),);
  573. }
  574. fUiServer.flushMessages();
  575. }
  576. void uiServerCallback(const EngineCallbackOpcode action, const uint pluginId,
  577. const int value1, const int value2, const int value3,
  578. const float valuef, const char* const valueStr)
  579. {
  580. if (! fIsRunning)
  581. return;
  582. if (! fUiServer.isPipeRunning())
  583. return;
  584. switch (action)
  585. {
  586. case ENGINE_CALLBACK_UPDATE:
  587. if (const CarlaPluginPtr plugin = getPlugin(pluginId))
  588. {
  589. if (plugin->isEnabled())
  590. {
  591. CARLA_SAFE_ASSERT_BREAK(plugin->getId() == pluginId);
  592. uiServerSendPluginProperties(plugin);
  593. }
  594. }
  595. break;
  596. case ENGINE_CALLBACK_RELOAD_INFO:
  597. if (const CarlaPluginPtr plugin = getPlugin(pluginId))
  598. {
  599. if (plugin->isEnabled())
  600. {
  601. CARLA_SAFE_ASSERT_BREAK(plugin->getId() == pluginId);
  602. uiServerSendPluginInfo(plugin);
  603. }
  604. }
  605. break;
  606. case ENGINE_CALLBACK_RELOAD_PARAMETERS:
  607. if (const CarlaPluginPtr plugin = getPlugin(pluginId))
  608. {
  609. if (plugin->isEnabled())
  610. {
  611. CARLA_SAFE_ASSERT_BREAK(plugin->getId() == pluginId);
  612. uiServerSendPluginParameters(plugin);
  613. }
  614. }
  615. break;
  616. case ENGINE_CALLBACK_RELOAD_PROGRAMS:
  617. if (const CarlaPluginPtr plugin = getPlugin(pluginId))
  618. {
  619. if (plugin->isEnabled())
  620. {
  621. CARLA_SAFE_ASSERT_BREAK(plugin->getId() == pluginId);
  622. uiServerSendPluginPrograms(plugin);
  623. }
  624. }
  625. break;
  626. case ENGINE_CALLBACK_RELOAD_ALL:
  627. case ENGINE_CALLBACK_PLUGIN_ADDED:
  628. case ENGINE_CALLBACK_PLUGIN_RENAMED:
  629. if (const CarlaPluginPtr plugin = getPlugin(pluginId))
  630. {
  631. if (plugin->isEnabled())
  632. {
  633. CARLA_SAFE_ASSERT_BREAK(plugin->getId() == pluginId);
  634. uiServerSendPluginInfo(plugin);
  635. uiServerSendPluginParameters(plugin);
  636. uiServerSendPluginPrograms(plugin);
  637. uiServerSendPluginProperties(plugin);
  638. }
  639. }
  640. break;
  641. default:
  642. break;
  643. }
  644. char tmpBuf[STR_MAX+1];
  645. carla_zeroChars(tmpBuf, STR_MAX+1);
  646. const CarlaMutexLocker cml(fUiServer.getPipeLock());
  647. std::snprintf(tmpBuf, STR_MAX, "ENGINE_CALLBACK_%i\n", int(action));
  648. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  649. std::snprintf(tmpBuf, STR_MAX, "%u\n", pluginId);
  650. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  651. std::snprintf(tmpBuf, STR_MAX, "%i\n", value1);
  652. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  653. std::snprintf(tmpBuf, STR_MAX, "%i\n", value2);
  654. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  655. std::snprintf(tmpBuf, STR_MAX, "%i\n", value3);
  656. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  657. {
  658. const CarlaScopedLocale csl;
  659. std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(valuef));
  660. }
  661. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  662. if (valueStr != nullptr) {
  663. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(valueStr),);
  664. } else {
  665. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
  666. }
  667. fUiServer.flushMessages();
  668. }
  669. void uiServerInfo()
  670. {
  671. CARLA_SAFE_ASSERT_RETURN(fIsRunning,);
  672. CARLA_SAFE_ASSERT_RETURN(fUiServer.isPipeRunning(),);
  673. char tmpBuf[STR_MAX+1];
  674. carla_zeroChars(tmpBuf, STR_MAX+1);
  675. const CarlaMutexLocker cml(fUiServer.getPipeLock());
  676. #if defined(HAVE_LIBLO) && !defined(BUILD_BRIDGE)
  677. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("osc-urls\n"),);
  678. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(pData->osc.getServerPathTCP()),);
  679. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(pData->osc.getServerPathUDP()),);
  680. #endif
  681. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("max-plugin-number\n"),);
  682. std::snprintf(tmpBuf, STR_MAX, "%i\n", pData->maxPluginNumber);
  683. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  684. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("buffer-size\n"),);
  685. std::snprintf(tmpBuf, STR_MAX, "%i\n", pData->bufferSize);
  686. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  687. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("sample-rate\n"),);
  688. {
  689. const CarlaScopedLocale csl;
  690. std::snprintf(tmpBuf, STR_MAX, "%.12g\n", pData->sampleRate);
  691. }
  692. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  693. fUiServer.flushMessages();
  694. }
  695. void uiServerOptions()
  696. {
  697. CARLA_SAFE_ASSERT_RETURN(fIsRunning,);
  698. CARLA_SAFE_ASSERT_RETURN(fUiServer.isPipeRunning(),);
  699. char tmpBuf[STR_MAX+1];
  700. carla_zeroChars(tmpBuf, STR_MAX+1);
  701. const EngineOptions& options(pData->options);
  702. const CarlaMutexLocker cml(fUiServer.getPipeLock());
  703. const char* const optionsForcedStr(fOptionsForced ? "true\n" : "false\n");
  704. const std::size_t optionsForcedStrSize(fOptionsForced ? 5 : 6);
  705. std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PROCESS_MODE);
  706. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  707. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
  708. std::snprintf(tmpBuf, STR_MAX, "%i\n", options.processMode);
  709. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  710. fUiServer.flushMessages();
  711. std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_TRANSPORT_MODE);
  712. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  713. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
  714. std::snprintf(tmpBuf, STR_MAX, "%i\n", options.transportMode);
  715. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  716. fUiServer.flushMessages();
  717. std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_FORCE_STEREO);
  718. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  719. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
  720. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.forceStereo ? "true\n" : "false\n"),);
  721. fUiServer.flushMessages();
  722. std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PREFER_PLUGIN_BRIDGES);
  723. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  724. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
  725. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.preferPluginBridges ? "true\n" : "false\n"),);
  726. fUiServer.flushMessages();
  727. std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PREFER_UI_BRIDGES);
  728. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  729. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
  730. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.preferUiBridges ? "true\n" : "false\n"),);
  731. fUiServer.flushMessages();
  732. std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_UIS_ALWAYS_ON_TOP);
  733. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  734. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
  735. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.uisAlwaysOnTop ? "true\n" : "false\n"),);
  736. fUiServer.flushMessages();
  737. std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_MAX_PARAMETERS);
  738. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  739. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
  740. std::snprintf(tmpBuf, STR_MAX, "%i\n", options.maxParameters);
  741. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  742. fUiServer.flushMessages();
  743. std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_UI_BRIDGES_TIMEOUT);
  744. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  745. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
  746. std::snprintf(tmpBuf, STR_MAX, "%i\n", options.uiBridgesTimeout);
  747. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  748. fUiServer.flushMessages();
  749. std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PATH_BINARIES);
  750. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  751. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("true\n", 5),);
  752. std::snprintf(tmpBuf, STR_MAX, "%s\n", options.binaryDir);
  753. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  754. fUiServer.flushMessages();
  755. std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PATH_RESOURCES);
  756. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  757. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("true\n", 5),);
  758. std::snprintf(tmpBuf, STR_MAX, "%s\n", options.resourceDir);
  759. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  760. fUiServer.flushMessages();
  761. }
  762. #endif
  763. // -------------------------------------------------------------------
  764. // Plugin parameter calls
  765. uint32_t getParameterCount() const
  766. {
  767. return kNumInParams + kNumOutParams;
  768. }
  769. const NativeParameter* getParameterInfo(const uint32_t index) const
  770. {
  771. static NativeParameter param;
  772. static char strBufName[STR_MAX+1];
  773. static char strBufUnit[STR_MAX+1];
  774. static char strBufComment[STR_MAX+1];
  775. static char strBufGroupName[STR_MAX+1];
  776. carla_zeroChars(strBufName, STR_MAX+1);
  777. carla_zeroChars(strBufUnit, STR_MAX+1);
  778. carla_zeroChars(strBufComment, STR_MAX+1);
  779. carla_zeroChars(strBufGroupName, STR_MAX+1);
  780. uint32_t rindex = index;
  781. if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
  782. {
  783. const ParameterData& paramData(plugin->getParameterData(rindex));
  784. const ParameterRanges& paramRanges(plugin->getParameterRanges(rindex));
  785. if (! plugin->getParameterName(rindex, strBufName))
  786. strBufName[0] = '\0';
  787. if (! plugin->getParameterUnit(rindex, strBufUnit))
  788. strBufUnit[0] = '\0';
  789. if (! plugin->getParameterComment(rindex, strBufComment))
  790. strBufComment[0] = '\0';
  791. if (! plugin->getParameterGroupName(rindex, strBufGroupName))
  792. std::snprintf(strBufGroupName, STR_MAX, "%u:%s", plugin->getId(), plugin->getName());
  793. uint hints = 0x0;
  794. if (paramData.hints & PARAMETER_IS_BOOLEAN)
  795. hints |= NATIVE_PARAMETER_IS_BOOLEAN;
  796. if (paramData.hints & PARAMETER_IS_INTEGER)
  797. hints |= NATIVE_PARAMETER_IS_INTEGER;
  798. if (paramData.hints & PARAMETER_IS_LOGARITHMIC)
  799. hints |= NATIVE_PARAMETER_IS_LOGARITHMIC;
  800. if (paramData.hints & PARAMETER_IS_AUTOMATABLE)
  801. hints |= NATIVE_PARAMETER_IS_AUTOMATABLE;
  802. if (paramData.hints & PARAMETER_USES_SAMPLERATE)
  803. hints |= NATIVE_PARAMETER_USES_SAMPLE_RATE;
  804. if (paramData.hints & PARAMETER_USES_SCALEPOINTS)
  805. hints |= NATIVE_PARAMETER_USES_SCALEPOINTS;
  806. if (paramData.type == PARAMETER_INPUT || paramData.type == PARAMETER_OUTPUT)
  807. {
  808. if (paramData.hints & PARAMETER_IS_ENABLED)
  809. hints |= NATIVE_PARAMETER_IS_ENABLED;
  810. if (paramData.type == PARAMETER_OUTPUT)
  811. hints |= NATIVE_PARAMETER_IS_OUTPUT;
  812. }
  813. param.hints = static_cast<NativeParameterHints>(hints);
  814. param.name = strBufName;
  815. param.unit = strBufUnit;
  816. param.comment = strBufComment;
  817. param.groupName = strBufGroupName;
  818. param.ranges.def = paramRanges.def;
  819. param.ranges.min = paramRanges.min;
  820. param.ranges.max = paramRanges.max;
  821. param.ranges.step = paramRanges.step;
  822. param.ranges.stepSmall = paramRanges.stepSmall;
  823. param.ranges.stepLarge = paramRanges.stepLarge;
  824. param.scalePointCount = 0; // TODO
  825. param.scalePoints = nullptr;
  826. return &param;
  827. }
  828. param.hints = index < kNumInParams ? static_cast<NativeParameterHints>(0x0) : NATIVE_PARAMETER_IS_OUTPUT;
  829. param.name = "Unused";
  830. param.unit = "";
  831. param.ranges.def = 0.0f;
  832. param.ranges.min = 0.0f;
  833. param.ranges.max = 1.0f;
  834. param.ranges.step = 0.01f;
  835. param.ranges.stepSmall = 0.001f;
  836. param.ranges.stepLarge = 0.1f;
  837. param.scalePointCount = 0;
  838. param.scalePoints = nullptr;
  839. return &param;
  840. }
  841. float getParameterValue(const uint32_t index) const
  842. {
  843. uint32_t rindex = index;
  844. if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
  845. return plugin->getParameterValue(rindex);
  846. return fParameters[index];
  847. }
  848. // -------------------------------------------------------------------
  849. // Plugin state calls
  850. void setParameterValue(const uint32_t index, const float value)
  851. {
  852. uint32_t rindex = index;
  853. if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
  854. plugin->setParameterValueRT(rindex, value, 0, false);
  855. fParameters[index] = value;
  856. }
  857. // -------------------------------------------------------------------
  858. // Plugin process calls
  859. void activate()
  860. {
  861. #if 0
  862. for (uint i=0; i < pData->curPluginCount; ++i)
  863. {
  864. CarlaPluginPtr plugin = pData->plugins[i].plugin;
  865. if (plugin == nullptr || ! plugin->isEnabled())
  866. continue;
  867. plugin->setActive(true, true, false);
  868. }
  869. #endif
  870. fIsActive = true;
  871. }
  872. void deactivate()
  873. {
  874. fIsActive = false;
  875. #if 0
  876. for (uint i=0; i < pData->curPluginCount; ++i)
  877. {
  878. CarlaPluginPtr plugin = pData->plugins[i].plugin;
  879. if (plugin == nullptr || ! plugin->isEnabled())
  880. continue;
  881. plugin->setActive(false, true, false);
  882. }
  883. #endif
  884. // just in case
  885. //runPendingRtEvents();
  886. }
  887. void process(const float* const* const inBuffer, float** const outBuffer, const uint32_t frames,
  888. const NativeMidiEvent* const midiEvents, const uint32_t midiEventCount)
  889. {
  890. if (frames > pData->bufferSize)
  891. {
  892. carla_stderr2("Host is calling process with too high number of frames! %u vs %u",
  893. frames, pData->bufferSize);
  894. deactivate();
  895. bufferSizeChanged(frames);
  896. activate();
  897. }
  898. const PendingRtEventsRunner prt(this, frames, true);
  899. // ---------------------------------------------------------------
  900. // Time Info
  901. const NativeTimeInfo* const timeInfo(pHost->get_time_info(pHost->handle));
  902. pData->timeInfo.playing = timeInfo->playing;
  903. pData->timeInfo.frame = timeInfo->frame;
  904. pData->timeInfo.usecs = timeInfo->usecs;
  905. pData->timeInfo.bbt.valid = timeInfo->bbt.valid;
  906. if (timeInfo->bbt.valid)
  907. {
  908. pData->timeInfo.bbt.bar = timeInfo->bbt.bar;
  909. pData->timeInfo.bbt.beat = timeInfo->bbt.beat;
  910. pData->timeInfo.bbt.tick = timeInfo->bbt.tick;
  911. pData->timeInfo.bbt.barStartTick = timeInfo->bbt.barStartTick;
  912. pData->timeInfo.bbt.beatsPerBar = timeInfo->bbt.beatsPerBar;
  913. pData->timeInfo.bbt.beatType = timeInfo->bbt.beatType;
  914. pData->timeInfo.bbt.ticksPerBeat = timeInfo->bbt.ticksPerBeat;
  915. pData->timeInfo.bbt.beatsPerMinute = timeInfo->bbt.beatsPerMinute;
  916. }
  917. // ---------------------------------------------------------------
  918. // Do nothing if no plugins and rack mode
  919. if (pData->curPluginCount == 0 && ! kIsPatchbay)
  920. {
  921. if (outBuffer[0] != inBuffer[0])
  922. carla_copyFloats(outBuffer[0], inBuffer[0], frames);
  923. if (outBuffer[1] != inBuffer[1])
  924. carla_copyFloats(outBuffer[1], inBuffer[1], frames);
  925. for (uint32_t i=0; i < midiEventCount; ++i)
  926. {
  927. if (! pHost->write_midi_event(pHost->handle, &midiEvents[i]))
  928. break;
  929. }
  930. return;
  931. }
  932. // ---------------------------------------------------------------
  933. // initialize events
  934. carla_zeroStructs(pData->events.in, kMaxEngineEventInternalCount);
  935. carla_zeroStructs(pData->events.out, kMaxEngineEventInternalCount);
  936. // ---------------------------------------------------------------
  937. // events input (before processing)
  938. {
  939. uint32_t engineEventIndex = 0;
  940. for (uint32_t i=0; i < midiEventCount && engineEventIndex < kMaxEngineEventInternalCount; ++i)
  941. {
  942. const NativeMidiEvent& midiEvent(midiEvents[i]);
  943. EngineEvent& engineEvent(pData->events.in[engineEventIndex++]);
  944. engineEvent.time = midiEvent.time;
  945. engineEvent.fillFromMidiData(midiEvent.size, midiEvent.data, 0);
  946. if (engineEventIndex >= kMaxEngineEventInternalCount)
  947. break;
  948. }
  949. }
  950. if (kIsPatchbay)
  951. {
  952. // -----------------------------------------------------------
  953. // process
  954. pData->graph.process(pData, inBuffer, outBuffer, frames);
  955. }
  956. else
  957. {
  958. // -----------------------------------------------------------
  959. // create audio buffers
  960. const float* inBuf[2] = { inBuffer[0], inBuffer[1] };
  961. /* */ float* outBuf[2] = { outBuffer[0], outBuffer[1] };
  962. // -----------------------------------------------------------
  963. // process
  964. pData->graph.processRack(pData, inBuf, outBuf, frames);
  965. }
  966. // ---------------------------------------------------------------
  967. // events output (after processing)
  968. carla_zeroStructs(pData->events.in, kMaxEngineEventInternalCount);
  969. if (kHasMidiOut)
  970. {
  971. NativeMidiEvent midiEvent;
  972. for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i)
  973. {
  974. const EngineEvent& engineEvent(pData->events.out[i]);
  975. if (engineEvent.type == kEngineEventTypeNull)
  976. break;
  977. carla_zeroStruct(midiEvent);
  978. midiEvent.time = engineEvent.time;
  979. /**/ if (engineEvent.type == kEngineEventTypeControl)
  980. {
  981. midiEvent.port = 0;
  982. midiEvent.size = engineEvent.ctrl.convertToMidiData(engineEvent.channel, midiEvent.data);
  983. }
  984. else if (engineEvent.type == kEngineEventTypeMidi)
  985. {
  986. if (engineEvent.midi.size > 4)
  987. continue;
  988. midiEvent.port = engineEvent.midi.port;
  989. midiEvent.size = engineEvent.midi.size;
  990. midiEvent.data[0] = static_cast<uint8_t>(engineEvent.midi.data[0] | (engineEvent.channel & MIDI_CHANNEL_BIT));
  991. for (uint8_t j=1; j < midiEvent.size; ++j)
  992. midiEvent.data[j] = engineEvent.midi.data[j];
  993. }
  994. else
  995. {
  996. continue;
  997. }
  998. if (midiEvent.size > 0)
  999. pHost->write_midi_event(pHost->handle, &midiEvent);
  1000. }
  1001. }
  1002. }
  1003. // -------------------------------------------------------------------
  1004. // Plugin UI calls
  1005. #ifndef CARLA_ENGINE_WITHOUT_UI
  1006. void uiShow(const bool show)
  1007. {
  1008. if (show)
  1009. {
  1010. if (fUiServer.isPipeRunning())
  1011. {
  1012. fUiServer.writeFocusMessage();
  1013. return;
  1014. }
  1015. CarlaString path(pHost->resourceDir);
  1016. if (kIsPatchbay)
  1017. path += CARLA_OS_SEP_STR "carla-plugin-patchbay";
  1018. else
  1019. path += CARLA_OS_SEP_STR "carla-plugin";
  1020. #ifdef CARLA_OS_WIN
  1021. path += ".exe";
  1022. #endif
  1023. carla_stdout("Trying to start carla-plugin using \"%s\"", path.buffer());
  1024. fUiServer.setData(path, pData->sampleRate, pHost->uiName);
  1025. if (! fUiServer.startPipeServer(false))
  1026. {
  1027. pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_UI_UNAVAILABLE, 0, 0, nullptr, 0.0f);
  1028. return;
  1029. }
  1030. uiServerInfo();
  1031. uiServerOptions();
  1032. uiServerCallback(ENGINE_CALLBACK_ENGINE_STARTED,
  1033. pData->curPluginCount,
  1034. pData->options.processMode,
  1035. pData->options.transportMode,
  1036. static_cast<int>(pData->bufferSize),
  1037. static_cast<float>(pData->sampleRate),
  1038. "Plugin");
  1039. fUiServer.writeShowMessage();
  1040. for (uint i=0; i < pData->curPluginCount; ++i)
  1041. {
  1042. if (const CarlaPluginPtr plugin = pData->plugins[i].plugin)
  1043. if (plugin->isEnabled())
  1044. uiServerCallback(ENGINE_CALLBACK_PLUGIN_ADDED, i, plugin->getType(),
  1045. 0, 0, 0.0f,
  1046. plugin->getName());
  1047. }
  1048. if (kIsPatchbay)
  1049. patchbayRefresh(true, false, false);
  1050. }
  1051. else
  1052. {
  1053. fUiServer.stopPipeServer(2000);
  1054. // hide all custom uis
  1055. for (uint i=0; i < pData->curPluginCount; ++i)
  1056. {
  1057. if (const CarlaPluginPtr plugin = pData->plugins[i].plugin)
  1058. {
  1059. if (plugin->isEnabled())
  1060. {
  1061. if (plugin->getHints() & PLUGIN_HAS_CUSTOM_UI)
  1062. {
  1063. try {
  1064. plugin->showCustomUI(false);
  1065. } CARLA_SAFE_EXCEPTION_CONTINUE("Plugin showCustomUI (hide)");
  1066. }
  1067. }
  1068. }
  1069. }
  1070. }
  1071. }
  1072. #endif
  1073. void uiIdle()
  1074. {
  1075. #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
  1076. const ScopedJuceMessageThreadRunner sjmtr(*this, false);
  1077. if (kNeedsJuceEvents && ! sjmtr.wasLocked)
  1078. return;
  1079. #endif
  1080. for (uint i=0; i < pData->curPluginCount; ++i)
  1081. {
  1082. if (const CarlaPluginPtr plugin = pData->plugins[i].plugin)
  1083. {
  1084. if (plugin->isEnabled())
  1085. {
  1086. const uint hints = plugin->getHints();
  1087. if ((hints & PLUGIN_HAS_CUSTOM_UI) != 0 && (hints & PLUGIN_NEEDS_UI_MAIN_THREAD) != 0)
  1088. {
  1089. try {
  1090. plugin->uiIdle();
  1091. } CARLA_SAFE_EXCEPTION_CONTINUE("Plugin uiIdle");
  1092. }
  1093. }
  1094. }
  1095. }
  1096. #ifndef CARLA_ENGINE_WITHOUT_UI
  1097. idlePipe();
  1098. switch (fUiServer.getAndResetUiState())
  1099. {
  1100. case CarlaExternalUI::UiNone:
  1101. case CarlaExternalUI::UiShow:
  1102. break;
  1103. case CarlaExternalUI::UiCrashed:
  1104. pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_UI_UNAVAILABLE, 0, 0, nullptr, 0.0f);
  1105. break;
  1106. case CarlaExternalUI::UiHide:
  1107. pHost->ui_closed(pHost->handle);
  1108. fUiServer.stopPipeServer(1000);
  1109. break;
  1110. }
  1111. #endif
  1112. if (carla_isNotEqual(fLastScaleFactor, pData->options.uiScale))
  1113. {
  1114. fLastScaleFactor = pData->options.uiScale;
  1115. pHost->dispatcher(pHost->handle,
  1116. NATIVE_HOST_OPCODE_UI_RESIZE,
  1117. static_cast<int>(kUiWidth * fLastScaleFactor + 0.5f),
  1118. static_cast<int>(kUiHeight * fLastScaleFactor + 0.5f),
  1119. nullptr, 0.0f);
  1120. }
  1121. {
  1122. const CarlaMutexLocker cml(fPluginDeleterMutex);
  1123. pData->deletePluginsAsNeeded();
  1124. }
  1125. }
  1126. void uiSetParameterValue(const uint32_t index, const float value)
  1127. {
  1128. uint32_t rindex = index;
  1129. if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
  1130. {
  1131. if (plugin->getHints() & PLUGIN_HAS_CUSTOM_UI)
  1132. plugin->uiParameterChange(rindex, value);
  1133. #ifndef CARLA_ENGINE_WITHOUT_UI
  1134. if (index >= kNumInParams || ! fUiServer.isPipeRunning())
  1135. return;
  1136. uiServerCallback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED,
  1137. plugin->getId(),
  1138. static_cast<int>(rindex),
  1139. 0, 0,
  1140. value,
  1141. nullptr);
  1142. #endif
  1143. }
  1144. }
  1145. #ifndef CARLA_ENGINE_WITHOUT_UI
  1146. void idlePipe()
  1147. {
  1148. if (! fUiServer.isPipeRunning())
  1149. return;
  1150. fUiServer.idlePipe();
  1151. if (! fUiServer.isPipeRunning())
  1152. return;
  1153. char tmpBuf[STR_MAX+1];
  1154. carla_zeroChars(tmpBuf, STR_MAX+1);
  1155. const CarlaMutexLocker cml(fUiServer.getPipeLock());
  1156. const CarlaScopedLocale csl;
  1157. const EngineTimeInfo& timeInfo(pData->timeInfo);
  1158. // ------------------------------------------------------------------------------------------------------------
  1159. // send engine info
  1160. std::snprintf(tmpBuf, STR_MAX, "%.12g:0\n", static_cast<double>(getDSPLoad()));
  1161. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("runtime-info\n"),);
  1162. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  1163. fUiServer.flushMessages();
  1164. if (const char* const projFolder = getCurrentProjectFolder())
  1165. {
  1166. if (fLastProjectFolder != projFolder)
  1167. {
  1168. carla_stdout("Project folder changed to %s", projFolder);
  1169. fLastProjectFolder = projFolder;
  1170. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("project-folder\n"),);
  1171. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(projFolder),);
  1172. fUiServer.flushMessages();
  1173. }
  1174. }
  1175. // ------------------------------------------------------------------------------------------------------------
  1176. // send transport
  1177. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("transport\n"),);
  1178. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(timeInfo.playing ? "true\n" : "false\n"),);
  1179. if (timeInfo.bbt.valid)
  1180. {
  1181. std::snprintf(tmpBuf, STR_MAX, P_UINT64 ":%i:%i:%i\n", timeInfo.frame,
  1182. timeInfo.bbt.bar,
  1183. timeInfo.bbt.beat,
  1184. static_cast<int>(timeInfo.bbt.tick + 0.5));
  1185. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  1186. std::snprintf(tmpBuf, STR_MAX, "%.12g\n", timeInfo.bbt.beatsPerMinute);
  1187. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  1188. }
  1189. else
  1190. {
  1191. std::snprintf(tmpBuf, STR_MAX, P_UINT64 ":0:0:0\n", timeInfo.frame);
  1192. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  1193. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("0.0\n"),);
  1194. }
  1195. fUiServer.flushMessages();
  1196. // ------------------------------------------------------------------------------------------------------------
  1197. // send peaks and param outputs for all plugins
  1198. for (uint i=0; i < pData->curPluginCount; ++i)
  1199. {
  1200. const EnginePluginData& plugData(pData->plugins[i]);
  1201. const CarlaPluginPtr plugin = pData->plugins[i].plugin;
  1202. std::snprintf(tmpBuf, STR_MAX, "PEAKS_%i\n", i);
  1203. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  1204. std::snprintf(tmpBuf, STR_MAX, "%.12g:%.12g:%.12g:%.12g\n",
  1205. static_cast<double>(plugData.peaks[0]),
  1206. static_cast<double>(plugData.peaks[1]),
  1207. static_cast<double>(plugData.peaks[2]),
  1208. static_cast<double>(plugData.peaks[3]));
  1209. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  1210. fUiServer.flushMessages();
  1211. for (uint32_t j=0, count=plugin->getParameterCount(); j < count; ++j)
  1212. {
  1213. if (! plugin->isParameterOutput(j))
  1214. continue;
  1215. std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%u:%u\n", i, j);
  1216. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  1217. std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(plugin->getParameterValue(j)));
  1218. CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
  1219. fUiServer.flushMessages();
  1220. }
  1221. }
  1222. }
  1223. #endif
  1224. // -------------------------------------------------------------------
  1225. // Plugin state calls
  1226. char* getState() const
  1227. {
  1228. MemoryOutputStream out;
  1229. saveProjectInternal(out);
  1230. return strdup(out.toString().toRawUTF8());
  1231. }
  1232. void setState(const char* const data)
  1233. {
  1234. #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
  1235. const ScopedJuceMessageThreadRunner sjmtr(*this, true);
  1236. #endif
  1237. // remove all plugins from UI side
  1238. for (uint i=0, count=pData->curPluginCount; i < count; ++i)
  1239. CarlaEngine::callback(true, true, ENGINE_CALLBACK_PLUGIN_REMOVED, count-i-1, 0, 0, 0, 0.0f, nullptr);
  1240. // remove all plugins from backend, no lock
  1241. fIsRunning = false;
  1242. removeAllPlugins();
  1243. fIsRunning = true;
  1244. {
  1245. const CarlaMutexLocker cml(fPluginDeleterMutex);
  1246. pData->deletePluginsAsNeeded();
  1247. }
  1248. // stopped during removeAllPlugins()
  1249. if (! pData->runner.isRunnerActive())
  1250. pData->runner.start();
  1251. fOptionsForced = true;
  1252. const String state(data);
  1253. XmlDocument xml(state);
  1254. loadProjectInternal(xml, true);
  1255. reloadFromUI();
  1256. }
  1257. // -------------------------------------------------------------------
  1258. public:
  1259. #define handlePtr ((CarlaEngineNative*)handle)
  1260. static NativePluginHandle _instantiateRack(const NativeHostDescriptor* host)
  1261. {
  1262. return new CarlaEngineNative(host, false, true);
  1263. }
  1264. static NativePluginHandle _instantiateRackNoMidiOut(const NativeHostDescriptor* host)
  1265. {
  1266. return new CarlaEngineNative(host, false, false);
  1267. }
  1268. static NativePluginHandle _instantiatePatchbay(const NativeHostDescriptor* host)
  1269. {
  1270. return new CarlaEngineNative(host, true, true);
  1271. }
  1272. static NativePluginHandle _instantiatePatchbay3s(const NativeHostDescriptor* host)
  1273. {
  1274. return new CarlaEngineNative(host, true, true, 3, 2);
  1275. }
  1276. static NativePluginHandle _instantiatePatchbay16(const NativeHostDescriptor* host)
  1277. {
  1278. return new CarlaEngineNative(host, true, true, 16, 16);
  1279. }
  1280. static NativePluginHandle _instantiatePatchbay32(const NativeHostDescriptor* host)
  1281. {
  1282. return new CarlaEngineNative(host, true, true, 32, 32);
  1283. }
  1284. static NativePluginHandle _instantiatePatchbay64(const NativeHostDescriptor* host)
  1285. {
  1286. return new CarlaEngineNative(host, true, true, 64, 64);
  1287. }
  1288. static NativePluginHandle _instantiatePatchbayCV(const NativeHostDescriptor* host)
  1289. {
  1290. return new CarlaEngineNative(host, true, true, 2, 2, 5, 5);
  1291. }
  1292. static NativePluginHandle _instantiatePatchbayCV8(const NativeHostDescriptor* host)
  1293. {
  1294. return new CarlaEngineNative(host, true, true, 2, 2, 8, 8);
  1295. }
  1296. static NativePluginHandle _instantiatePatchbayCV32(const NativeHostDescriptor* host)
  1297. {
  1298. return new CarlaEngineNative(host, true, true, 64, 64, 32, 32);
  1299. }
  1300. static NativePluginHandle _instantiatePatchbayOBS(const NativeHostDescriptor* host)
  1301. {
  1302. return new CarlaEngineNative(host, true, true, 8, 8);
  1303. }
  1304. static void _cleanup(NativePluginHandle handle)
  1305. {
  1306. delete handlePtr;
  1307. }
  1308. static uint32_t _get_parameter_count(NativePluginHandle handle)
  1309. {
  1310. return handlePtr->getParameterCount();
  1311. }
  1312. static const NativeParameter* _get_parameter_info(NativePluginHandle handle, uint32_t index)
  1313. {
  1314. return handlePtr->getParameterInfo(index);
  1315. }
  1316. static float _get_parameter_value(NativePluginHandle handle, uint32_t index)
  1317. {
  1318. return handlePtr->getParameterValue(index);
  1319. }
  1320. static void _set_parameter_value(NativePluginHandle handle, uint32_t index, float value)
  1321. {
  1322. handlePtr->setParameterValue(index, value);
  1323. }
  1324. #ifndef CARLA_ENGINE_WITHOUT_UI
  1325. static void _ui_show(NativePluginHandle handle, bool show)
  1326. {
  1327. handlePtr->uiShow(show);
  1328. }
  1329. #endif
  1330. static void _ui_idle(NativePluginHandle handle)
  1331. {
  1332. handlePtr->uiIdle();
  1333. }
  1334. static void _ui_set_parameter_value(NativePluginHandle handle, uint32_t index, float value)
  1335. {
  1336. handlePtr->uiSetParameterValue(index, value);
  1337. }
  1338. static void _activate(NativePluginHandle handle)
  1339. {
  1340. handlePtr->activate();
  1341. }
  1342. static void _deactivate(NativePluginHandle handle)
  1343. {
  1344. handlePtr->deactivate();
  1345. }
  1346. // FIXME for v3.0, use const for the input buffer
  1347. static void _process(NativePluginHandle handle,
  1348. float** inBuffer, float** outBuffer, const uint32_t frames,
  1349. const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
  1350. {
  1351. handlePtr->process(inBuffer, outBuffer, frames, midiEvents, midiEventCount);
  1352. }
  1353. static char* _get_state(NativePluginHandle handle)
  1354. {
  1355. return handlePtr->getState();
  1356. }
  1357. static void _set_state(NativePluginHandle handle, const char* data)
  1358. {
  1359. handlePtr->setState(data);
  1360. }
  1361. static intptr_t _dispatcher(NativePluginHandle handle,
  1362. NativePluginDispatcherOpcode opcode,
  1363. int32_t index, intptr_t value, void* ptr, float opt)
  1364. {
  1365. switch(opcode)
  1366. {
  1367. case NATIVE_PLUGIN_OPCODE_NULL:
  1368. return 0;
  1369. case NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED:
  1370. CARLA_SAFE_ASSERT_RETURN(value > 0, 0);
  1371. handlePtr->bufferSizeChanged(static_cast<uint32_t>(value));
  1372. return 0;
  1373. case NATIVE_PLUGIN_OPCODE_SAMPLE_RATE_CHANGED:
  1374. CARLA_SAFE_ASSERT_RETURN(opt > 0.0f, 0);
  1375. handlePtr->sampleRateChanged(static_cast<double>(opt));
  1376. return 0;
  1377. case NATIVE_PLUGIN_OPCODE_OFFLINE_CHANGED:
  1378. handlePtr->offlineModeChanged(value != 0);
  1379. return 0;
  1380. case NATIVE_PLUGIN_OPCODE_UI_NAME_CHANGED:
  1381. //handlePtr->uiNameChanged(static_cast<const char*>(ptr));
  1382. return 0;
  1383. case NATIVE_PLUGIN_OPCODE_GET_INTERNAL_HANDLE: {
  1384. CarlaEngineNative* const engine = handlePtr;
  1385. return (intptr_t)(CarlaEngine*)engine;
  1386. }
  1387. case NATIVE_PLUGIN_OPCODE_IDLE:
  1388. //handlePtr->idle();
  1389. return 0;
  1390. case NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT:
  1391. return 0;
  1392. case NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED:
  1393. handlePtr->fUsesEmbed = true;
  1394. return 0;
  1395. case NATIVE_PLUGIN_OPCODE_HOST_OPTION:
  1396. handlePtr->setOption(static_cast<EngineOption>(index), value, static_cast<const char*>(ptr));
  1397. return 0;
  1398. }
  1399. return 0;
  1400. // unused
  1401. (void)index;
  1402. (void)ptr;
  1403. }
  1404. // -------------------------------------------------------------------
  1405. #undef handlePtr
  1406. private:
  1407. const NativeHostDescriptor* const pHost;
  1408. #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
  1409. const bool kNeedsJuceEvents;
  1410. const CarlaJUCE::ReferenceCountedJuceMessageMessager fJuceMsgMgr;
  1411. CarlaMutex fJuceMsgMutex;
  1412. struct ScopedJuceMessageThreadRunner {
  1413. const CarlaMutexTryLocker cmtl;
  1414. const bool wasLocked;
  1415. ScopedJuceMessageThreadRunner(CarlaEngineNative& self, const bool forceLock) noexcept
  1416. : cmtl(self.fJuceMsgMutex, forceLock),
  1417. wasLocked(cmtl.wasLocked())
  1418. {
  1419. if (! self.kNeedsJuceEvents)
  1420. return;
  1421. if (! wasLocked)
  1422. return;
  1423. CarlaJUCE::setMessageManagerForThisThread();
  1424. }
  1425. ~ScopedJuceMessageThreadRunner()
  1426. {
  1427. CarlaJUCE::dispatchMessageManagerMessages();
  1428. }
  1429. CARLA_DECLARE_NON_COPYABLE(ScopedJuceMessageThreadRunner)
  1430. };
  1431. #endif
  1432. const bool kIsPatchbay; // rack if false
  1433. const bool kHasMidiOut;
  1434. bool fIsActive, fIsRunning, fUsesEmbed;
  1435. #ifndef CARLA_ENGINE_WITHOUT_UI
  1436. CarlaEngineNativeUI fUiServer;
  1437. #endif
  1438. float fLastScaleFactor;
  1439. float fParameters[kNumInParams+kNumOutParams];
  1440. CarlaString fLastProjectFolder;
  1441. CarlaMutex fPluginDeleterMutex;
  1442. bool fOptionsForced;
  1443. CarlaPluginPtr _getPluginForParameterIndex(uint32_t& index) const noexcept
  1444. {
  1445. if (pData->curPluginCount == 0 || pData->plugins == nullptr)
  1446. return nullptr;
  1447. for (uint32_t i=0; i<pData->curPluginCount; ++i)
  1448. {
  1449. const CarlaPluginPtr plugin = pData->plugins[i].plugin;
  1450. if (plugin.get() == nullptr || ! plugin->isEnabled())
  1451. break;
  1452. if (const uint32_t paramCount = plugin->getParameterCount())
  1453. {
  1454. if (index >= paramCount)
  1455. {
  1456. index -= paramCount;
  1457. continue;
  1458. }
  1459. return plugin;
  1460. }
  1461. }
  1462. return nullptr;
  1463. }
  1464. bool _getRealIndexForPluginParameter(const uint32_t pluginId, uint32_t& rindex) const noexcept
  1465. {
  1466. if (pData->curPluginCount == 0 || pluginId >= pData->curPluginCount || pData->plugins == nullptr)
  1467. return false;
  1468. for (uint32_t i=0; i<pluginId; ++i)
  1469. {
  1470. const CarlaPluginPtr plugin = pData->plugins[i].plugin;
  1471. if (plugin.get() == nullptr || ! plugin->isEnabled())
  1472. return false;
  1473. rindex += plugin->getParameterCount();
  1474. }
  1475. if (rindex >= kNumInParams)
  1476. return false;
  1477. return true;
  1478. }
  1479. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineNative)
  1480. };
  1481. // -----------------------------------------------------------------------
  1482. #ifndef CARLA_ENGINE_WITHOUT_UI
  1483. bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
  1484. {
  1485. if (CarlaExternalUI::msgReceived(msg))
  1486. return true;
  1487. bool ok = true;
  1488. if (std::strcmp(msg, "set_engine_option") == 0)
  1489. {
  1490. uint32_t option;
  1491. int32_t value;
  1492. const char* valueStr = nullptr;
  1493. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(option), true);
  1494. CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(value), true);
  1495. readNextLineAsString(valueStr, false); // can be null
  1496. try {
  1497. fEngine->setOption(static_cast<EngineOption>(option), value, valueStr);
  1498. } CARLA_SAFE_EXCEPTION("setOption");
  1499. }
  1500. else if (std::strcmp(msg, "clear_engine_xruns") == 0)
  1501. {
  1502. fEngine->clearXruns();
  1503. }
  1504. else if (std::strcmp(msg, "cancel_engine_action") == 0)
  1505. {
  1506. fEngine->setActionCanceled(true);
  1507. }
  1508. else if (std::strcmp(msg, "load_file") == 0)
  1509. {
  1510. const char* filename;
  1511. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);
  1512. try {
  1513. ok = fEngine->loadFile(filename);
  1514. } CARLA_SAFE_EXCEPTION("loadFile");
  1515. fEngine->reloadFromUI();
  1516. }
  1517. else if (std::strcmp(msg, "load_project") == 0)
  1518. {
  1519. const char* filename;
  1520. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);
  1521. try {
  1522. ok = fEngine->loadProject(filename, true);
  1523. } CARLA_SAFE_EXCEPTION("loadProject");
  1524. fEngine->reloadFromUI();
  1525. }
  1526. else if (std::strcmp(msg, "save_project") == 0)
  1527. {
  1528. const char* filename;
  1529. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);
  1530. try {
  1531. ok = fEngine->saveProject(filename, true);
  1532. } CARLA_SAFE_EXCEPTION("saveProject");
  1533. }
  1534. else if (std::strcmp(msg, "clear_project_filename") == 0)
  1535. {
  1536. fEngine->clearCurrentProjectFilename();
  1537. }
  1538. else if (std::strcmp(msg, "patchbay_connect") == 0)
  1539. {
  1540. bool external;
  1541. uint32_t groupA, portA, groupB, portB;
  1542. CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(external), true);
  1543. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(groupA), true);
  1544. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(portA), true);
  1545. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(groupB), true);
  1546. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(portB), true);
  1547. try {
  1548. ok = fEngine->patchbayConnect(external, groupA, portA, groupB, portB);
  1549. } CARLA_SAFE_EXCEPTION("patchbayConnect");
  1550. }
  1551. else if (std::strcmp(msg, "patchbay_disconnect") == 0)
  1552. {
  1553. bool external;
  1554. uint32_t connectionId;
  1555. CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(external), true);
  1556. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(connectionId), true);
  1557. try {
  1558. ok = fEngine->patchbayDisconnect(external, connectionId);
  1559. } CARLA_SAFE_EXCEPTION("patchbayDisconnect");
  1560. }
  1561. else if (std::strcmp(msg, "patchbay_set_group_pos") == 0)
  1562. {
  1563. bool external;
  1564. uint32_t groupId;
  1565. int x1, y1, x2, y2;
  1566. CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(external), true);
  1567. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(groupId), true);
  1568. CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(x1), true);
  1569. CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(y1), true);
  1570. CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(x2), true);
  1571. CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(y2), true);
  1572. try {
  1573. ok = fEngine->patchbaySetGroupPos(false, true, external, groupId, x1, y1, x2, y2);
  1574. } CARLA_SAFE_EXCEPTION("patchbaySetGroupPos");
  1575. }
  1576. else if (std::strcmp(msg, "patchbay_refresh") == 0)
  1577. {
  1578. bool external;
  1579. CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(external), true);
  1580. try {
  1581. ok = fEngine->patchbayRefresh(true, false, external);
  1582. } CARLA_SAFE_EXCEPTION("patchbayRefresh");
  1583. }
  1584. else if (std::strcmp(msg, "transport_play") == 0)
  1585. {
  1586. fEngine->transportPlay();
  1587. }
  1588. else if (std::strcmp(msg, "transport_pause") == 0)
  1589. {
  1590. fEngine->transportPause();
  1591. }
  1592. else if (std::strcmp(msg, "transport_bpm") == 0)
  1593. {
  1594. double bpm;
  1595. CARLA_SAFE_ASSERT_RETURN(readNextLineAsDouble(bpm), true);
  1596. fEngine->transportBPM(bpm);
  1597. }
  1598. else if (std::strcmp(msg, "transport_relocate") == 0)
  1599. {
  1600. uint64_t frame;
  1601. CARLA_SAFE_ASSERT_RETURN(readNextLineAsULong(frame), true);
  1602. fEngine->transportRelocate(frame);
  1603. }
  1604. else if (std::strcmp(msg, "add_plugin") == 0)
  1605. {
  1606. uint32_t btype, ptype;
  1607. const char* filename = nullptr;
  1608. const char* name;
  1609. const char* label;
  1610. int64_t uniqueId;
  1611. uint options;
  1612. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(btype), true);
  1613. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(ptype), true);
  1614. readNextLineAsString(filename, true); // can be null
  1615. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(name, true), true);
  1616. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(label, true), true);
  1617. CARLA_SAFE_ASSERT_RETURN(readNextLineAsLong(uniqueId), true);
  1618. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(options), true);
  1619. if (filename != nullptr && std::strcmp(filename, "(null)") == 0)
  1620. {
  1621. std::free(const_cast<char*>(filename));
  1622. filename = nullptr;
  1623. }
  1624. if (std::strcmp(name, "(null)") == 0)
  1625. {
  1626. std::free(const_cast<char*>(name));
  1627. name = nullptr;
  1628. }
  1629. ok = fEngine->addPlugin(static_cast<BinaryType>(btype), static_cast<PluginType>(ptype),
  1630. filename, name, label, uniqueId, nullptr, options);
  1631. if (filename != nullptr)
  1632. std::free(const_cast<char*>(filename));
  1633. if (name != nullptr)
  1634. std::free(const_cast<char*>(name));
  1635. std::free(const_cast<char*>(label));
  1636. fEngine->reloadFromUI();
  1637. }
  1638. else if (std::strcmp(msg, "remove_plugin") == 0)
  1639. {
  1640. uint32_t pluginId;
  1641. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1642. ok = fEngine->removePlugin(pluginId);
  1643. fEngine->reloadFromUI();
  1644. }
  1645. else if (std::strcmp(msg, "remove_all_plugins") == 0)
  1646. {
  1647. ok = fEngine->removeAllPlugins();
  1648. fEngine->reloadFromUI();
  1649. }
  1650. else if (std::strcmp(msg, "rename_plugin") == 0)
  1651. {
  1652. uint32_t pluginId;
  1653. const char* newName;
  1654. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1655. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(newName, false), true);
  1656. ok = fEngine->renamePlugin(pluginId, newName);
  1657. }
  1658. else if (std::strcmp(msg, "clone_plugin") == 0)
  1659. {
  1660. uint32_t pluginId;
  1661. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1662. ok = fEngine->clonePlugin(pluginId);
  1663. fEngine->reloadFromUI();
  1664. }
  1665. else if (std::strcmp(msg, "replace_plugin") == 0)
  1666. {
  1667. uint32_t pluginId;
  1668. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1669. ok = fEngine->replacePlugin(pluginId);
  1670. }
  1671. else if (std::strcmp(msg, "switch_plugins") == 0)
  1672. {
  1673. uint32_t pluginIdA, pluginIdB;
  1674. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginIdA), true);
  1675. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginIdB), true);
  1676. ok = fEngine->switchPlugins(pluginIdA, pluginIdB);
  1677. fEngine->reloadFromUI();
  1678. }
  1679. else if (std::strcmp(msg, "load_plugin_state") == 0)
  1680. {
  1681. uint32_t pluginId;
  1682. const char* filename;
  1683. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1684. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);
  1685. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1686. {
  1687. plugin->loadStateFromFile(filename);
  1688. _updateParamValues(plugin, pluginId, false, true);
  1689. }
  1690. }
  1691. else if (std::strcmp(msg, "save_plugin_state") == 0)
  1692. {
  1693. uint32_t pluginId;
  1694. const char* filename;
  1695. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1696. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);
  1697. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1698. plugin->saveStateToFile(filename);
  1699. }
  1700. else if (std::strcmp(msg, "set_option") == 0)
  1701. {
  1702. uint32_t pluginId, option;
  1703. bool yesNo;
  1704. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1705. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(option), true);
  1706. CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(yesNo), true);
  1707. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1708. plugin->setOption(option, yesNo, false);
  1709. }
  1710. else if (std::strcmp(msg, "set_active") == 0)
  1711. {
  1712. uint32_t pluginId;
  1713. bool onOff;
  1714. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1715. CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(onOff), true);
  1716. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1717. plugin->setActive(onOff, true, false);
  1718. }
  1719. else if (std::strcmp(msg, "set_drywet") == 0)
  1720. {
  1721. uint32_t pluginId;
  1722. float value;
  1723. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1724. CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
  1725. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1726. plugin->setDryWet(value, true, false);
  1727. }
  1728. else if (std::strcmp(msg, "set_volume") == 0)
  1729. {
  1730. uint32_t pluginId;
  1731. float value;
  1732. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1733. CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
  1734. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1735. plugin->setVolume(value, true, false);
  1736. }
  1737. else if (std::strcmp(msg, "set_balance_left") == 0)
  1738. {
  1739. uint32_t pluginId;
  1740. float value;
  1741. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1742. CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
  1743. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1744. plugin->setBalanceLeft(value, true, false);
  1745. }
  1746. else if (std::strcmp(msg, "set_balance_right") == 0)
  1747. {
  1748. uint32_t pluginId;
  1749. float value;
  1750. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1751. CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
  1752. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1753. plugin->setBalanceRight(value, true, false);
  1754. }
  1755. else if (std::strcmp(msg, "set_panning") == 0)
  1756. {
  1757. uint32_t pluginId;
  1758. float value;
  1759. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1760. CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
  1761. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1762. plugin->setPanning(value, true, false);
  1763. }
  1764. else if (std::strcmp(msg, "set_ctrl_channel") == 0)
  1765. {
  1766. uint32_t pluginId;
  1767. int32_t channel;
  1768. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1769. CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(channel), true);
  1770. CARLA_SAFE_ASSERT_RETURN(channel >= -1 && channel < MAX_MIDI_CHANNELS, true);
  1771. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1772. plugin->setCtrlChannel(int8_t(channel), true, false);
  1773. }
  1774. else if (std::strcmp(msg, "set_parameter_value") == 0)
  1775. {
  1776. uint32_t pluginId, parameterId;
  1777. float value;
  1778. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1779. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId), true);
  1780. CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
  1781. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1782. {
  1783. plugin->setParameterValue(parameterId, value, true, true, false);
  1784. fEngine->setParameterValueFromUI(pluginId, parameterId, value);
  1785. }
  1786. }
  1787. else if (std::strcmp(msg, "set_parameter_midi_channel") == 0)
  1788. {
  1789. uint32_t pluginId, parameterId, channel;
  1790. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1791. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId), true);
  1792. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(channel), true);
  1793. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, true);
  1794. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1795. plugin->setParameterMidiChannel(parameterId, static_cast<uint8_t>(channel), true, false);
  1796. }
  1797. else if (std::strcmp(msg, "set_parameter_mapped_control_index") == 0)
  1798. {
  1799. uint32_t pluginId, parameterId;
  1800. int32_t ctrl;
  1801. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1802. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId), true);
  1803. CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(ctrl), true);
  1804. CARLA_SAFE_ASSERT_RETURN(ctrl >= CONTROL_INDEX_NONE && ctrl <= CONTROL_INDEX_MAX_ALLOWED, true);
  1805. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1806. plugin->setParameterMappedControlIndex(parameterId, static_cast<int16_t>(ctrl), true, false, true);
  1807. }
  1808. else if (std::strcmp(msg, "set_parameter_mapped_range") == 0)
  1809. {
  1810. uint32_t pluginId, parameterId;
  1811. float minimum, maximum;
  1812. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1813. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId), true);
  1814. CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(minimum), true);
  1815. CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(maximum), true);
  1816. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1817. plugin->setParameterMappedRange(parameterId, minimum, maximum, true, false);
  1818. }
  1819. else if (std::strcmp(msg, "set_parameter_touch") == 0)
  1820. {
  1821. uint32_t pluginId, parameterId;
  1822. bool touching;
  1823. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1824. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId), true);
  1825. CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(touching), true);
  1826. if (fEngine->getPlugin(pluginId))
  1827. fEngine->setParameterTouchFromUI(pluginId, parameterId, touching);
  1828. }
  1829. else if (std::strcmp(msg, "set_program") == 0)
  1830. {
  1831. uint32_t pluginId;
  1832. int32_t index;
  1833. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1834. CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(index), true);
  1835. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1836. {
  1837. plugin->setProgram(index, true, true, false);
  1838. _updateParamValues(plugin, pluginId, true, true);
  1839. }
  1840. }
  1841. else if (std::strcmp(msg, "set_midi_program") == 0)
  1842. {
  1843. uint32_t pluginId;
  1844. int32_t index;
  1845. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1846. CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(index), true);
  1847. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1848. {
  1849. plugin->setMidiProgram(index, true, true, false);
  1850. _updateParamValues(plugin, pluginId, true, true);
  1851. }
  1852. }
  1853. else if (std::strcmp(msg, "set_custom_data") == 0)
  1854. {
  1855. uint32_t pluginId;
  1856. const char* type;
  1857. const char* key;
  1858. const char* value;
  1859. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1860. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(type, true), true);
  1861. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(key, true), true);
  1862. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(value, false), true);
  1863. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1864. plugin->setCustomData(type, key, value, true);
  1865. std::free(const_cast<char*>(type));
  1866. std::free(const_cast<char*>(key));
  1867. }
  1868. else if (std::strcmp(msg, "set_chunk_data") == 0)
  1869. {
  1870. uint32_t pluginId;
  1871. const char* cdata;
  1872. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1873. CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(cdata, false), true);
  1874. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1875. {
  1876. std::vector<uint8_t> chunk(carla_getChunkFromBase64String(cdata));
  1877. #ifdef CARLA_PROPER_CPP11_SUPPORT
  1878. plugin->setChunkData(chunk.data(), chunk.size());
  1879. #else
  1880. plugin->setChunkData(&chunk.front(), chunk.size());
  1881. #endif
  1882. _updateParamValues(plugin, pluginId, false, true);
  1883. }
  1884. }
  1885. else if (std::strcmp(msg, "prepare_for_save") == 0)
  1886. {
  1887. uint32_t pluginId;
  1888. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1889. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1890. plugin->prepareForSave(false);
  1891. }
  1892. else if (std::strcmp(msg, "reset_parameters") == 0)
  1893. {
  1894. uint32_t pluginId;
  1895. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1896. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1897. {
  1898. plugin->resetParameters();
  1899. _updateParamValues(plugin, pluginId, false, true);
  1900. }
  1901. }
  1902. else if (std::strcmp(msg, "randomize_parameters") == 0)
  1903. {
  1904. uint32_t pluginId;
  1905. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1906. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1907. {
  1908. plugin->randomizeParameters();
  1909. _updateParamValues(plugin, pluginId, false, true);
  1910. }
  1911. }
  1912. else if (std::strcmp(msg, "send_midi_note") == 0)
  1913. {
  1914. uint32_t pluginId, channel, note, velocity;
  1915. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1916. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(channel), true);
  1917. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(note), true);
  1918. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(velocity), true);
  1919. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, true);
  1920. CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_VALUE, true);
  1921. CARLA_SAFE_ASSERT_RETURN(velocity < MAX_MIDI_VALUE, true);
  1922. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1923. plugin->sendMidiSingleNote(static_cast<uint8_t>(channel), static_cast<uint8_t>(note), static_cast<uint8_t>(velocity), true, true, false);
  1924. }
  1925. else if (std::strcmp(msg, "show_custom_ui") == 0)
  1926. {
  1927. uint32_t pluginId;
  1928. bool yesNo;
  1929. CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
  1930. CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(yesNo), true);
  1931. if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
  1932. plugin->showCustomUI(yesNo);
  1933. }
  1934. else
  1935. {
  1936. carla_stderr("CarlaEngineNativeUI::msgReceived : %s", msg);
  1937. return false;
  1938. }
  1939. if (! ok)
  1940. {
  1941. const CarlaMutexLocker cml(getPipeLock());
  1942. if (writeMessage("error\n", 6) && writeAndFixMessage(fEngine->getLastError()))
  1943. flushMessages();
  1944. }
  1945. return true;
  1946. }
  1947. void CarlaEngineNativeUI::_updateParamValues(const CarlaPluginPtr& plugin,
  1948. const uint32_t pluginId,
  1949. const bool sendCallback, const bool sendPluginHost) const noexcept
  1950. {
  1951. float value;
  1952. for (uint32_t i=0, count=plugin->getParameterCount(); i<count; ++i) {
  1953. value = plugin->getParameterValue(i);
  1954. if (sendCallback) {
  1955. fEngine->callback(true, true,
  1956. ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED,
  1957. pluginId,
  1958. static_cast<int>(i),
  1959. 0, 0,
  1960. value,
  1961. nullptr);
  1962. }
  1963. if (sendPluginHost) {
  1964. carla_stdout("_updateParamValues");
  1965. fEngine->setParameterValueFromUI(pluginId, i, value);
  1966. }
  1967. }
  1968. }
  1969. #endif
  1970. // -----------------------------------------------------------------------
  1971. static const NativePluginDescriptor carlaRackDesc = {
  1972. /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
  1973. /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
  1974. |NATIVE_PLUGIN_HAS_UI
  1975. |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
  1976. |NATIVE_PLUGIN_USES_STATE
  1977. |NATIVE_PLUGIN_USES_TIME
  1978. |NATIVE_PLUGIN_USES_UI_SIZE),
  1979. /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
  1980. /* audioIns */ 2,
  1981. /* audioOuts */ 2,
  1982. /* midiIns */ 1,
  1983. /* midiOuts */ 1,
  1984. /* paramIns */ kNumInParams,
  1985. /* paramOuts */ kNumOutParams,
  1986. /* name */ "Carla-Rack",
  1987. /* label */ "carlarack",
  1988. /* maker */ "falkTX",
  1989. /* copyright */ "GNU GPL v2+",
  1990. CarlaEngineNative::_instantiateRack,
  1991. CarlaEngineNative::_cleanup,
  1992. CarlaEngineNative::_get_parameter_count,
  1993. CarlaEngineNative::_get_parameter_info,
  1994. CarlaEngineNative::_get_parameter_value,
  1995. /* _get_midi_program_count */ nullptr,
  1996. /* _get_midi_program_info */ nullptr,
  1997. CarlaEngineNative::_set_parameter_value,
  1998. /* _set_midi_program */ nullptr,
  1999. /* _set_custom_data */ nullptr,
  2000. #ifndef CARLA_ENGINE_WITHOUT_UI
  2001. CarlaEngineNative::_ui_show,
  2002. #else
  2003. nullptr,
  2004. #endif
  2005. CarlaEngineNative::_ui_idle,
  2006. CarlaEngineNative::_ui_set_parameter_value,
  2007. /* _ui_set_midi_program */ nullptr,
  2008. /* _ui_set_custom_data */ nullptr,
  2009. CarlaEngineNative::_activate,
  2010. CarlaEngineNative::_deactivate,
  2011. CarlaEngineNative::_process,
  2012. CarlaEngineNative::_get_state,
  2013. CarlaEngineNative::_set_state,
  2014. CarlaEngineNative::_dispatcher,
  2015. /* _render_inline_dsplay */ nullptr,
  2016. /* cvIns */ 0,
  2017. /* cvOuts */ 0,
  2018. /* _get_buffer_port_name */ nullptr,
  2019. /* _get_buffer_port_range */ nullptr,
  2020. /* ui_width */ kUiWidth,
  2021. /* ui_height */ kUiHeight
  2022. };
  2023. static const NativePluginDescriptor carlaRackNoMidiOutDesc = {
  2024. /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
  2025. /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
  2026. |NATIVE_PLUGIN_HAS_UI
  2027. |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
  2028. |NATIVE_PLUGIN_USES_STATE
  2029. |NATIVE_PLUGIN_USES_TIME
  2030. |NATIVE_PLUGIN_USES_UI_SIZE),
  2031. /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
  2032. /* audioIns */ 2,
  2033. /* audioOuts */ 2,
  2034. /* midiIns */ 1,
  2035. /* midiOuts */ 0,
  2036. /* paramIns */ kNumInParams,
  2037. /* paramOuts */ kNumOutParams,
  2038. /* name */ "Carla-Rack (no midi out)",
  2039. /* label */ "carlarack-nomidiout",
  2040. /* maker */ "falkTX",
  2041. /* copyright */ "GNU GPL v2+",
  2042. CarlaEngineNative::_instantiateRackNoMidiOut,
  2043. CarlaEngineNative::_cleanup,
  2044. CarlaEngineNative::_get_parameter_count,
  2045. CarlaEngineNative::_get_parameter_info,
  2046. CarlaEngineNative::_get_parameter_value,
  2047. /* _get_midi_program_count */ nullptr,
  2048. /* _get_midi_program_info */ nullptr,
  2049. CarlaEngineNative::_set_parameter_value,
  2050. /* _set_midi_program */ nullptr,
  2051. /* _set_custom_data */ nullptr,
  2052. #ifndef CARLA_ENGINE_WITHOUT_UI
  2053. CarlaEngineNative::_ui_show,
  2054. #else
  2055. nullptr,
  2056. #endif
  2057. CarlaEngineNative::_ui_idle,
  2058. CarlaEngineNative::_ui_set_parameter_value,
  2059. /* _ui_set_midi_program */ nullptr,
  2060. /* _ui_set_custom_data */ nullptr,
  2061. CarlaEngineNative::_activate,
  2062. CarlaEngineNative::_deactivate,
  2063. CarlaEngineNative::_process,
  2064. CarlaEngineNative::_get_state,
  2065. CarlaEngineNative::_set_state,
  2066. CarlaEngineNative::_dispatcher,
  2067. /* _render_inline_dsplay */ nullptr,
  2068. /* cvIns */ 0,
  2069. /* cvOuts */ 0,
  2070. /* _get_buffer_port_name */ nullptr,
  2071. /* _get_buffer_port_range */ nullptr,
  2072. /* ui_width */ kUiWidth,
  2073. /* ui_height */ kUiHeight
  2074. };
  2075. static const NativePluginDescriptor carlaPatchbayDesc = {
  2076. /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
  2077. /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
  2078. |NATIVE_PLUGIN_HAS_UI
  2079. |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
  2080. |NATIVE_PLUGIN_USES_STATE
  2081. |NATIVE_PLUGIN_USES_TIME
  2082. |NATIVE_PLUGIN_USES_UI_SIZE),
  2083. /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
  2084. /* audioIns */ 2,
  2085. /* audioOuts */ 2,
  2086. /* midiIns */ 1,
  2087. /* midiOuts */ 1,
  2088. /* paramIns */ kNumInParams,
  2089. /* paramOuts */ kNumOutParams,
  2090. /* name */ "Carla-Patchbay",
  2091. /* label */ "carlapatchbay",
  2092. /* maker */ "falkTX",
  2093. /* copyright */ "GNU GPL v2+",
  2094. CarlaEngineNative::_instantiatePatchbay,
  2095. CarlaEngineNative::_cleanup,
  2096. CarlaEngineNative::_get_parameter_count,
  2097. CarlaEngineNative::_get_parameter_info,
  2098. CarlaEngineNative::_get_parameter_value,
  2099. /* _get_midi_program_count */ nullptr,
  2100. /* _get_midi_program_info */ nullptr,
  2101. CarlaEngineNative::_set_parameter_value,
  2102. /* _set_midi_program */ nullptr,
  2103. /* _set_custom_data */ nullptr,
  2104. #ifndef CARLA_ENGINE_WITHOUT_UI
  2105. CarlaEngineNative::_ui_show,
  2106. #else
  2107. nullptr,
  2108. #endif
  2109. CarlaEngineNative::_ui_idle,
  2110. CarlaEngineNative::_ui_set_parameter_value,
  2111. /* _ui_set_midi_program */ nullptr,
  2112. /* _ui_set_custom_data */ nullptr,
  2113. CarlaEngineNative::_activate,
  2114. CarlaEngineNative::_deactivate,
  2115. CarlaEngineNative::_process,
  2116. CarlaEngineNative::_get_state,
  2117. CarlaEngineNative::_set_state,
  2118. CarlaEngineNative::_dispatcher,
  2119. /* _render_inline_dsplay */ nullptr,
  2120. /* cvIns */ 0,
  2121. /* cvOuts */ 0,
  2122. /* _get_buffer_port_name */ nullptr,
  2123. /* _get_buffer_port_range */ nullptr,
  2124. /* ui_width */ kUiWidth,
  2125. /* ui_height */ kUiHeight
  2126. };
  2127. static const NativePluginDescriptor carlaPatchbay3sDesc = {
  2128. /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
  2129. /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
  2130. |NATIVE_PLUGIN_HAS_UI
  2131. |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
  2132. |NATIVE_PLUGIN_USES_STATE
  2133. |NATIVE_PLUGIN_USES_TIME
  2134. |NATIVE_PLUGIN_USES_UI_SIZE),
  2135. /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
  2136. /* audioIns */ 3,
  2137. /* audioOuts */ 2,
  2138. /* midiIns */ 1,
  2139. /* midiOuts */ 1,
  2140. /* paramIns */ kNumInParams,
  2141. /* paramOuts */ kNumOutParams,
  2142. /* name */ "Carla-Patchbay (sidechain)",
  2143. /* label */ "carlapatchbay3s",
  2144. /* maker */ "falkTX",
  2145. /* copyright */ "GNU GPL v2+",
  2146. CarlaEngineNative::_instantiatePatchbay3s,
  2147. CarlaEngineNative::_cleanup,
  2148. CarlaEngineNative::_get_parameter_count,
  2149. CarlaEngineNative::_get_parameter_info,
  2150. CarlaEngineNative::_get_parameter_value,
  2151. /* _get_midi_program_count */ nullptr,
  2152. /* _get_midi_program_info */ nullptr,
  2153. CarlaEngineNative::_set_parameter_value,
  2154. /* _set_midi_program */ nullptr,
  2155. /* _set_custom_data */ nullptr,
  2156. #ifndef CARLA_ENGINE_WITHOUT_UI
  2157. CarlaEngineNative::_ui_show,
  2158. #else
  2159. nullptr,
  2160. #endif
  2161. CarlaEngineNative::_ui_idle,
  2162. CarlaEngineNative::_ui_set_parameter_value,
  2163. /* _ui_set_midi_program */ nullptr,
  2164. /* _ui_set_custom_data */ nullptr,
  2165. CarlaEngineNative::_activate,
  2166. CarlaEngineNative::_deactivate,
  2167. CarlaEngineNative::_process,
  2168. CarlaEngineNative::_get_state,
  2169. CarlaEngineNative::_set_state,
  2170. CarlaEngineNative::_dispatcher,
  2171. /* _render_inline_dsplay */ nullptr,
  2172. /* cvIns */ 0,
  2173. /* cvOuts */ 0,
  2174. /* _get_buffer_port_name */ nullptr,
  2175. /* _get_buffer_port_range */ nullptr,
  2176. /* ui_width */ kUiWidth,
  2177. /* ui_height */ kUiHeight
  2178. };
  2179. static const NativePluginDescriptor carlaPatchbay16Desc = {
  2180. /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
  2181. /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
  2182. |NATIVE_PLUGIN_HAS_UI
  2183. |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
  2184. |NATIVE_PLUGIN_USES_STATE
  2185. |NATIVE_PLUGIN_USES_TIME
  2186. |NATIVE_PLUGIN_USES_UI_SIZE),
  2187. /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
  2188. /* audioIns */ 16,
  2189. /* audioOuts */ 16,
  2190. /* midiIns */ 1,
  2191. /* midiOuts */ 1,
  2192. /* paramIns */ kNumInParams,
  2193. /* paramOuts */ kNumOutParams,
  2194. /* name */ "Carla-Patchbay (16chan)",
  2195. /* label */ "carlapatchbay16",
  2196. /* maker */ "falkTX",
  2197. /* copyright */ "GNU GPL v2+",
  2198. CarlaEngineNative::_instantiatePatchbay16,
  2199. CarlaEngineNative::_cleanup,
  2200. CarlaEngineNative::_get_parameter_count,
  2201. CarlaEngineNative::_get_parameter_info,
  2202. CarlaEngineNative::_get_parameter_value,
  2203. /* _get_midi_program_count */ nullptr,
  2204. /* _get_midi_program_info */ nullptr,
  2205. CarlaEngineNative::_set_parameter_value,
  2206. /* _set_midi_program */ nullptr,
  2207. /* _set_custom_data */ nullptr,
  2208. #ifndef CARLA_ENGINE_WITHOUT_UI
  2209. CarlaEngineNative::_ui_show,
  2210. #else
  2211. nullptr,
  2212. #endif
  2213. CarlaEngineNative::_ui_idle,
  2214. CarlaEngineNative::_ui_set_parameter_value,
  2215. /* _ui_set_midi_program */ nullptr,
  2216. /* _ui_set_custom_data */ nullptr,
  2217. CarlaEngineNative::_activate,
  2218. CarlaEngineNative::_deactivate,
  2219. CarlaEngineNative::_process,
  2220. CarlaEngineNative::_get_state,
  2221. CarlaEngineNative::_set_state,
  2222. CarlaEngineNative::_dispatcher,
  2223. /* _render_inline_dsplay */ nullptr,
  2224. /* cvIns */ 0,
  2225. /* cvOuts */ 0,
  2226. /* _get_buffer_port_name */ nullptr,
  2227. /* _get_buffer_port_range */ nullptr,
  2228. /* ui_width */ kUiWidth,
  2229. /* ui_height */ kUiHeight
  2230. };
  2231. static const NativePluginDescriptor carlaPatchbay32Desc = {
  2232. /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
  2233. /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
  2234. |NATIVE_PLUGIN_HAS_UI
  2235. |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
  2236. |NATIVE_PLUGIN_USES_STATE
  2237. |NATIVE_PLUGIN_USES_TIME
  2238. |NATIVE_PLUGIN_USES_UI_SIZE),
  2239. /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
  2240. /* audioIns */ 32,
  2241. /* audioOuts */ 32,
  2242. /* midiIns */ 1,
  2243. /* midiOuts */ 1,
  2244. /* paramIns */ kNumInParams,
  2245. /* paramOuts */ kNumOutParams,
  2246. /* name */ "Carla-Patchbay (32chan)",
  2247. /* label */ "carlapatchbay32",
  2248. /* maker */ "falkTX",
  2249. /* copyright */ "GNU GPL v2+",
  2250. CarlaEngineNative::_instantiatePatchbay32,
  2251. CarlaEngineNative::_cleanup,
  2252. CarlaEngineNative::_get_parameter_count,
  2253. CarlaEngineNative::_get_parameter_info,
  2254. CarlaEngineNative::_get_parameter_value,
  2255. /* _get_midi_program_count */ nullptr,
  2256. /* _get_midi_program_info */ nullptr,
  2257. CarlaEngineNative::_set_parameter_value,
  2258. /* _set_midi_program */ nullptr,
  2259. /* _set_custom_data */ nullptr,
  2260. #ifndef CARLA_ENGINE_WITHOUT_UI
  2261. CarlaEngineNative::_ui_show,
  2262. #else
  2263. nullptr,
  2264. #endif
  2265. CarlaEngineNative::_ui_idle,
  2266. CarlaEngineNative::_ui_set_parameter_value,
  2267. /* _ui_set_midi_program */ nullptr,
  2268. /* _ui_set_custom_data */ nullptr,
  2269. CarlaEngineNative::_activate,
  2270. CarlaEngineNative::_deactivate,
  2271. CarlaEngineNative::_process,
  2272. CarlaEngineNative::_get_state,
  2273. CarlaEngineNative::_set_state,
  2274. CarlaEngineNative::_dispatcher,
  2275. /* _render_inline_dsplay */ nullptr,
  2276. /* cvIns */ 0,
  2277. /* cvOuts */ 0,
  2278. /* _get_buffer_port_name */ nullptr,
  2279. /* _get_buffer_port_range */ nullptr,
  2280. /* ui_width */ kUiWidth,
  2281. /* ui_height */ kUiHeight
  2282. };
  2283. static const NativePluginDescriptor carlaPatchbay64Desc = {
  2284. /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
  2285. /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
  2286. |NATIVE_PLUGIN_HAS_UI
  2287. |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
  2288. |NATIVE_PLUGIN_USES_STATE
  2289. |NATIVE_PLUGIN_USES_TIME
  2290. |NATIVE_PLUGIN_USES_UI_SIZE),
  2291. /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
  2292. /* audioIns */ 64,
  2293. /* audioOuts */ 64,
  2294. /* midiIns */ 1,
  2295. /* midiOuts */ 1,
  2296. /* paramIns */ kNumInParams,
  2297. /* paramOuts */ kNumOutParams,
  2298. /* name */ "Carla-Patchbay (64chan)",
  2299. /* label */ "carlapatchbay64",
  2300. /* maker */ "falkTX",
  2301. /* copyright */ "GNU GPL v2+",
  2302. CarlaEngineNative::_instantiatePatchbay64,
  2303. CarlaEngineNative::_cleanup,
  2304. CarlaEngineNative::_get_parameter_count,
  2305. CarlaEngineNative::_get_parameter_info,
  2306. CarlaEngineNative::_get_parameter_value,
  2307. /* _get_midi_program_count */ nullptr,
  2308. /* _get_midi_program_info */ nullptr,
  2309. CarlaEngineNative::_set_parameter_value,
  2310. /* _set_midi_program */ nullptr,
  2311. /* _set_custom_data */ nullptr,
  2312. #ifndef CARLA_ENGINE_WITHOUT_UI
  2313. CarlaEngineNative::_ui_show,
  2314. #else
  2315. nullptr,
  2316. #endif
  2317. CarlaEngineNative::_ui_idle,
  2318. CarlaEngineNative::_ui_set_parameter_value,
  2319. /* _ui_set_midi_program */ nullptr,
  2320. /* _ui_set_custom_data */ nullptr,
  2321. CarlaEngineNative::_activate,
  2322. CarlaEngineNative::_deactivate,
  2323. CarlaEngineNative::_process,
  2324. CarlaEngineNative::_get_state,
  2325. CarlaEngineNative::_set_state,
  2326. CarlaEngineNative::_dispatcher,
  2327. /* _render_inline_dsplay */ nullptr,
  2328. /* cvIns */ 0,
  2329. /* cvOuts */ 0,
  2330. /* _get_buffer_port_name */ nullptr,
  2331. /* _get_buffer_port_range */ nullptr,
  2332. /* ui_width */ kUiWidth,
  2333. /* ui_height */ kUiHeight
  2334. };
  2335. static const NativePluginDescriptor carlaPatchbayCVDesc = {
  2336. /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
  2337. /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
  2338. |NATIVE_PLUGIN_HAS_UI
  2339. |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
  2340. |NATIVE_PLUGIN_USES_CONTROL_VOLTAGE
  2341. |NATIVE_PLUGIN_USES_STATE
  2342. |NATIVE_PLUGIN_USES_TIME
  2343. |NATIVE_PLUGIN_USES_UI_SIZE),
  2344. /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
  2345. /* audioIns */ 2,
  2346. /* audioOuts */ 2,
  2347. /* midiIns */ 1,
  2348. /* midiOuts */ 1,
  2349. /* paramIns */ kNumInParams,
  2350. /* paramOuts */ kNumOutParams,
  2351. /* name */ "Carla-Patchbay (CV)",
  2352. /* label */ "carlapatchbaycv",
  2353. /* maker */ "falkTX",
  2354. /* copyright */ "GNU GPL v2+",
  2355. CarlaEngineNative::_instantiatePatchbayCV,
  2356. CarlaEngineNative::_cleanup,
  2357. CarlaEngineNative::_get_parameter_count,
  2358. CarlaEngineNative::_get_parameter_info,
  2359. CarlaEngineNative::_get_parameter_value,
  2360. /* _get_midi_program_count */ nullptr,
  2361. /* _get_midi_program_info */ nullptr,
  2362. CarlaEngineNative::_set_parameter_value,
  2363. /* _set_midi_program */ nullptr,
  2364. /* _set_custom_data */ nullptr,
  2365. #ifndef CARLA_ENGINE_WITHOUT_UI
  2366. CarlaEngineNative::_ui_show,
  2367. #else
  2368. nullptr,
  2369. #endif
  2370. CarlaEngineNative::_ui_idle,
  2371. CarlaEngineNative::_ui_set_parameter_value,
  2372. /* _ui_set_midi_program */ nullptr,
  2373. /* _ui_set_custom_data */ nullptr,
  2374. CarlaEngineNative::_activate,
  2375. CarlaEngineNative::_deactivate,
  2376. CarlaEngineNative::_process,
  2377. CarlaEngineNative::_get_state,
  2378. CarlaEngineNative::_set_state,
  2379. CarlaEngineNative::_dispatcher,
  2380. /* _render_inline_dsplay */ nullptr,
  2381. /* cvIns */ 5,
  2382. /* cvOuts */ 5,
  2383. /* _get_buffer_port_name */ nullptr,
  2384. /* _get_buffer_port_range */ nullptr,
  2385. /* ui_width */ kUiWidth,
  2386. /* ui_height */ kUiHeight
  2387. };
  2388. static const NativePluginDescriptor carlaPatchbayCV8Desc = {
  2389. /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
  2390. /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
  2391. |NATIVE_PLUGIN_HAS_UI
  2392. |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
  2393. |NATIVE_PLUGIN_USES_CONTROL_VOLTAGE
  2394. |NATIVE_PLUGIN_USES_STATE
  2395. |NATIVE_PLUGIN_USES_TIME
  2396. |NATIVE_PLUGIN_USES_UI_SIZE),
  2397. /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
  2398. /* audioIns */ 2,
  2399. /* audioOuts */ 2,
  2400. /* midiIns */ 1,
  2401. /* midiOuts */ 1,
  2402. /* paramIns */ kNumInParams,
  2403. /* paramOuts */ kNumOutParams,
  2404. /* name */ "Carla-Patchbay (CV8)",
  2405. /* label */ "carlapatchbaycv",
  2406. /* maker */ "falkTX",
  2407. /* copyright */ "GNU GPL v2+",
  2408. CarlaEngineNative::_instantiatePatchbayCV8,
  2409. CarlaEngineNative::_cleanup,
  2410. CarlaEngineNative::_get_parameter_count,
  2411. CarlaEngineNative::_get_parameter_info,
  2412. CarlaEngineNative::_get_parameter_value,
  2413. /* _get_midi_program_count */ nullptr,
  2414. /* _get_midi_program_info */ nullptr,
  2415. CarlaEngineNative::_set_parameter_value,
  2416. /* _set_midi_program */ nullptr,
  2417. /* _set_custom_data */ nullptr,
  2418. #ifndef CARLA_ENGINE_WITHOUT_UI
  2419. CarlaEngineNative::_ui_show,
  2420. #else
  2421. nullptr,
  2422. #endif
  2423. CarlaEngineNative::_ui_idle,
  2424. CarlaEngineNative::_ui_set_parameter_value,
  2425. /* _ui_set_midi_program */ nullptr,
  2426. /* _ui_set_custom_data */ nullptr,
  2427. CarlaEngineNative::_activate,
  2428. CarlaEngineNative::_deactivate,
  2429. CarlaEngineNative::_process,
  2430. CarlaEngineNative::_get_state,
  2431. CarlaEngineNative::_set_state,
  2432. CarlaEngineNative::_dispatcher,
  2433. /* _render_inline_dsplay */ nullptr,
  2434. /* cvIns */ 8,
  2435. /* cvOuts */ 8,
  2436. /* _get_buffer_port_name */ nullptr,
  2437. /* _get_buffer_port_range */ nullptr,
  2438. /* ui_width */ kUiWidth,
  2439. /* ui_height */ kUiHeight
  2440. };
  2441. static const NativePluginDescriptor carlaPatchbayCV32Desc = {
  2442. /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
  2443. /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
  2444. |NATIVE_PLUGIN_HAS_UI
  2445. |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
  2446. |NATIVE_PLUGIN_USES_CONTROL_VOLTAGE
  2447. |NATIVE_PLUGIN_USES_STATE
  2448. |NATIVE_PLUGIN_USES_TIME
  2449. |NATIVE_PLUGIN_USES_UI_SIZE),
  2450. /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
  2451. /* audioIns */ 64,
  2452. /* audioOuts */ 64,
  2453. /* midiIns */ 1,
  2454. /* midiOuts */ 1,
  2455. /* paramIns */ kNumInParams,
  2456. /* paramOuts */ kNumOutParams,
  2457. /* name */ "Carla-Patchbay (CV32)",
  2458. /* label */ "carlapatchbaycv",
  2459. /* maker */ "falkTX",
  2460. /* copyright */ "GNU GPL v2+",
  2461. CarlaEngineNative::_instantiatePatchbayCV32,
  2462. CarlaEngineNative::_cleanup,
  2463. CarlaEngineNative::_get_parameter_count,
  2464. CarlaEngineNative::_get_parameter_info,
  2465. CarlaEngineNative::_get_parameter_value,
  2466. /* _get_midi_program_count */ nullptr,
  2467. /* _get_midi_program_info */ nullptr,
  2468. CarlaEngineNative::_set_parameter_value,
  2469. /* _set_midi_program */ nullptr,
  2470. /* _set_custom_data */ nullptr,
  2471. #ifndef CARLA_ENGINE_WITHOUT_UI
  2472. CarlaEngineNative::_ui_show,
  2473. #else
  2474. nullptr,
  2475. #endif
  2476. CarlaEngineNative::_ui_idle,
  2477. CarlaEngineNative::_ui_set_parameter_value,
  2478. /* _ui_set_midi_program */ nullptr,
  2479. /* _ui_set_custom_data */ nullptr,
  2480. CarlaEngineNative::_activate,
  2481. CarlaEngineNative::_deactivate,
  2482. CarlaEngineNative::_process,
  2483. CarlaEngineNative::_get_state,
  2484. CarlaEngineNative::_set_state,
  2485. CarlaEngineNative::_dispatcher,
  2486. /* _render_inline_dsplay */ nullptr,
  2487. /* cvIns */ 32,
  2488. /* cvOuts */ 32,
  2489. /* _get_buffer_port_name */ nullptr,
  2490. /* _get_buffer_port_range */ nullptr,
  2491. /* ui_width */ kUiWidth,
  2492. /* ui_height */ kUiHeight
  2493. };
  2494. static const NativePluginDescriptor carlaPatchbayOBS = {
  2495. /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
  2496. /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
  2497. |NATIVE_PLUGIN_HAS_UI
  2498. |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
  2499. |NATIVE_PLUGIN_USES_STATE
  2500. |NATIVE_PLUGIN_USES_TIME
  2501. |NATIVE_PLUGIN_USES_UI_SIZE),
  2502. /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
  2503. /* audioIns */ 8,
  2504. /* audioOuts */ 8,
  2505. /* midiIns */ 0,
  2506. /* midiOuts */ 0,
  2507. /* paramIns */ kNumInParams,
  2508. /* paramOuts */ kNumOutParams,
  2509. /* name */ "Carla-Patchbay (OBS)",
  2510. /* label */ "carlapatchbayOBS",
  2511. /* maker */ "falkTX",
  2512. /* copyright */ "GNU GPL v2+",
  2513. CarlaEngineNative::_instantiatePatchbayOBS,
  2514. CarlaEngineNative::_cleanup,
  2515. CarlaEngineNative::_get_parameter_count,
  2516. CarlaEngineNative::_get_parameter_info,
  2517. CarlaEngineNative::_get_parameter_value,
  2518. /* _get_midi_program_count */ nullptr,
  2519. /* _get_midi_program_info */ nullptr,
  2520. CarlaEngineNative::_set_parameter_value,
  2521. /* _set_midi_program */ nullptr,
  2522. /* _set_custom_data */ nullptr,
  2523. #ifndef CARLA_ENGINE_WITHOUT_UI
  2524. CarlaEngineNative::_ui_show,
  2525. #else
  2526. nullptr,
  2527. #endif
  2528. CarlaEngineNative::_ui_idle,
  2529. CarlaEngineNative::_ui_set_parameter_value,
  2530. /* _ui_set_midi_program */ nullptr,
  2531. /* _ui_set_custom_data */ nullptr,
  2532. CarlaEngineNative::_activate,
  2533. CarlaEngineNative::_deactivate,
  2534. CarlaEngineNative::_process,
  2535. CarlaEngineNative::_get_state,
  2536. CarlaEngineNative::_set_state,
  2537. CarlaEngineNative::_dispatcher,
  2538. /* _render_inline_dsplay */ nullptr,
  2539. /* cvIns */ 0,
  2540. /* cvOuts */ 0,
  2541. /* _get_buffer_port_name */ nullptr,
  2542. /* _get_buffer_port_range */ nullptr,
  2543. /* ui_width */ kUiWidth,
  2544. /* ui_height */ kUiHeight
  2545. };
  2546. CARLA_BACKEND_END_NAMESPACE
  2547. // -----------------------------------------------------------------------
  2548. #ifndef STATIC_PLUGIN_TARGET
  2549. CARLA_API_EXPORT
  2550. void carla_register_native_plugin_carla();
  2551. void carla_register_native_plugin_carla()
  2552. {
  2553. CARLA_BACKEND_USE_NAMESPACE;
  2554. carla_register_native_plugin(&carlaRackDesc);
  2555. carla_register_native_plugin(&carlaRackNoMidiOutDesc);
  2556. carla_register_native_plugin(&carlaPatchbayDesc);
  2557. carla_register_native_plugin(&carlaPatchbay3sDesc);
  2558. carla_register_native_plugin(&carlaPatchbay16Desc);
  2559. carla_register_native_plugin(&carlaPatchbay32Desc);
  2560. carla_register_native_plugin(&carlaPatchbay64Desc);
  2561. carla_register_native_plugin(&carlaPatchbayCVDesc);
  2562. }
  2563. #endif
  2564. // -----------------------------------------------------------------------
  2565. const NativePluginDescriptor* carla_get_native_rack_plugin()
  2566. {
  2567. CARLA_BACKEND_USE_NAMESPACE;
  2568. return &carlaRackDesc;
  2569. }
  2570. const NativePluginDescriptor* carla_get_native_patchbay_plugin()
  2571. {
  2572. CARLA_BACKEND_USE_NAMESPACE;
  2573. return &carlaPatchbayDesc;
  2574. }
  2575. const NativePluginDescriptor* carla_get_native_patchbay16_plugin()
  2576. {
  2577. CARLA_BACKEND_USE_NAMESPACE;
  2578. return &carlaPatchbay16Desc;
  2579. }
  2580. const NativePluginDescriptor* carla_get_native_patchbay32_plugin()
  2581. {
  2582. CARLA_BACKEND_USE_NAMESPACE;
  2583. return &carlaPatchbay32Desc;
  2584. }
  2585. const NativePluginDescriptor* carla_get_native_patchbay64_plugin()
  2586. {
  2587. CARLA_BACKEND_USE_NAMESPACE;
  2588. return &carlaPatchbay64Desc;
  2589. }
  2590. const NativePluginDescriptor* carla_get_native_patchbay_cv_plugin()
  2591. {
  2592. CARLA_BACKEND_USE_NAMESPACE;
  2593. return &carlaPatchbayCVDesc;
  2594. }
  2595. const NativePluginDescriptor* carla_get_native_patchbay_cv8_plugin()
  2596. {
  2597. CARLA_BACKEND_USE_NAMESPACE;
  2598. return &carlaPatchbayCV8Desc;
  2599. }
  2600. const NativePluginDescriptor* carla_get_native_patchbay_cv32_plugin()
  2601. {
  2602. CARLA_BACKEND_USE_NAMESPACE;
  2603. return &carlaPatchbayCV32Desc;
  2604. }
  2605. const NativePluginDescriptor* carla_get_native_patchbay_obs_plugin()
  2606. {
  2607. CARLA_BACKEND_USE_NAMESPACE;
  2608. return &carlaPatchbayOBS;
  2609. }
  2610. // -----------------------------------------------------------------------
  2611. // Extra stuff for linking purposes
  2612. #ifdef CARLA_PLUGIN_BUILD
  2613. CARLA_BACKEND_START_NAMESPACE
  2614. namespace EngineInit {
  2615. #ifndef HAVE_JACK
  2616. CarlaEngine* newJack() { return nullptr; }
  2617. #endif
  2618. #ifdef USING_JUCE_AUDIO_DEVICES
  2619. CarlaEngine* newJuce(const AudioApi) { return nullptr; }
  2620. uint getJuceApiCount() { return 0; }
  2621. const char* getJuceApiName(const uint) { return nullptr; }
  2622. const char* const* getJuceApiDeviceNames(const uint) { return nullptr; }
  2623. const EngineDriverDeviceInfo* getJuceDeviceInfo(const uint, const char* const) { return nullptr; }
  2624. bool showJuceDeviceControlPanel(const uint, const char* const) { return false; }
  2625. #endif
  2626. #ifdef USING_RTAUDIO
  2627. CarlaEngine* newRtAudio(const AudioApi) { return nullptr; }
  2628. uint getRtAudioApiCount() { return 0; }
  2629. const char* getRtAudioApiName(const uint) { return nullptr; }
  2630. const char* const* getRtAudioApiDeviceNames(const uint) { return nullptr; }
  2631. const EngineDriverDeviceInfo* getRtAudioDeviceInfo(const uint, const char* const) { return nullptr; }
  2632. #endif
  2633. #ifdef HAVE_SDL
  2634. CarlaEngine* newSDL() { return nullptr; }
  2635. const char* const* getSDLDeviceNames() { return nullptr; }
  2636. #endif
  2637. }
  2638. CARLA_BACKEND_END_NAMESPACE
  2639. #define CARLA_PLUGIN_UI_CLASS_PREFIX Plugin
  2640. #include "CarlaPluginUI.cpp"
  2641. # undef CARLA_PLUGIN_UI_CLASS_PREFIX
  2642. #include "CarlaDssiUtils.cpp"
  2643. #include "CarlaMacUtils.cpp"
  2644. #include "CarlaPatchbayUtils.cpp"
  2645. #include "CarlaPipeUtils.cpp"
  2646. #include "CarlaProcessUtils.cpp"
  2647. #include "CarlaStateUtils.cpp"
  2648. #endif /* CARLA_PLUGIN_BUILD */
  2649. // -----------------------------------------------------------------------