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