|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061 |
- /*
- * Carla Plugin Host
- * Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * For a full copy of the GNU General Public License see the doc/GPL.txt file.
- */
-
- #include "CarlaDefines.h"
-
- #ifdef BUILD_BRIDGE_ALTERNATIVE_ARCH
- # error This file should not be compiled if building alternative-arch bridges
- #endif
-
- #ifdef CARLA_OS_WASM
- # define CARLA_ENGINE_WITHOUT_UI
- #endif
-
- #include "CarlaEngineInit.hpp"
- #include "CarlaEngineInternal.hpp"
- #include "CarlaPlugin.hpp"
-
- #include "CarlaBackendUtils.hpp"
- #include "CarlaBase64Utils.hpp"
- #include "CarlaBinaryUtils.hpp"
- #include "CarlaMathUtils.hpp"
- #include "CarlaStateUtils.hpp"
-
- #include "CarlaExternalUI.hpp"
- #include "CarlaHost.h"
- #include "CarlaNative.hpp"
- #include "CarlaNativePlugin.h"
-
- #include "water/files/File.h"
- #include "water/streams/MemoryOutputStream.h"
- #include "water/xml/XmlDocument.h"
- #include "water/xml/XmlElement.h"
-
- #ifdef USING_JUCE
- # include "carla_juce/carla_juce.h"
- #endif
-
- using water::File;
- using water::MemoryOutputStream;
- using water::String;
- using water::XmlDocument;
- using water::XmlElement;
-
- CARLA_BACKEND_START_NAMESPACE
-
- static const uint32_t kNumInParams = 100;
- static const uint32_t kNumOutParams = 10;
-
- static const uint16_t kUiWidth = 1024;
- static const uint16_t kUiHeight = 712;
-
- // -----------------------------------------------------------------------
-
- #ifndef CARLA_ENGINE_WITHOUT_UI
- class CarlaEngineNative;
-
- class CarlaEngineNativeUI : public CarlaExternalUI
- {
- public:
- CarlaEngineNativeUI(CarlaEngineNative* const engine)
- : fEngine(engine)
- {
- carla_debug("CarlaEngineNativeUI::CarlaEngineNativeUI(%p)", engine);
- }
-
- ~CarlaEngineNativeUI() noexcept override
- {
- carla_debug("CarlaEngineNativeUI::~CarlaEngineNativeUI()");
- }
-
- protected:
- bool msgReceived(const char* const msg) noexcept override;
-
- private:
- CarlaEngineNative* const fEngine;
-
- void _updateParamValues(const CarlaPluginPtr& plugin,
- uint32_t pluginId,
- bool sendCallback, bool sendPluginHost) const noexcept;
-
- CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineNativeUI)
- };
- #endif
-
- // -----------------------------------------------------------------------
-
- class CarlaEngineNative : public CarlaEngine
- {
- public:
- CarlaEngineNative(const NativeHostDescriptor* const host, const bool isPatchbay, const bool withMidiOut,
- const uint32_t inChan = 2, uint32_t outChan = 2,
- const uint32_t cvIns = 0, const uint32_t cvOuts = 0)
- : CarlaEngine(),
- pHost(host),
- #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
- // if not running inside Carla, we will have to run event loop ourselves
- kNeedsJuceEvents(host->dispatcher(pHost->handle,
- NATIVE_HOST_OPCODE_INTERNAL_PLUGIN, 0, 0, nullptr, 0.0f) == 0),
- fJuceMsgMgr(),
- fJuceMsgMutex(),
- #endif
- kIsPatchbay(isPatchbay),
- kHasMidiOut(withMidiOut),
- fIsActive(false),
- fIsRunning(false),
- fUsesEmbed(false),
- #ifndef CARLA_ENGINE_WITHOUT_UI
- fUiServer(this),
- #endif
- fLastScaleFactor(1.0f),
- fLastProjectFolder(),
- fPluginDeleterMutex(),
- fOptionsForced(false)
- {
- carla_debug("CarlaEngineNative::CarlaEngineNative()");
-
- carla_zeroFloats(fParameters, kNumInParams+kNumOutParams);
-
- #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
- if (kNeedsJuceEvents)
- fJuceMsgMgr.incRef();
- #endif
-
- pData->bufferSize = pHost->get_buffer_size(pHost->handle);
- pData->sampleRate = pHost->get_sample_rate(pHost->handle);
- pData->initTime(nullptr);
-
- #ifndef BUILD_BRIDGE
- // Forced OSC setup when running as plugin
- pData->options.oscEnabled = true;
- pData->options.oscPortTCP = -1;
- pData->options.oscPortUDP = 0;
- #endif
-
- if (outChan == 0)
- outChan = inChan;
-
- // set-up engine
- if (kIsPatchbay)
- {
- pData->options.processMode = ENGINE_PROCESS_MODE_PATCHBAY;
- pData->options.transportMode = ENGINE_TRANSPORT_MODE_PLUGIN;
- pData->options.forceStereo = false;
- pData->options.preferPluginBridges = false;
- pData->options.preferUiBridges = false;
- init("Carla-Patchbay");
- pData->graph.create(inChan, outChan, cvIns, cvOuts);
- }
- else
- {
- CARLA_SAFE_ASSERT(inChan == 2);
- CARLA_SAFE_ASSERT(outChan == 2);
- pData->options.processMode = ENGINE_PROCESS_MODE_CONTINUOUS_RACK;
- pData->options.transportMode = ENGINE_TRANSPORT_MODE_PLUGIN;
- pData->options.forceStereo = true;
- pData->options.preferPluginBridges = false;
- pData->options.preferUiBridges = false;
- init("Carla-Rack");
- pData->graph.create(0, 0, 0, 0); // FIXME?
- }
-
- if (pData->options.resourceDir != nullptr)
- delete[] pData->options.resourceDir;
- if (pData->options.binaryDir != nullptr)
- delete[] pData->options.binaryDir;
-
- const water::String binaryDir(File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName());
-
- pData->options.resourceDir = carla_strdup(pHost->resourceDir);
- pData->options.binaryDir = carla_strdup(binaryDir.toRawUTF8());
- }
-
- ~CarlaEngineNative() override
- {
- CARLA_SAFE_ASSERT(! fIsActive);
- carla_debug("CarlaEngineNative::~CarlaEngineNative() - START");
-
- pData->aboutToClose = true;
- fIsRunning = false;
-
- {
- #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
- const ScopedJuceMessageThreadRunner sjmtr(*this, true);
- #endif
- removeAllPlugins();
- //runPendingRtEvents();
- close();
-
- pData->graph.destroy();
- }
-
- #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
- if (kNeedsJuceEvents)
- fJuceMsgMgr.decRef();
- #endif
-
- carla_debug("CarlaEngineNative::~CarlaEngineNative() - END");
- }
-
- // -------------------------------------
- // CarlaEngine virtual calls
-
- bool init(const char* const clientName) override
- {
- carla_debug("CarlaEngineNative::init(\"%s\")", clientName);
-
- fIsRunning = true;
-
- if (! pData->init(clientName))
- {
- close();
- setLastError("Failed to init internal data");
- return false;
- }
-
- pData->bufferSize = pHost->get_buffer_size(pHost->handle);
- pData->sampleRate = pHost->get_sample_rate(pHost->handle);
-
- return true;
- }
-
- bool close() override
- {
- fIsRunning = false;
- CarlaEngine::close();
- return true;
- }
-
- bool hasIdleOnMainThread() const noexcept override
- {
- return false;
- }
-
- bool isRunning() const noexcept override
- {
- return fIsRunning;
- }
-
- bool isOffline() const noexcept override
- {
- return pHost->is_offline(pHost->handle);
- }
-
- bool usesConstantBufferSize() const noexcept override
- {
- // TODO LV2 hosts can report this, till then we allow this
- return true;
- }
-
- EngineType getType() const noexcept override
- {
- return kEngineTypePlugin;
- }
-
- const char* getCurrentDriverName() const noexcept override
- {
- return "Plugin";
- }
-
- const char* getCurrentProjectFolder() const noexcept override
- {
- CARLA_SAFE_ASSERT_RETURN(pHost != nullptr, nullptr);
-
- static char filetype[] = "carla\0";
-
- try {
- return (const char*)(uintptr_t)pHost->dispatcher(pHost->handle,
- NATIVE_HOST_OPCODE_GET_FILE_PATH,
- 0, 0,
- (void*)filetype,
- 0.0f);
- } CARLA_SAFE_EXCEPTION_RETURN("get_file_path", nullptr);
- }
-
- void callback(const bool sendHost, const bool sendOsc,
- const EngineCallbackOpcode action, const uint pluginId,
- const int value1, const int value2, const int value3,
- const float valuef, const char* const valueStr) noexcept override
- {
- CarlaEngine::callback(sendHost, sendOsc, action, pluginId, value1, value2, value3, valuef, valueStr);
-
- #ifndef CARLA_ENGINE_WITHOUT_UI
- if (sendHost)
- uiServerCallback(action, pluginId, value1, value2, value3, valuef, valueStr);
- #endif
-
- switch (action)
- {
- case ENGINE_CALLBACK_IDLE:
- if (! pData->aboutToClose)
- pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_HOST_IDLE, 0, 0, nullptr, 0.0f);
- break;
-
- case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
- if (sendHost && value1 >= 0)
- {
- uint32_t rindex = static_cast<uint32_t>(value1);
- if (_getRealIndexForPluginParameter(pluginId, rindex))
- {
- fParameters[rindex] = valuef;
-
- if (fUsesEmbed
- #ifndef CARLA_ENGINE_WITHOUT_UI
- || fUiServer.isPipeRunning()
- #endif
- )
- {
- pHost->ui_parameter_changed(pHost->handle, rindex, valuef);
- }
- else
- {
- static uint last_pluginId = pluginId;
- static int last_value1 = value1;
- static bool init = true;
-
- if (init || last_pluginId != pluginId || last_value1 != value1)
- {
- init = false;
- last_pluginId = pluginId;
- last_value1 = value1;
- carla_stdout("Plugin with id %d triggered parameter %d update while UI is hidden",
- pluginId, value1);
- }
- }
- }
- }
- break;
-
- case ENGINE_CALLBACK_UI_STATE_CHANGED:
- if (sendHost && fUsesEmbed)
- pHost->ui_closed(pHost->handle);
- break;
-
- default:
- break;
- }
- }
-
- const char* runFileCallback(FileCallbackOpcode action,
- bool isDir, const char* title, const char* filter) noexcept override
- {
- switch (action)
- {
- case FILE_CALLBACK_DEBUG:
- return nullptr;
-
- case FILE_CALLBACK_OPEN:
- return pHost->ui_open_file(pHost->handle, isDir, title, filter);
-
- case FILE_CALLBACK_SAVE:
- return pHost->ui_save_file(pHost->handle, isDir, title, filter);
- }
-
- return nullptr;
- }
-
- // -------------------------------------------------------------------
-
- void touchPluginParameter(const uint id, const uint32_t parameterId, const bool touch) noexcept override
- {
- setParameterTouchFromUI(id, parameterId, touch);
- }
-
- // -------------------------------------------------------------------
-
- void setParameterValueFromUI(const uint32_t pluginId, const uint32_t index, const float value)
- {
- uint32_t rindex = index;
- if (_getRealIndexForPluginParameter(pluginId, rindex))
- {
- fParameters[rindex] = value;
- pHost->ui_parameter_changed(pHost->handle, rindex, value);
- }
- }
-
- void setParameterTouchFromUI(const uint32_t pluginId, const uint32_t index, const bool touch)
- {
- uint32_t rindex = index;
- if (_getRealIndexForPluginParameter(pluginId, rindex))
- {
- pHost->dispatcher(pHost->handle,
- NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER,
- static_cast<int32_t>(rindex),
- touch ? 1 : 0,
- nullptr, 0.0f);
- }
- }
-
- void reloadFromUI()
- {
- carla_zeroFloats(fParameters, kNumInParams+kNumOutParams);
- pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_RELOAD_PARAMETERS, 0, 0, nullptr, 0.0f);
- }
-
- protected:
- // -------------------------------------------------------------------
-
- void bufferSizeChanged(const uint32_t newBufferSize)
- {
- if (pData->bufferSize == newBufferSize)
- return;
-
- #ifndef CARLA_ENGINE_WITHOUT_UI
- {
- const CarlaMutexLocker cml(fUiServer.getPipeLock());
-
- if (fUiServer.writeMessage("buffer-size\n"))
- {
- char tmpBuf[STR_MAX+1];
- carla_zeroChars(tmpBuf, STR_MAX+1);
-
- std::snprintf(tmpBuf, STR_MAX, "%i\n", newBufferSize);
-
- if (fUiServer.writeMessage(tmpBuf))
- fUiServer.flushMessages();
- }
- }
- #endif
-
- pData->bufferSize = newBufferSize;
- CarlaEngine::bufferSizeChanged(newBufferSize);
- }
-
- void sampleRateChanged(const double newSampleRate)
- {
- if (carla_isEqual(pData->sampleRate, newSampleRate))
- return;
-
- #ifndef CARLA_ENGINE_WITHOUT_UI
- {
- const CarlaMutexLocker cml(fUiServer.getPipeLock());
-
- if (fUiServer.writeMessage("sample-rate\n"))
- {
- char tmpBuf[STR_MAX+1];
- carla_zeroChars(tmpBuf, STR_MAX+1);
-
- {
- const CarlaScopedLocale csl;
- std::snprintf(tmpBuf, STR_MAX, "%.12g\n", newSampleRate);
- }
-
- if (fUiServer.writeMessage(tmpBuf))
- fUiServer.flushMessages();
- }
- }
- #endif
-
- pData->sampleRate = newSampleRate;
- CarlaEngine::sampleRateChanged(newSampleRate);
- }
-
- #ifndef CARLA_ENGINE_WITHOUT_UI
- // -------------------------------------------------------------------
-
- void uiServerSendPluginInfo(const CarlaPluginPtr& plugin)
- {
- char tmpBuf[STR_MAX+1];
- carla_zeroChars(tmpBuf, STR_MAX+1);
-
- const CarlaMutexLocker cml(fUiServer.getPipeLock());
-
- const uint pluginId(plugin->getId());
-
- std::snprintf(tmpBuf, STR_MAX, "PLUGIN_INFO_%i\n", pluginId);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "%i:%i:%i:" P_INT64 ":%i:%i\n",
- plugin->getType(), plugin->getCategory(),
- plugin->getHints(), plugin->getUniqueId(),
- plugin->getOptionsAvailable(), plugin->getOptionsEnabled());
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- if (const char* const filename = plugin->getFilename())
- {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(filename),);
- }
- else
- {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- if (const char* const name = plugin->getName())
- {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(name),);
- }
- else
- {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- if (const char* const iconName = plugin->getIconName())
- {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(iconName),);
- }
- else
- {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- if (plugin->getRealName(tmpBuf)) {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
- } else {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- if (plugin->getLabel(tmpBuf)) {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
- } else {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- if (plugin->getMaker(tmpBuf)) {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
- } else {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- if (plugin->getCopyright(tmpBuf)) {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
- } else {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- std::snprintf(tmpBuf, STR_MAX, "AUDIO_COUNT_%i:%i:%i\n",
- pluginId, plugin->getAudioInCount(), plugin->getAudioOutCount());
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "MIDI_COUNT_%i:%i:%i\n",
- pluginId, plugin->getMidiInCount(), plugin->getMidiOutCount());
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- fUiServer.flushMessages();
- }
-
- void uiServerSendPluginParameters(const CarlaPluginPtr& plugin)
- {
- char tmpBuf[STR_MAX+1];
- carla_zeroChars(tmpBuf, STR_MAX+1);
-
- const CarlaMutexLocker cml(fUiServer.getPipeLock());
- const CarlaScopedLocale csl;
-
- const uint pluginId(plugin->getId());
-
- for (int32_t i=PARAMETER_ACTIVE; i>PARAMETER_MAX; --i)
- {
- std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%u:%i\n", pluginId, i);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(plugin->getInternalParameterValue(i)));
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- fUiServer.flushMessages();
- }
-
- uint32_t ins, outs, count;
- plugin->getParameterCountInfo(ins, outs);
- count = plugin->getParameterCount();
-
- std::snprintf(tmpBuf, STR_MAX, "PARAMETER_COUNT_%i:%i:%i:%i\n", pluginId, ins, outs, count);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- for (uint32_t i=0; i<count; ++i)
- {
- const ParameterData& paramData(plugin->getParameterData(i));
- const ParameterRanges& paramRanges(plugin->getParameterRanges(i));
-
- std::snprintf(tmpBuf, STR_MAX, "PARAMETER_DATA_%i:%i\n", pluginId, i);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "%i:%i:%i:%i\n", paramData.type, paramData.hints,
- paramData.mappedControlIndex, paramData.midiChannel);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "%.12g:%.12g\n", static_cast<double>(paramData.mappedMinimum),
- static_cast<double>(paramData.mappedMaximum));
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- if (plugin->getParameterName(i, tmpBuf)) {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
- } else {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- if (plugin->getParameterUnit(i, tmpBuf)) {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
- } else {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- if (plugin->getParameterComment(i, tmpBuf)) {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
- } else {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- if (plugin->getParameterGroupName(i, tmpBuf)) {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
- } else {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- std::snprintf(tmpBuf, STR_MAX, "PARAMETER_RANGES_%i:%i\n", pluginId, i);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "%.12g:%.12g:%.12g:%.12g:%.12g:%.12g\n",
- static_cast<double>(paramRanges.def),
- static_cast<double>(paramRanges.min),
- static_cast<double>(paramRanges.max),
- static_cast<double>(paramRanges.step),
- static_cast<double>(paramRanges.stepSmall),
- static_cast<double>(paramRanges.stepLarge));
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%u:%u\n", pluginId, i);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(plugin->getParameterValue(i)));
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- }
-
- fUiServer.flushMessages();
- }
-
- void uiServerSendPluginPrograms(const CarlaPluginPtr& plugin)
- {
- char tmpBuf[STR_MAX+1];
- carla_zeroChars(tmpBuf, STR_MAX+1);
-
- const CarlaMutexLocker cml(fUiServer.getPipeLock());
-
- const uint pluginId(plugin->getId());
-
- uint32_t count = plugin->getProgramCount();
- std::snprintf(tmpBuf, STR_MAX, "PROGRAM_COUNT_%i:%i:%i\n", pluginId, count, plugin->getCurrentProgram());
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- for (uint32_t i=0; i<count; ++i)
- {
- std::snprintf(tmpBuf, STR_MAX, "PROGRAM_NAME_%i:%i\n", pluginId, i);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- if (plugin->getProgramName(i, tmpBuf)) {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(tmpBuf),);
- } else {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
- }
-
- fUiServer.flushMessages();
-
- count = plugin->getMidiProgramCount();
- std::snprintf(tmpBuf, STR_MAX, "MIDI_PROGRAM_COUNT_%i:%i:%i\n",
- pluginId, count, plugin->getCurrentMidiProgram());
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- for (uint32_t i=0; i<count; ++i)
- {
- std::snprintf(tmpBuf, STR_MAX, "MIDI_PROGRAM_DATA_%i:%i\n", pluginId, i);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- const MidiProgramData& mpData(plugin->getMidiProgramData(i));
-
- std::snprintf(tmpBuf, STR_MAX, "%i:%i\n", mpData.bank, mpData.program);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(mpData.name),);
- }
-
- fUiServer.flushMessages();
- }
-
- void uiServerSendPluginProperties(const CarlaPluginPtr& plugin)
- {
- char tmpBuf[STR_MAX+1];
- carla_zeroChars(tmpBuf, STR_MAX+1);
-
- const CarlaMutexLocker cml(fUiServer.getPipeLock());
-
- const uint pluginId(plugin->getId());
-
- uint32_t count = plugin->getCustomDataCount();
- std::snprintf(tmpBuf, STR_MAX, "CUSTOM_DATA_COUNT_%i:%i\n", pluginId, count);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- for (uint32_t i=0; i<count; ++i)
- {
- const CustomData& customData(plugin->getCustomData(i));
- CARLA_SAFE_ASSERT_CONTINUE(customData.isValid());
-
- if (std::strcmp(customData.type, CUSTOM_DATA_TYPE_PROPERTY) != 0)
- continue;
-
- std::snprintf(tmpBuf, STR_MAX, "CUSTOM_DATA_%i:%i\n", pluginId, i);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(customData.type),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(customData.key),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(customData.value),);
- }
-
- fUiServer.flushMessages();
- }
-
- void uiServerCallback(const EngineCallbackOpcode action, const uint pluginId,
- const int value1, const int value2, const int value3,
- const float valuef, const char* const valueStr)
- {
- if (! fIsRunning)
- return;
- if (! fUiServer.isPipeRunning())
- return;
-
- switch (action)
- {
- case ENGINE_CALLBACK_UPDATE:
- if (const CarlaPluginPtr plugin = getPlugin(pluginId))
- {
- if (plugin->isEnabled())
- {
- CARLA_SAFE_ASSERT_BREAK(plugin->getId() == pluginId);
- uiServerSendPluginProperties(plugin);
- }
- }
- break;
-
- case ENGINE_CALLBACK_RELOAD_INFO:
- if (const CarlaPluginPtr plugin = getPlugin(pluginId))
- {
- if (plugin->isEnabled())
- {
- CARLA_SAFE_ASSERT_BREAK(plugin->getId() == pluginId);
- uiServerSendPluginInfo(plugin);
- }
- }
- break;
-
- case ENGINE_CALLBACK_RELOAD_PARAMETERS:
- if (const CarlaPluginPtr plugin = getPlugin(pluginId))
- {
- if (plugin->isEnabled())
- {
- CARLA_SAFE_ASSERT_BREAK(plugin->getId() == pluginId);
- uiServerSendPluginParameters(plugin);
- }
- }
- break;
-
- case ENGINE_CALLBACK_RELOAD_PROGRAMS:
- if (const CarlaPluginPtr plugin = getPlugin(pluginId))
- {
- if (plugin->isEnabled())
- {
- CARLA_SAFE_ASSERT_BREAK(plugin->getId() == pluginId);
- uiServerSendPluginPrograms(plugin);
- }
- }
- break;
-
- case ENGINE_CALLBACK_RELOAD_ALL:
- case ENGINE_CALLBACK_PLUGIN_ADDED:
- case ENGINE_CALLBACK_PLUGIN_RENAMED:
- if (const CarlaPluginPtr plugin = getPlugin(pluginId))
- {
- if (plugin->isEnabled())
- {
- CARLA_SAFE_ASSERT_BREAK(plugin->getId() == pluginId);
- uiServerSendPluginInfo(plugin);
- uiServerSendPluginParameters(plugin);
- uiServerSendPluginPrograms(plugin);
- uiServerSendPluginProperties(plugin);
- }
- }
- break;
-
- default:
- break;
- }
-
- char tmpBuf[STR_MAX+1];
- carla_zeroChars(tmpBuf, STR_MAX+1);
-
- const CarlaMutexLocker cml(fUiServer.getPipeLock());
-
- std::snprintf(tmpBuf, STR_MAX, "ENGINE_CALLBACK_%i\n", int(action));
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "%u\n", pluginId);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "%i\n", value1);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "%i\n", value2);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- std::snprintf(tmpBuf, STR_MAX, "%i\n", value3);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- {
- const CarlaScopedLocale csl;
- std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(valuef));
- }
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- if (valueStr != nullptr) {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(valueStr),);
- } else {
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
- }
-
- fUiServer.flushMessages();
- }
-
- void uiServerInfo()
- {
- CARLA_SAFE_ASSERT_RETURN(fIsRunning,);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.isPipeRunning(),);
-
- char tmpBuf[STR_MAX+1];
- carla_zeroChars(tmpBuf, STR_MAX+1);
-
- const CarlaMutexLocker cml(fUiServer.getPipeLock());
-
- #if defined(HAVE_LIBLO) && !defined(BUILD_BRIDGE)
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("osc-urls\n"),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(pData->osc.getServerPathTCP()),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(pData->osc.getServerPathUDP()),);
- #endif
-
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("max-plugin-number\n"),);
- std::snprintf(tmpBuf, STR_MAX, "%i\n", pData->maxPluginNumber);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("buffer-size\n"),);
- std::snprintf(tmpBuf, STR_MAX, "%i\n", pData->bufferSize);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("sample-rate\n"),);
- {
- const CarlaScopedLocale csl;
- std::snprintf(tmpBuf, STR_MAX, "%.12g\n", pData->sampleRate);
- }
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- fUiServer.flushMessages();
- }
-
- void uiServerOptions()
- {
- CARLA_SAFE_ASSERT_RETURN(fIsRunning,);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.isPipeRunning(),);
-
- char tmpBuf[STR_MAX+1];
- carla_zeroChars(tmpBuf, STR_MAX+1);
-
- const EngineOptions& options(pData->options);
- const CarlaMutexLocker cml(fUiServer.getPipeLock());
-
- const char* const optionsForcedStr(fOptionsForced ? "true\n" : "false\n");
- const std::size_t optionsForcedStrSize(fOptionsForced ? 5 : 6);
-
- std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PROCESS_MODE);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
- std::snprintf(tmpBuf, STR_MAX, "%i\n", options.processMode);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- fUiServer.flushMessages();
-
- std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_TRANSPORT_MODE);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
- std::snprintf(tmpBuf, STR_MAX, "%i\n", options.transportMode);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- fUiServer.flushMessages();
-
- std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_FORCE_STEREO);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.forceStereo ? "true\n" : "false\n"),);
- fUiServer.flushMessages();
-
- std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PREFER_PLUGIN_BRIDGES);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.preferPluginBridges ? "true\n" : "false\n"),);
- fUiServer.flushMessages();
-
- std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PREFER_UI_BRIDGES);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.preferUiBridges ? "true\n" : "false\n"),);
- fUiServer.flushMessages();
-
- std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_UIS_ALWAYS_ON_TOP);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(options.uisAlwaysOnTop ? "true\n" : "false\n"),);
- fUiServer.flushMessages();
-
- std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_MAX_PARAMETERS);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
- std::snprintf(tmpBuf, STR_MAX, "%i\n", options.maxParameters);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- fUiServer.flushMessages();
-
- std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_UI_BRIDGES_TIMEOUT);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(optionsForcedStr, optionsForcedStrSize),);
- std::snprintf(tmpBuf, STR_MAX, "%i\n", options.uiBridgesTimeout);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- fUiServer.flushMessages();
-
- std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PATH_BINARIES);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("true\n", 5),);
- std::snprintf(tmpBuf, STR_MAX, "%s\n", options.binaryDir);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- fUiServer.flushMessages();
-
- std::snprintf(tmpBuf, STR_MAX, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PATH_RESOURCES);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("true\n", 5),);
- std::snprintf(tmpBuf, STR_MAX, "%s\n", options.resourceDir);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- fUiServer.flushMessages();
- }
- #endif
-
- // -------------------------------------------------------------------
- // Plugin parameter calls
-
- uint32_t getParameterCount() const
- {
- return kNumInParams + kNumOutParams;
- }
-
- const NativeParameter* getParameterInfo(const uint32_t index) const
- {
- static NativeParameter param;
-
- static char strBufName[STR_MAX+1];
- static char strBufUnit[STR_MAX+1];
- static char strBufComment[STR_MAX+1];
- static char strBufGroupName[STR_MAX+1];
- carla_zeroChars(strBufName, STR_MAX+1);
- carla_zeroChars(strBufUnit, STR_MAX+1);
- carla_zeroChars(strBufComment, STR_MAX+1);
- carla_zeroChars(strBufGroupName, STR_MAX+1);
-
- uint32_t rindex = index;
- if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
- {
- const ParameterData& paramData(plugin->getParameterData(rindex));
- const ParameterRanges& paramRanges(plugin->getParameterRanges(rindex));
-
- if (! plugin->getParameterName(rindex, strBufName))
- strBufName[0] = '\0';
- if (! plugin->getParameterUnit(rindex, strBufUnit))
- strBufUnit[0] = '\0';
- if (! plugin->getParameterComment(rindex, strBufComment))
- strBufComment[0] = '\0';
- if (! plugin->getParameterGroupName(rindex, strBufGroupName))
- std::snprintf(strBufGroupName, STR_MAX, "%u:%s", plugin->getId(), plugin->getName());
-
- uint hints = 0x0;
-
- if (paramData.hints & PARAMETER_IS_BOOLEAN)
- hints |= NATIVE_PARAMETER_IS_BOOLEAN;
- if (paramData.hints & PARAMETER_IS_INTEGER)
- hints |= NATIVE_PARAMETER_IS_INTEGER;
- if (paramData.hints & PARAMETER_IS_LOGARITHMIC)
- hints |= NATIVE_PARAMETER_IS_LOGARITHMIC;
- if (paramData.hints & PARAMETER_IS_AUTOMATABLE)
- hints |= NATIVE_PARAMETER_IS_AUTOMATABLE;
- if (paramData.hints & PARAMETER_USES_SAMPLERATE)
- hints |= NATIVE_PARAMETER_USES_SAMPLE_RATE;
- if (paramData.hints & PARAMETER_USES_SCALEPOINTS)
- hints |= NATIVE_PARAMETER_USES_SCALEPOINTS;
-
- if (paramData.type == PARAMETER_INPUT || paramData.type == PARAMETER_OUTPUT)
- {
- if (paramData.hints & PARAMETER_IS_ENABLED)
- hints |= NATIVE_PARAMETER_IS_ENABLED;
- if (paramData.type == PARAMETER_OUTPUT)
- hints |= NATIVE_PARAMETER_IS_OUTPUT;
- }
-
- param.hints = static_cast<NativeParameterHints>(hints);
- param.name = strBufName;
- param.unit = strBufUnit;
- param.comment = strBufComment;
- param.groupName = strBufGroupName;
- param.ranges.def = paramRanges.def;
- param.ranges.min = paramRanges.min;
- param.ranges.max = paramRanges.max;
- param.ranges.step = paramRanges.step;
- param.ranges.stepSmall = paramRanges.stepSmall;
- param.ranges.stepLarge = paramRanges.stepLarge;
- param.scalePointCount = 0; // TODO
- param.scalePoints = nullptr;
-
- return ¶m;
- }
-
- param.hints = index < kNumInParams ? static_cast<NativeParameterHints>(0x0) : NATIVE_PARAMETER_IS_OUTPUT;
- param.name = "Unused";
- param.unit = "";
- param.ranges.def = 0.0f;
- param.ranges.min = 0.0f;
- param.ranges.max = 1.0f;
- param.ranges.step = 0.01f;
- param.ranges.stepSmall = 0.001f;
- param.ranges.stepLarge = 0.1f;
- param.scalePointCount = 0;
- param.scalePoints = nullptr;
-
- return ¶m;
- }
-
- float getParameterValue(const uint32_t index) const
- {
- uint32_t rindex = index;
- if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
- return plugin->getParameterValue(rindex);
-
- return fParameters[index];
- }
-
- // -------------------------------------------------------------------
- // Plugin state calls
-
- void setParameterValue(const uint32_t index, const float value)
- {
- uint32_t rindex = index;
- if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
- plugin->setParameterValueRT(rindex, value, 0, false);
-
- fParameters[index] = value;
- }
-
- // -------------------------------------------------------------------
- // Plugin process calls
-
- void activate()
- {
- #if 0
- for (uint i=0; i < pData->curPluginCount; ++i)
- {
- CarlaPluginPtr plugin = pData->plugins[i].plugin;
-
- if (plugin == nullptr || ! plugin->isEnabled())
- continue;
-
- plugin->setActive(true, true, false);
- }
- #endif
- fIsActive = true;
- }
-
- void deactivate()
- {
- fIsActive = false;
- #if 0
- for (uint i=0; i < pData->curPluginCount; ++i)
- {
- CarlaPluginPtr plugin = pData->plugins[i].plugin;
-
- if (plugin == nullptr || ! plugin->isEnabled())
- continue;
-
- plugin->setActive(false, true, false);
- }
- #endif
-
- // just in case
- //runPendingRtEvents();
- }
-
- void process(const float* const* const inBuffer, float** const outBuffer, const uint32_t frames,
- const NativeMidiEvent* const midiEvents, const uint32_t midiEventCount)
- {
- if (frames > pData->bufferSize)
- {
- carla_stderr2("Host is calling process with too high number of frames! %u vs %u",
- frames, pData->bufferSize);
-
- deactivate();
- bufferSizeChanged(frames);
- activate();
- }
-
- const PendingRtEventsRunner prt(this, frames, true);
-
- // ---------------------------------------------------------------
- // Time Info
-
- const NativeTimeInfo* const timeInfo(pHost->get_time_info(pHost->handle));
-
- pData->timeInfo.playing = timeInfo->playing;
- pData->timeInfo.frame = timeInfo->frame;
- pData->timeInfo.usecs = timeInfo->usecs;
- pData->timeInfo.bbt.valid = timeInfo->bbt.valid;
-
- if (timeInfo->bbt.valid)
- {
- pData->timeInfo.bbt.bar = timeInfo->bbt.bar;
- pData->timeInfo.bbt.beat = timeInfo->bbt.beat;
- pData->timeInfo.bbt.tick = timeInfo->bbt.tick;
- pData->timeInfo.bbt.barStartTick = timeInfo->bbt.barStartTick;
-
- pData->timeInfo.bbt.beatsPerBar = timeInfo->bbt.beatsPerBar;
- pData->timeInfo.bbt.beatType = timeInfo->bbt.beatType;
-
- pData->timeInfo.bbt.ticksPerBeat = timeInfo->bbt.ticksPerBeat;
- pData->timeInfo.bbt.beatsPerMinute = timeInfo->bbt.beatsPerMinute;
- }
-
- // ---------------------------------------------------------------
- // Do nothing if no plugins and rack mode
-
- if (pData->curPluginCount == 0 && ! kIsPatchbay)
- {
- if (outBuffer[0] != inBuffer[0])
- carla_copyFloats(outBuffer[0], inBuffer[0], frames);
-
- if (outBuffer[1] != inBuffer[1])
- carla_copyFloats(outBuffer[1], inBuffer[1], frames);
-
- for (uint32_t i=0; i < midiEventCount; ++i)
- {
- if (! pHost->write_midi_event(pHost->handle, &midiEvents[i]))
- break;
- }
- return;
- }
-
- // ---------------------------------------------------------------
- // initialize events
-
- carla_zeroStructs(pData->events.in, kMaxEngineEventInternalCount);
- carla_zeroStructs(pData->events.out, kMaxEngineEventInternalCount);
-
- // ---------------------------------------------------------------
- // events input (before processing)
-
- {
- uint32_t engineEventIndex = 0;
-
- for (uint32_t i=0; i < midiEventCount && engineEventIndex < kMaxEngineEventInternalCount; ++i)
- {
- const NativeMidiEvent& midiEvent(midiEvents[i]);
- EngineEvent& engineEvent(pData->events.in[engineEventIndex++]);
-
- engineEvent.time = midiEvent.time;
- engineEvent.fillFromMidiData(midiEvent.size, midiEvent.data, 0);
-
- if (engineEventIndex >= kMaxEngineEventInternalCount)
- break;
- }
- }
-
- if (kIsPatchbay)
- {
- // -----------------------------------------------------------
- // process
-
- pData->graph.process(pData, inBuffer, outBuffer, frames);
- }
- else
- {
- // -----------------------------------------------------------
- // create audio buffers
-
- const float* inBuf[2] = { inBuffer[0], inBuffer[1] };
- /* */ float* outBuf[2] = { outBuffer[0], outBuffer[1] };
-
- // -----------------------------------------------------------
- // process
-
- pData->graph.processRack(pData, inBuf, outBuf, frames);
- }
-
- // ---------------------------------------------------------------
- // events output (after processing)
-
- carla_zeroStructs(pData->events.in, kMaxEngineEventInternalCount);
-
- if (kHasMidiOut)
- {
- NativeMidiEvent midiEvent;
-
- for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i)
- {
- const EngineEvent& engineEvent(pData->events.out[i]);
-
- if (engineEvent.type == kEngineEventTypeNull)
- break;
-
- carla_zeroStruct(midiEvent);
- midiEvent.time = engineEvent.time;
-
- /**/ if (engineEvent.type == kEngineEventTypeControl)
- {
- midiEvent.port = 0;
- midiEvent.size = engineEvent.ctrl.convertToMidiData(engineEvent.channel, midiEvent.data);
- }
- else if (engineEvent.type == kEngineEventTypeMidi)
- {
- if (engineEvent.midi.size > 4)
- continue;
-
- midiEvent.port = engineEvent.midi.port;
- midiEvent.size = engineEvent.midi.size;
-
- midiEvent.data[0] = static_cast<uint8_t>(engineEvent.midi.data[0] | (engineEvent.channel & MIDI_CHANNEL_BIT));
-
- for (uint8_t j=1; j < midiEvent.size; ++j)
- midiEvent.data[j] = engineEvent.midi.data[j];
- }
- else
- {
- continue;
- }
-
- if (midiEvent.size > 0)
- pHost->write_midi_event(pHost->handle, &midiEvent);
- }
- }
- }
-
- // -------------------------------------------------------------------
- // Plugin UI calls
-
- #ifndef CARLA_ENGINE_WITHOUT_UI
- void uiShow(const bool show)
- {
- if (show)
- {
- if (fUiServer.isPipeRunning())
- {
- fUiServer.writeFocusMessage();
- return;
- }
-
- CarlaString path(pHost->resourceDir);
-
- if (kIsPatchbay)
- path += CARLA_OS_SEP_STR "carla-plugin-patchbay";
- else
- path += CARLA_OS_SEP_STR "carla-plugin";
- #ifdef CARLA_OS_WIN
- path += ".exe";
- #endif
- carla_stdout("Trying to start carla-plugin using \"%s\"", path.buffer());
-
- fUiServer.setData(path, pData->sampleRate, pHost->uiName);
-
- if (! fUiServer.startPipeServer(false))
- {
- pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_UI_UNAVAILABLE, 0, 0, nullptr, 0.0f);
- return;
- }
-
- uiServerInfo();
- uiServerOptions();
- uiServerCallback(ENGINE_CALLBACK_ENGINE_STARTED,
- pData->curPluginCount,
- pData->options.processMode,
- pData->options.transportMode,
- static_cast<int>(pData->bufferSize),
- static_cast<float>(pData->sampleRate),
- "Plugin");
-
- fUiServer.writeShowMessage();
-
- for (uint i=0; i < pData->curPluginCount; ++i)
- {
- if (const CarlaPluginPtr plugin = pData->plugins[i].plugin)
- if (plugin->isEnabled())
- uiServerCallback(ENGINE_CALLBACK_PLUGIN_ADDED, i, plugin->getType(),
- 0, 0, 0.0f,
- plugin->getName());
- }
-
- if (kIsPatchbay)
- patchbayRefresh(true, false, false);
- }
- else
- {
- fUiServer.stopPipeServer(2000);
-
- // hide all custom uis
- for (uint i=0; i < pData->curPluginCount; ++i)
- {
- if (const CarlaPluginPtr plugin = pData->plugins[i].plugin)
- {
- if (plugin->isEnabled())
- {
- if (plugin->getHints() & PLUGIN_HAS_CUSTOM_UI)
- {
- try {
- plugin->showCustomUI(false);
- } CARLA_SAFE_EXCEPTION_CONTINUE("Plugin showCustomUI (hide)");
- }
- }
- }
- }
- }
- }
- #endif
-
- void uiIdle()
- {
- #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
- const ScopedJuceMessageThreadRunner sjmtr(*this, false);
-
- if (kNeedsJuceEvents && ! sjmtr.wasLocked)
- return;
- #endif
-
- for (uint i=0; i < pData->curPluginCount; ++i)
- {
- if (const CarlaPluginPtr plugin = pData->plugins[i].plugin)
- {
- if (plugin->isEnabled())
- {
- const uint hints = plugin->getHints();
-
- if ((hints & PLUGIN_HAS_CUSTOM_UI) != 0 && (hints & PLUGIN_NEEDS_UI_MAIN_THREAD) != 0)
- {
- try {
- plugin->uiIdle();
- } CARLA_SAFE_EXCEPTION_CONTINUE("Plugin uiIdle");
- }
- }
- }
- }
-
- #ifndef CARLA_ENGINE_WITHOUT_UI
- idlePipe();
-
- switch (fUiServer.getAndResetUiState())
- {
- case CarlaExternalUI::UiNone:
- case CarlaExternalUI::UiShow:
- break;
- case CarlaExternalUI::UiCrashed:
- pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_UI_UNAVAILABLE, 0, 0, nullptr, 0.0f);
- break;
- case CarlaExternalUI::UiHide:
- pHost->ui_closed(pHost->handle);
- fUiServer.stopPipeServer(1000);
- break;
- }
- #endif
-
- if (carla_isNotEqual(fLastScaleFactor, pData->options.uiScale))
- {
- fLastScaleFactor = pData->options.uiScale;
- pHost->dispatcher(pHost->handle,
- NATIVE_HOST_OPCODE_UI_RESIZE,
- static_cast<int>(kUiWidth * fLastScaleFactor + 0.5f),
- static_cast<int>(kUiHeight * fLastScaleFactor + 0.5f),
- nullptr, 0.0f);
- }
-
- {
- const CarlaMutexLocker cml(fPluginDeleterMutex);
- pData->deletePluginsAsNeeded();
- }
- }
-
- void uiSetParameterValue(const uint32_t index, const float value)
- {
- uint32_t rindex = index;
- if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
- {
- if (plugin->getHints() & PLUGIN_HAS_CUSTOM_UI)
- plugin->uiParameterChange(rindex, value);
-
- #ifndef CARLA_ENGINE_WITHOUT_UI
- if (index >= kNumInParams || ! fUiServer.isPipeRunning())
- return;
-
- uiServerCallback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED,
- plugin->getId(),
- static_cast<int>(rindex),
- 0, 0,
- value,
- nullptr);
- #endif
- }
- }
-
- #ifndef CARLA_ENGINE_WITHOUT_UI
- void idlePipe()
- {
- if (! fUiServer.isPipeRunning())
- return;
-
- fUiServer.idlePipe();
-
- if (! fUiServer.isPipeRunning())
- return;
-
- char tmpBuf[STR_MAX+1];
- carla_zeroChars(tmpBuf, STR_MAX+1);
-
- const CarlaMutexLocker cml(fUiServer.getPipeLock());
- const CarlaScopedLocale csl;
- const EngineTimeInfo& timeInfo(pData->timeInfo);
-
- // ------------------------------------------------------------------------------------------------------------
- // send engine info
-
- std::snprintf(tmpBuf, STR_MAX, "%.12g:0\n", static_cast<double>(getDSPLoad()));
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("runtime-info\n"),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- fUiServer.flushMessages();
-
- if (const char* const projFolder = getCurrentProjectFolder())
- {
- if (fLastProjectFolder != projFolder)
- {
- carla_stdout("Project folder changed to %s", projFolder);
- fLastProjectFolder = projFolder;
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("project-folder\n"),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeAndFixMessage(projFolder),);
- fUiServer.flushMessages();
- }
- }
-
- // ------------------------------------------------------------------------------------------------------------
- // send transport
-
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("transport\n"),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(timeInfo.playing ? "true\n" : "false\n"),);
-
- if (timeInfo.bbt.valid)
- {
- std::snprintf(tmpBuf, STR_MAX, P_UINT64 ":%i:%i:%i\n", timeInfo.frame,
- timeInfo.bbt.bar,
- timeInfo.bbt.beat,
- static_cast<int>(timeInfo.bbt.tick + 0.5));
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- std::snprintf(tmpBuf, STR_MAX, "%.12g\n", timeInfo.bbt.beatsPerMinute);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- }
- else
- {
- std::snprintf(tmpBuf, STR_MAX, P_UINT64 ":0:0:0\n", timeInfo.frame);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage("0.0\n"),);
- }
-
- fUiServer.flushMessages();
-
- // ------------------------------------------------------------------------------------------------------------
- // send peaks and param outputs for all plugins
-
- for (uint i=0; i < pData->curPluginCount; ++i)
- {
- const EnginePluginData& plugData(pData->plugins[i]);
- const CarlaPluginPtr plugin = pData->plugins[i].plugin;
-
- std::snprintf(tmpBuf, STR_MAX, "PEAKS_%i\n", i);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- std::snprintf(tmpBuf, STR_MAX, "%.12g:%.12g:%.12g:%.12g\n",
- static_cast<double>(plugData.peaks[0]),
- static_cast<double>(plugData.peaks[1]),
- static_cast<double>(plugData.peaks[2]),
- static_cast<double>(plugData.peaks[3]));
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- fUiServer.flushMessages();
-
- for (uint32_t j=0, count=plugin->getParameterCount(); j < count; ++j)
- {
- if (! plugin->isParameterOutput(j))
- continue;
-
- std::snprintf(tmpBuf, STR_MAX, "PARAMVAL_%u:%u\n", i, j);
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
- std::snprintf(tmpBuf, STR_MAX, "%.12g\n", static_cast<double>(plugin->getParameterValue(j)));
- CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
-
- fUiServer.flushMessages();
- }
- }
- }
- #endif
-
- // -------------------------------------------------------------------
- // Plugin state calls
-
- char* getState() const
- {
- MemoryOutputStream out;
- saveProjectInternal(out);
- return strdup(out.toString().toRawUTF8());
- }
-
- void setState(const char* const data)
- {
- #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
- const ScopedJuceMessageThreadRunner sjmtr(*this, true);
- #endif
-
- // remove all plugins from UI side
- for (uint i=0, count=pData->curPluginCount; i < count; ++i)
- CarlaEngine::callback(true, true, ENGINE_CALLBACK_PLUGIN_REMOVED, count-i-1, 0, 0, 0, 0.0f, nullptr);
-
- // remove all plugins from backend, no lock
- fIsRunning = false;
- removeAllPlugins();
- fIsRunning = true;
-
- {
- const CarlaMutexLocker cml(fPluginDeleterMutex);
- pData->deletePluginsAsNeeded();
- }
-
- // stopped during removeAllPlugins()
- if (! pData->runner.isRunnerActive())
- pData->runner.start();
-
- fOptionsForced = true;
- const String state(data);
- XmlDocument xml(state);
- loadProjectInternal(xml, true);
-
- reloadFromUI();
- }
-
- // -------------------------------------------------------------------
-
- public:
- #define handlePtr ((CarlaEngineNative*)handle)
-
- static NativePluginHandle _instantiateRack(const NativeHostDescriptor* host)
- {
- return new CarlaEngineNative(host, false, true);
- }
-
- static NativePluginHandle _instantiateRackNoMidiOut(const NativeHostDescriptor* host)
- {
- return new CarlaEngineNative(host, false, false);
- }
-
- static NativePluginHandle _instantiatePatchbay(const NativeHostDescriptor* host)
- {
- return new CarlaEngineNative(host, true, true);
- }
-
- static NativePluginHandle _instantiatePatchbay3s(const NativeHostDescriptor* host)
- {
- return new CarlaEngineNative(host, true, true, 3, 2);
- }
-
- static NativePluginHandle _instantiatePatchbay16(const NativeHostDescriptor* host)
- {
- return new CarlaEngineNative(host, true, true, 16, 16);
- }
-
- static NativePluginHandle _instantiatePatchbay32(const NativeHostDescriptor* host)
- {
- return new CarlaEngineNative(host, true, true, 32, 32);
- }
-
- static NativePluginHandle _instantiatePatchbay64(const NativeHostDescriptor* host)
- {
- return new CarlaEngineNative(host, true, true, 64, 64);
- }
-
- static NativePluginHandle _instantiatePatchbayCV(const NativeHostDescriptor* host)
- {
- return new CarlaEngineNative(host, true, true, 2, 2, 5, 5);
- }
-
- static NativePluginHandle _instantiatePatchbayCV8(const NativeHostDescriptor* host)
- {
- return new CarlaEngineNative(host, true, true, 2, 2, 8, 8);
- }
-
- static NativePluginHandle _instantiatePatchbayCV32(const NativeHostDescriptor* host)
- {
- return new CarlaEngineNative(host, true, true, 64, 64, 32, 32);
- }
-
- static void _cleanup(NativePluginHandle handle)
- {
- delete handlePtr;
- }
-
- static uint32_t _get_parameter_count(NativePluginHandle handle)
- {
- return handlePtr->getParameterCount();
- }
-
- static const NativeParameter* _get_parameter_info(NativePluginHandle handle, uint32_t index)
- {
- return handlePtr->getParameterInfo(index);
- }
-
- static float _get_parameter_value(NativePluginHandle handle, uint32_t index)
- {
- return handlePtr->getParameterValue(index);
- }
-
- static void _set_parameter_value(NativePluginHandle handle, uint32_t index, float value)
- {
- handlePtr->setParameterValue(index, value);
- }
-
- #ifndef CARLA_ENGINE_WITHOUT_UI
- static void _ui_show(NativePluginHandle handle, bool show)
- {
- handlePtr->uiShow(show);
- }
- #endif
-
- static void _ui_idle(NativePluginHandle handle)
- {
- handlePtr->uiIdle();
- }
-
- static void _ui_set_parameter_value(NativePluginHandle handle, uint32_t index, float value)
- {
- handlePtr->uiSetParameterValue(index, value);
- }
-
- static void _activate(NativePluginHandle handle)
- {
- handlePtr->activate();
- }
-
- static void _deactivate(NativePluginHandle handle)
- {
- handlePtr->deactivate();
- }
-
- // FIXME for v3.0, use const for the input buffer
- static void _process(NativePluginHandle handle,
- float** inBuffer, float** outBuffer, const uint32_t frames,
- const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
- {
- handlePtr->process(inBuffer, outBuffer, frames, midiEvents, midiEventCount);
- }
-
- static char* _get_state(NativePluginHandle handle)
- {
- return handlePtr->getState();
- }
-
- static void _set_state(NativePluginHandle handle, const char* data)
- {
- handlePtr->setState(data);
- }
-
- static intptr_t _dispatcher(NativePluginHandle handle,
- NativePluginDispatcherOpcode opcode,
- int32_t index, intptr_t value, void* ptr, float opt)
- {
- switch(opcode)
- {
- case NATIVE_PLUGIN_OPCODE_NULL:
- return 0;
- case NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED:
- CARLA_SAFE_ASSERT_RETURN(value > 0, 0);
- handlePtr->bufferSizeChanged(static_cast<uint32_t>(value));
- return 0;
- case NATIVE_PLUGIN_OPCODE_SAMPLE_RATE_CHANGED:
- CARLA_SAFE_ASSERT_RETURN(opt > 0.0f, 0);
- handlePtr->sampleRateChanged(static_cast<double>(opt));
- return 0;
- case NATIVE_PLUGIN_OPCODE_OFFLINE_CHANGED:
- handlePtr->offlineModeChanged(value != 0);
- return 0;
- case NATIVE_PLUGIN_OPCODE_UI_NAME_CHANGED:
- //handlePtr->uiNameChanged(static_cast<const char*>(ptr));
- return 0;
- case NATIVE_PLUGIN_OPCODE_GET_INTERNAL_HANDLE: {
- CarlaEngineNative* const engine = handlePtr;
- return (intptr_t)(CarlaEngine*)engine;
- }
- case NATIVE_PLUGIN_OPCODE_IDLE:
- //handlePtr->idle();
- return 0;
- case NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT:
- return 0;
- case NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED:
- handlePtr->fUsesEmbed = true;
- return 0;
- }
-
- return 0;
-
- // unused
- (void)index;
- (void)ptr;
- }
-
- // -------------------------------------------------------------------
-
- #undef handlePtr
-
- private:
- const NativeHostDescriptor* const pHost;
-
- #ifdef USE_REFCOUNTER_JUCE_MESSAGE_MANAGER
- const bool kNeedsJuceEvents;
- const CarlaJUCE::ReferenceCountedJuceMessageMessager fJuceMsgMgr;
- CarlaMutex fJuceMsgMutex;
-
- struct ScopedJuceMessageThreadRunner {
- const CarlaMutexTryLocker cmtl;
- const bool wasLocked;
-
- ScopedJuceMessageThreadRunner(CarlaEngineNative& self, const bool forceLock) noexcept
- : cmtl(self.fJuceMsgMutex, forceLock),
- wasLocked(cmtl.wasLocked())
- {
- if (! self.kNeedsJuceEvents)
- return;
- if (! wasLocked)
- return;
-
- CarlaJUCE::setMessageManagerForThisThread();
- }
-
- ~ScopedJuceMessageThreadRunner()
- {
- CarlaJUCE::dispatchMessageManagerMessages();
- }
-
- CARLA_DECLARE_NON_COPYABLE(ScopedJuceMessageThreadRunner)
- };
- #endif
-
- const bool kIsPatchbay; // rack if false
- const bool kHasMidiOut;
- bool fIsActive, fIsRunning, fUsesEmbed;
- #ifndef CARLA_ENGINE_WITHOUT_UI
- CarlaEngineNativeUI fUiServer;
- #endif
- float fLastScaleFactor;
-
- float fParameters[kNumInParams+kNumOutParams];
- CarlaString fLastProjectFolder;
- CarlaMutex fPluginDeleterMutex;
-
- bool fOptionsForced;
-
- CarlaPluginPtr _getPluginForParameterIndex(uint32_t& index) const noexcept
- {
- if (pData->curPluginCount == 0 || pData->plugins == nullptr)
- return nullptr;
-
- for (uint32_t i=0; i<pData->curPluginCount; ++i)
- {
- const CarlaPluginPtr plugin = pData->plugins[i].plugin;
-
- if (plugin.get() == nullptr || ! plugin->isEnabled())
- break;
-
- if (const uint32_t paramCount = plugin->getParameterCount())
- {
- if (index >= paramCount)
- {
- index -= paramCount;
- continue;
- }
-
- return plugin;
- }
- }
-
- return nullptr;
- }
-
- bool _getRealIndexForPluginParameter(const uint32_t pluginId, uint32_t& rindex) const noexcept
- {
- if (pData->curPluginCount == 0 || pluginId >= pData->curPluginCount || pData->plugins == nullptr)
- return false;
-
- for (uint32_t i=0; i<pluginId; ++i)
- {
- const CarlaPluginPtr plugin = pData->plugins[i].plugin;
-
- if (plugin.get() == nullptr || ! plugin->isEnabled())
- return false;
-
- rindex += plugin->getParameterCount();
- }
-
- if (rindex >= kNumInParams)
- return false;
-
- return true;
- }
-
- CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineNative)
- };
-
- // -----------------------------------------------------------------------
-
- #ifndef CARLA_ENGINE_WITHOUT_UI
- bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
- {
- if (CarlaExternalUI::msgReceived(msg))
- return true;
-
- bool ok = true;
-
- if (std::strcmp(msg, "set_engine_option") == 0)
- {
- uint32_t option;
- int32_t value;
- const char* valueStr = nullptr;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(option), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(value), true);
- readNextLineAsString(valueStr, false); // can be null
-
- try {
- fEngine->setOption(static_cast<EngineOption>(option), value, valueStr);
- } CARLA_SAFE_EXCEPTION("setOption");
- }
- else if (std::strcmp(msg, "clear_engine_xruns") == 0)
- {
- fEngine->clearXruns();
- }
- else if (std::strcmp(msg, "cancel_engine_action") == 0)
- {
- fEngine->setActionCanceled(true);
- }
- else if (std::strcmp(msg, "load_file") == 0)
- {
- const char* filename;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);
-
- try {
- ok = fEngine->loadFile(filename);
- } CARLA_SAFE_EXCEPTION("loadFile");
-
- fEngine->reloadFromUI();
- }
- else if (std::strcmp(msg, "load_project") == 0)
- {
- const char* filename;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);
-
- try {
- ok = fEngine->loadProject(filename, true);
- } CARLA_SAFE_EXCEPTION("loadProject");
-
- fEngine->reloadFromUI();
- }
- else if (std::strcmp(msg, "save_project") == 0)
- {
- const char* filename;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);
-
- try {
- ok = fEngine->saveProject(filename, true);
- } CARLA_SAFE_EXCEPTION("saveProject");
- }
- else if (std::strcmp(msg, "clear_project_filename") == 0)
- {
- fEngine->clearCurrentProjectFilename();
- }
- else if (std::strcmp(msg, "patchbay_connect") == 0)
- {
- bool external;
- uint32_t groupA, portA, groupB, portB;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(external), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(groupA), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(portA), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(groupB), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(portB), true);
-
- try {
- ok = fEngine->patchbayConnect(external, groupA, portA, groupB, portB);
- } CARLA_SAFE_EXCEPTION("patchbayConnect");
- }
- else if (std::strcmp(msg, "patchbay_disconnect") == 0)
- {
- bool external;
- uint32_t connectionId;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(external), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(connectionId), true);
-
- try {
- ok = fEngine->patchbayDisconnect(external, connectionId);
- } CARLA_SAFE_EXCEPTION("patchbayDisconnect");
- }
- else if (std::strcmp(msg, "patchbay_set_group_pos") == 0)
- {
- bool external;
- uint32_t groupId;
- int x1, y1, x2, y2;
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(external), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(groupId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(x1), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(y1), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(x2), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(y2), true);
-
- try {
- ok = fEngine->patchbaySetGroupPos(false, true, external, groupId, x1, y1, x2, y2);
- } CARLA_SAFE_EXCEPTION("patchbaySetGroupPos");
- }
- else if (std::strcmp(msg, "patchbay_refresh") == 0)
- {
- bool external;
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(external), true);
-
- try {
- ok = fEngine->patchbayRefresh(true, false, external);
- } CARLA_SAFE_EXCEPTION("patchbayRefresh");
- }
- else if (std::strcmp(msg, "transport_play") == 0)
- {
- fEngine->transportPlay();
- }
- else if (std::strcmp(msg, "transport_pause") == 0)
- {
- fEngine->transportPause();
- }
- else if (std::strcmp(msg, "transport_bpm") == 0)
- {
- double bpm;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsDouble(bpm), true);
-
- fEngine->transportBPM(bpm);
- }
- else if (std::strcmp(msg, "transport_relocate") == 0)
- {
- uint64_t frame;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsULong(frame), true);
-
- fEngine->transportRelocate(frame);
- }
- else if (std::strcmp(msg, "add_plugin") == 0)
- {
- uint32_t btype, ptype;
- const char* filename = nullptr;
- const char* name;
- const char* label;
- int64_t uniqueId;
- uint options;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(btype), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(ptype), true);
- readNextLineAsString(filename, true); // can be null
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(name, true), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(label, true), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsLong(uniqueId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(options), true);
-
- if (filename != nullptr && std::strcmp(filename, "(null)") == 0)
- {
- std::free(const_cast<char*>(filename));
- filename = nullptr;
- }
-
- if (std::strcmp(name, "(null)") == 0)
- {
- std::free(const_cast<char*>(name));
- name = nullptr;
- }
-
- ok = fEngine->addPlugin(static_cast<BinaryType>(btype), static_cast<PluginType>(ptype),
- filename, name, label, uniqueId, nullptr, options);
-
- if (filename != nullptr)
- std::free(const_cast<char*>(filename));
- if (name != nullptr)
- std::free(const_cast<char*>(name));
- std::free(const_cast<char*>(label));
-
- fEngine->reloadFromUI();
- }
- else if (std::strcmp(msg, "remove_plugin") == 0)
- {
- uint32_t pluginId;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
-
- ok = fEngine->removePlugin(pluginId);
- fEngine->reloadFromUI();
- }
- else if (std::strcmp(msg, "remove_all_plugins") == 0)
- {
- ok = fEngine->removeAllPlugins();
- fEngine->reloadFromUI();
- }
- else if (std::strcmp(msg, "rename_plugin") == 0)
- {
- uint32_t pluginId;
- const char* newName;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(newName, false), true);
-
- ok = fEngine->renamePlugin(pluginId, newName);
- }
- else if (std::strcmp(msg, "clone_plugin") == 0)
- {
- uint32_t pluginId;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
-
- ok = fEngine->clonePlugin(pluginId);
- fEngine->reloadFromUI();
- }
- else if (std::strcmp(msg, "replace_plugin") == 0)
- {
- uint32_t pluginId;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
-
- ok = fEngine->replacePlugin(pluginId);
- }
- else if (std::strcmp(msg, "switch_plugins") == 0)
- {
- uint32_t pluginIdA, pluginIdB;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginIdA), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginIdB), true);
-
- ok = fEngine->switchPlugins(pluginIdA, pluginIdB);
- fEngine->reloadFromUI();
- }
- else if (std::strcmp(msg, "load_plugin_state") == 0)
- {
- uint32_t pluginId;
- const char* filename;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- {
- plugin->loadStateFromFile(filename);
- _updateParamValues(plugin, pluginId, false, true);
- }
- }
- else if (std::strcmp(msg, "save_plugin_state") == 0)
- {
- uint32_t pluginId;
- const char* filename;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->saveStateToFile(filename);
- }
- else if (std::strcmp(msg, "set_option") == 0)
- {
- uint32_t pluginId, option;
- bool yesNo;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(option), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(yesNo), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setOption(option, yesNo, false);
- }
- else if (std::strcmp(msg, "set_active") == 0)
- {
- uint32_t pluginId;
- bool onOff;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(onOff), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setActive(onOff, true, false);
- }
- else if (std::strcmp(msg, "set_drywet") == 0)
- {
- uint32_t pluginId;
- float value;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setDryWet(value, true, false);
- }
- else if (std::strcmp(msg, "set_volume") == 0)
- {
- uint32_t pluginId;
- float value;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setVolume(value, true, false);
- }
- else if (std::strcmp(msg, "set_balance_left") == 0)
- {
- uint32_t pluginId;
- float value;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setBalanceLeft(value, true, false);
- }
- else if (std::strcmp(msg, "set_balance_right") == 0)
- {
- uint32_t pluginId;
- float value;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setBalanceRight(value, true, false);
- }
- else if (std::strcmp(msg, "set_panning") == 0)
- {
- uint32_t pluginId;
- float value;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setPanning(value, true, false);
- }
- else if (std::strcmp(msg, "set_ctrl_channel") == 0)
- {
- uint32_t pluginId;
- int32_t channel;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(channel), true);
- CARLA_SAFE_ASSERT_RETURN(channel >= -1 && channel < MAX_MIDI_CHANNELS, true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setCtrlChannel(int8_t(channel), true, false);
- }
- else if (std::strcmp(msg, "set_parameter_value") == 0)
- {
- uint32_t pluginId, parameterId;
- float value;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- {
- plugin->setParameterValue(parameterId, value, true, true, false);
- fEngine->setParameterValueFromUI(pluginId, parameterId, value);
- }
- }
- else if (std::strcmp(msg, "set_parameter_midi_channel") == 0)
- {
- uint32_t pluginId, parameterId, channel;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(channel), true);
- CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setParameterMidiChannel(parameterId, static_cast<uint8_t>(channel), true, false);
- }
- else if (std::strcmp(msg, "set_parameter_mapped_control_index") == 0)
- {
- uint32_t pluginId, parameterId;
- int32_t ctrl;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(ctrl), true);
- CARLA_SAFE_ASSERT_RETURN(ctrl >= CONTROL_INDEX_NONE && ctrl <= CONTROL_INDEX_MAX_ALLOWED, true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setParameterMappedControlIndex(parameterId, static_cast<int16_t>(ctrl), true, false, true);
- }
- else if (std::strcmp(msg, "set_parameter_mapped_range") == 0)
- {
- uint32_t pluginId, parameterId;
- float minimum, maximum;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(minimum), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(maximum), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setParameterMappedRange(parameterId, minimum, maximum, true, false);
- }
- else if (std::strcmp(msg, "set_parameter_touch") == 0)
- {
- uint32_t pluginId, parameterId;
- bool touching;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(touching), true);
-
- if (fEngine->getPlugin(pluginId))
- fEngine->setParameterTouchFromUI(pluginId, parameterId, touching);
- }
- else if (std::strcmp(msg, "set_program") == 0)
- {
- uint32_t pluginId;
- int32_t index;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(index), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- {
- plugin->setProgram(index, true, true, false);
- _updateParamValues(plugin, pluginId, true, true);
- }
- }
- else if (std::strcmp(msg, "set_midi_program") == 0)
- {
- uint32_t pluginId;
- int32_t index;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(index), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- {
- plugin->setMidiProgram(index, true, true, false);
- _updateParamValues(plugin, pluginId, true, true);
- }
- }
- else if (std::strcmp(msg, "set_custom_data") == 0)
- {
- uint32_t pluginId;
- const char* type;
- const char* key;
- const char* value;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(type, true), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(key, true), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(value, false), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->setCustomData(type, key, value, true);
-
- std::free(const_cast<char*>(type));
- std::free(const_cast<char*>(key));
- }
- else if (std::strcmp(msg, "set_chunk_data") == 0)
- {
- uint32_t pluginId;
- const char* cdata;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(cdata, false), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- {
- std::vector<uint8_t> chunk(carla_getChunkFromBase64String(cdata));
- #ifdef CARLA_PROPER_CPP11_SUPPORT
- plugin->setChunkData(chunk.data(), chunk.size());
- #else
- plugin->setChunkData(&chunk.front(), chunk.size());
- #endif
- _updateParamValues(plugin, pluginId, false, true);
- }
- }
- else if (std::strcmp(msg, "prepare_for_save") == 0)
- {
- uint32_t pluginId;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->prepareForSave(false);
- }
- else if (std::strcmp(msg, "reset_parameters") == 0)
- {
- uint32_t pluginId;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- {
- plugin->resetParameters();
- _updateParamValues(plugin, pluginId, false, true);
- }
- }
- else if (std::strcmp(msg, "randomize_parameters") == 0)
- {
- uint32_t pluginId;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- {
- plugin->randomizeParameters();
- _updateParamValues(plugin, pluginId, false, true);
- }
- }
- else if (std::strcmp(msg, "send_midi_note") == 0)
- {
- uint32_t pluginId, channel, note, velocity;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(channel), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(note), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(velocity), true);
- CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, true);
- CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_VALUE, true);
- CARLA_SAFE_ASSERT_RETURN(velocity < MAX_MIDI_VALUE, true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->sendMidiSingleNote(static_cast<uint8_t>(channel), static_cast<uint8_t>(note), static_cast<uint8_t>(velocity), true, true, false);
- }
- else if (std::strcmp(msg, "show_custom_ui") == 0)
- {
- uint32_t pluginId;
- bool yesNo;
-
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
- CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(yesNo), true);
-
- if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
- plugin->showCustomUI(yesNo);
- }
- else
- {
- carla_stderr("CarlaEngineNativeUI::msgReceived : %s", msg);
- return false;
- }
-
- if (! ok)
- {
- const CarlaMutexLocker cml(getPipeLock());
-
- if (writeMessage("error\n", 6) && writeAndFixMessage(fEngine->getLastError()))
- flushMessages();
- }
-
- return true;
- }
-
- void CarlaEngineNativeUI::_updateParamValues(const CarlaPluginPtr& plugin,
- const uint32_t pluginId,
- const bool sendCallback, const bool sendPluginHost) const noexcept
- {
- float value;
-
- for (uint32_t i=0, count=plugin->getParameterCount(); i<count; ++i) {
- value = plugin->getParameterValue(i);
-
- if (sendCallback) {
- fEngine->callback(true, true,
- ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED,
- pluginId,
- static_cast<int>(i),
- 0, 0,
- value,
- nullptr);
- }
-
- if (sendPluginHost) {
- carla_stdout("_updateParamValues");
- fEngine->setParameterValueFromUI(pluginId, i, value);
- }
- }
- }
- #endif
-
- // -----------------------------------------------------------------------
-
- static const NativePluginDescriptor carlaRackDesc = {
- /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
- /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
- |NATIVE_PLUGIN_HAS_UI
- |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
- |NATIVE_PLUGIN_USES_STATE
- |NATIVE_PLUGIN_USES_TIME
- |NATIVE_PLUGIN_USES_UI_SIZE),
- /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 1,
- /* midiOuts */ 1,
- /* paramIns */ kNumInParams,
- /* paramOuts */ kNumOutParams,
- /* name */ "Carla-Rack",
- /* label */ "carlarack",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- CarlaEngineNative::_instantiateRack,
- CarlaEngineNative::_cleanup,
- CarlaEngineNative::_get_parameter_count,
- CarlaEngineNative::_get_parameter_info,
- CarlaEngineNative::_get_parameter_value,
- /* _get_midi_program_count */ nullptr,
- /* _get_midi_program_info */ nullptr,
- CarlaEngineNative::_set_parameter_value,
- /* _set_midi_program */ nullptr,
- /* _set_custom_data */ nullptr,
- #ifndef CARLA_ENGINE_WITHOUT_UI
- CarlaEngineNative::_ui_show,
- #else
- nullptr,
- #endif
- CarlaEngineNative::_ui_idle,
- CarlaEngineNative::_ui_set_parameter_value,
- /* _ui_set_midi_program */ nullptr,
- /* _ui_set_custom_data */ nullptr,
- CarlaEngineNative::_activate,
- CarlaEngineNative::_deactivate,
- CarlaEngineNative::_process,
- CarlaEngineNative::_get_state,
- CarlaEngineNative::_set_state,
- CarlaEngineNative::_dispatcher,
- /* _render_inline_dsplay */ nullptr,
- /* cvIns */ 0,
- /* cvOuts */ 0,
- /* _get_buffer_port_name */ nullptr,
- /* _get_buffer_port_range */ nullptr,
- /* ui_width */ kUiWidth,
- /* ui_height */ kUiHeight
- };
-
- static const NativePluginDescriptor carlaRackNoMidiOutDesc = {
- /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
- /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
- |NATIVE_PLUGIN_HAS_UI
- |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
- |NATIVE_PLUGIN_USES_STATE
- |NATIVE_PLUGIN_USES_TIME
- |NATIVE_PLUGIN_USES_UI_SIZE),
- /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 1,
- /* midiOuts */ 0,
- /* paramIns */ kNumInParams,
- /* paramOuts */ kNumOutParams,
- /* name */ "Carla-Rack (no midi out)",
- /* label */ "carlarack-nomidiout",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- CarlaEngineNative::_instantiateRackNoMidiOut,
- CarlaEngineNative::_cleanup,
- CarlaEngineNative::_get_parameter_count,
- CarlaEngineNative::_get_parameter_info,
- CarlaEngineNative::_get_parameter_value,
- /* _get_midi_program_count */ nullptr,
- /* _get_midi_program_info */ nullptr,
- CarlaEngineNative::_set_parameter_value,
- /* _set_midi_program */ nullptr,
- /* _set_custom_data */ nullptr,
- #ifndef CARLA_ENGINE_WITHOUT_UI
- CarlaEngineNative::_ui_show,
- #else
- nullptr,
- #endif
- CarlaEngineNative::_ui_idle,
- CarlaEngineNative::_ui_set_parameter_value,
- /* _ui_set_midi_program */ nullptr,
- /* _ui_set_custom_data */ nullptr,
- CarlaEngineNative::_activate,
- CarlaEngineNative::_deactivate,
- CarlaEngineNative::_process,
- CarlaEngineNative::_get_state,
- CarlaEngineNative::_set_state,
- CarlaEngineNative::_dispatcher,
- /* _render_inline_dsplay */ nullptr,
- /* cvIns */ 0,
- /* cvOuts */ 0,
- /* _get_buffer_port_name */ nullptr,
- /* _get_buffer_port_range */ nullptr,
- /* ui_width */ kUiWidth,
- /* ui_height */ kUiHeight
- };
-
- static const NativePluginDescriptor carlaPatchbayDesc = {
- /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
- /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
- |NATIVE_PLUGIN_HAS_UI
- |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
- |NATIVE_PLUGIN_USES_STATE
- |NATIVE_PLUGIN_USES_TIME
- |NATIVE_PLUGIN_USES_UI_SIZE),
- /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 1,
- /* midiOuts */ 1,
- /* paramIns */ kNumInParams,
- /* paramOuts */ kNumOutParams,
- /* name */ "Carla-Patchbay",
- /* label */ "carlapatchbay",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- CarlaEngineNative::_instantiatePatchbay,
- CarlaEngineNative::_cleanup,
- CarlaEngineNative::_get_parameter_count,
- CarlaEngineNative::_get_parameter_info,
- CarlaEngineNative::_get_parameter_value,
- /* _get_midi_program_count */ nullptr,
- /* _get_midi_program_info */ nullptr,
- CarlaEngineNative::_set_parameter_value,
- /* _set_midi_program */ nullptr,
- /* _set_custom_data */ nullptr,
- #ifndef CARLA_ENGINE_WITHOUT_UI
- CarlaEngineNative::_ui_show,
- #else
- nullptr,
- #endif
- CarlaEngineNative::_ui_idle,
- CarlaEngineNative::_ui_set_parameter_value,
- /* _ui_set_midi_program */ nullptr,
- /* _ui_set_custom_data */ nullptr,
- CarlaEngineNative::_activate,
- CarlaEngineNative::_deactivate,
- CarlaEngineNative::_process,
- CarlaEngineNative::_get_state,
- CarlaEngineNative::_set_state,
- CarlaEngineNative::_dispatcher,
- /* _render_inline_dsplay */ nullptr,
- /* cvIns */ 0,
- /* cvOuts */ 0,
- /* _get_buffer_port_name */ nullptr,
- /* _get_buffer_port_range */ nullptr,
- /* ui_width */ kUiWidth,
- /* ui_height */ kUiHeight
- };
-
- static const NativePluginDescriptor carlaPatchbay3sDesc = {
- /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
- /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
- |NATIVE_PLUGIN_HAS_UI
- |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
- |NATIVE_PLUGIN_USES_STATE
- |NATIVE_PLUGIN_USES_TIME
- |NATIVE_PLUGIN_USES_UI_SIZE),
- /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
- /* audioIns */ 3,
- /* audioOuts */ 2,
- /* midiIns */ 1,
- /* midiOuts */ 1,
- /* paramIns */ kNumInParams,
- /* paramOuts */ kNumOutParams,
- /* name */ "Carla-Patchbay (sidechain)",
- /* label */ "carlapatchbay3s",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- CarlaEngineNative::_instantiatePatchbay3s,
- CarlaEngineNative::_cleanup,
- CarlaEngineNative::_get_parameter_count,
- CarlaEngineNative::_get_parameter_info,
- CarlaEngineNative::_get_parameter_value,
- /* _get_midi_program_count */ nullptr,
- /* _get_midi_program_info */ nullptr,
- CarlaEngineNative::_set_parameter_value,
- /* _set_midi_program */ nullptr,
- /* _set_custom_data */ nullptr,
- #ifndef CARLA_ENGINE_WITHOUT_UI
- CarlaEngineNative::_ui_show,
- #else
- nullptr,
- #endif
- CarlaEngineNative::_ui_idle,
- CarlaEngineNative::_ui_set_parameter_value,
- /* _ui_set_midi_program */ nullptr,
- /* _ui_set_custom_data */ nullptr,
- CarlaEngineNative::_activate,
- CarlaEngineNative::_deactivate,
- CarlaEngineNative::_process,
- CarlaEngineNative::_get_state,
- CarlaEngineNative::_set_state,
- CarlaEngineNative::_dispatcher,
- /* _render_inline_dsplay */ nullptr,
- /* cvIns */ 0,
- /* cvOuts */ 0,
- /* _get_buffer_port_name */ nullptr,
- /* _get_buffer_port_range */ nullptr,
- /* ui_width */ kUiWidth,
- /* ui_height */ kUiHeight
- };
-
- static const NativePluginDescriptor carlaPatchbay16Desc = {
- /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
- /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
- |NATIVE_PLUGIN_HAS_UI
- |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
- |NATIVE_PLUGIN_USES_STATE
- |NATIVE_PLUGIN_USES_TIME
- |NATIVE_PLUGIN_USES_UI_SIZE),
- /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
- /* audioIns */ 16,
- /* audioOuts */ 16,
- /* midiIns */ 1,
- /* midiOuts */ 1,
- /* paramIns */ kNumInParams,
- /* paramOuts */ kNumOutParams,
- /* name */ "Carla-Patchbay (16chan)",
- /* label */ "carlapatchbay16",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- CarlaEngineNative::_instantiatePatchbay16,
- CarlaEngineNative::_cleanup,
- CarlaEngineNative::_get_parameter_count,
- CarlaEngineNative::_get_parameter_info,
- CarlaEngineNative::_get_parameter_value,
- /* _get_midi_program_count */ nullptr,
- /* _get_midi_program_info */ nullptr,
- CarlaEngineNative::_set_parameter_value,
- /* _set_midi_program */ nullptr,
- /* _set_custom_data */ nullptr,
- #ifndef CARLA_ENGINE_WITHOUT_UI
- CarlaEngineNative::_ui_show,
- #else
- nullptr,
- #endif
- CarlaEngineNative::_ui_idle,
- CarlaEngineNative::_ui_set_parameter_value,
- /* _ui_set_midi_program */ nullptr,
- /* _ui_set_custom_data */ nullptr,
- CarlaEngineNative::_activate,
- CarlaEngineNative::_deactivate,
- CarlaEngineNative::_process,
- CarlaEngineNative::_get_state,
- CarlaEngineNative::_set_state,
- CarlaEngineNative::_dispatcher,
- /* _render_inline_dsplay */ nullptr,
- /* cvIns */ 0,
- /* cvOuts */ 0,
- /* _get_buffer_port_name */ nullptr,
- /* _get_buffer_port_range */ nullptr,
- /* ui_width */ kUiWidth,
- /* ui_height */ kUiHeight
- };
-
- static const NativePluginDescriptor carlaPatchbay32Desc = {
- /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
- /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
- |NATIVE_PLUGIN_HAS_UI
- |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
- |NATIVE_PLUGIN_USES_STATE
- |NATIVE_PLUGIN_USES_TIME
- |NATIVE_PLUGIN_USES_UI_SIZE),
- /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
- /* audioIns */ 32,
- /* audioOuts */ 32,
- /* midiIns */ 1,
- /* midiOuts */ 1,
- /* paramIns */ kNumInParams,
- /* paramOuts */ kNumOutParams,
- /* name */ "Carla-Patchbay (32chan)",
- /* label */ "carlapatchbay32",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- CarlaEngineNative::_instantiatePatchbay32,
- CarlaEngineNative::_cleanup,
- CarlaEngineNative::_get_parameter_count,
- CarlaEngineNative::_get_parameter_info,
- CarlaEngineNative::_get_parameter_value,
- /* _get_midi_program_count */ nullptr,
- /* _get_midi_program_info */ nullptr,
- CarlaEngineNative::_set_parameter_value,
- /* _set_midi_program */ nullptr,
- /* _set_custom_data */ nullptr,
- #ifndef CARLA_ENGINE_WITHOUT_UI
- CarlaEngineNative::_ui_show,
- #else
- nullptr,
- #endif
- CarlaEngineNative::_ui_idle,
- CarlaEngineNative::_ui_set_parameter_value,
- /* _ui_set_midi_program */ nullptr,
- /* _ui_set_custom_data */ nullptr,
- CarlaEngineNative::_activate,
- CarlaEngineNative::_deactivate,
- CarlaEngineNative::_process,
- CarlaEngineNative::_get_state,
- CarlaEngineNative::_set_state,
- CarlaEngineNative::_dispatcher,
- /* _render_inline_dsplay */ nullptr,
- /* cvIns */ 0,
- /* cvOuts */ 0,
- /* _get_buffer_port_name */ nullptr,
- /* _get_buffer_port_range */ nullptr,
- /* ui_width */ kUiWidth,
- /* ui_height */ kUiHeight
- };
-
- static const NativePluginDescriptor carlaPatchbay64Desc = {
- /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
- /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
- |NATIVE_PLUGIN_HAS_UI
- |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
- |NATIVE_PLUGIN_USES_STATE
- |NATIVE_PLUGIN_USES_TIME
- |NATIVE_PLUGIN_USES_UI_SIZE),
- /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
- /* audioIns */ 64,
- /* audioOuts */ 64,
- /* midiIns */ 1,
- /* midiOuts */ 1,
- /* paramIns */ kNumInParams,
- /* paramOuts */ kNumOutParams,
- /* name */ "Carla-Patchbay (64chan)",
- /* label */ "carlapatchbay64",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- CarlaEngineNative::_instantiatePatchbay64,
- CarlaEngineNative::_cleanup,
- CarlaEngineNative::_get_parameter_count,
- CarlaEngineNative::_get_parameter_info,
- CarlaEngineNative::_get_parameter_value,
- /* _get_midi_program_count */ nullptr,
- /* _get_midi_program_info */ nullptr,
- CarlaEngineNative::_set_parameter_value,
- /* _set_midi_program */ nullptr,
- /* _set_custom_data */ nullptr,
- #ifndef CARLA_ENGINE_WITHOUT_UI
- CarlaEngineNative::_ui_show,
- #else
- nullptr,
- #endif
- CarlaEngineNative::_ui_idle,
- CarlaEngineNative::_ui_set_parameter_value,
- /* _ui_set_midi_program */ nullptr,
- /* _ui_set_custom_data */ nullptr,
- CarlaEngineNative::_activate,
- CarlaEngineNative::_deactivate,
- CarlaEngineNative::_process,
- CarlaEngineNative::_get_state,
- CarlaEngineNative::_set_state,
- CarlaEngineNative::_dispatcher,
- /* _render_inline_dsplay */ nullptr,
- /* cvIns */ 0,
- /* cvOuts */ 0,
- /* _get_buffer_port_name */ nullptr,
- /* _get_buffer_port_range */ nullptr,
- /* ui_width */ kUiWidth,
- /* ui_height */ kUiHeight
- };
-
- static const NativePluginDescriptor carlaPatchbayCVDesc = {
- /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
- /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
- |NATIVE_PLUGIN_HAS_UI
- |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
- |NATIVE_PLUGIN_USES_CONTROL_VOLTAGE
- |NATIVE_PLUGIN_USES_STATE
- |NATIVE_PLUGIN_USES_TIME
- |NATIVE_PLUGIN_USES_UI_SIZE),
- /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 1,
- /* midiOuts */ 1,
- /* paramIns */ kNumInParams,
- /* paramOuts */ kNumOutParams,
- /* name */ "Carla-Patchbay (CV)",
- /* label */ "carlapatchbaycv",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- CarlaEngineNative::_instantiatePatchbayCV,
- CarlaEngineNative::_cleanup,
- CarlaEngineNative::_get_parameter_count,
- CarlaEngineNative::_get_parameter_info,
- CarlaEngineNative::_get_parameter_value,
- /* _get_midi_program_count */ nullptr,
- /* _get_midi_program_info */ nullptr,
- CarlaEngineNative::_set_parameter_value,
- /* _set_midi_program */ nullptr,
- /* _set_custom_data */ nullptr,
- #ifndef CARLA_ENGINE_WITHOUT_UI
- CarlaEngineNative::_ui_show,
- #else
- nullptr,
- #endif
- CarlaEngineNative::_ui_idle,
- CarlaEngineNative::_ui_set_parameter_value,
- /* _ui_set_midi_program */ nullptr,
- /* _ui_set_custom_data */ nullptr,
- CarlaEngineNative::_activate,
- CarlaEngineNative::_deactivate,
- CarlaEngineNative::_process,
- CarlaEngineNative::_get_state,
- CarlaEngineNative::_set_state,
- CarlaEngineNative::_dispatcher,
- /* _render_inline_dsplay */ nullptr,
- /* cvIns */ 5,
- /* cvOuts */ 5,
- /* _get_buffer_port_name */ nullptr,
- /* _get_buffer_port_range */ nullptr,
- /* ui_width */ kUiWidth,
- /* ui_height */ kUiHeight
- };
-
- static const NativePluginDescriptor carlaPatchbayCV8Desc = {
- /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
- /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
- |NATIVE_PLUGIN_HAS_UI
- |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
- |NATIVE_PLUGIN_USES_CONTROL_VOLTAGE
- |NATIVE_PLUGIN_USES_STATE
- |NATIVE_PLUGIN_USES_TIME
- |NATIVE_PLUGIN_USES_UI_SIZE),
- /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 1,
- /* midiOuts */ 1,
- /* paramIns */ kNumInParams,
- /* paramOuts */ kNumOutParams,
- /* name */ "Carla-Patchbay (CV8)",
- /* label */ "carlapatchbaycv",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- CarlaEngineNative::_instantiatePatchbayCV8,
- CarlaEngineNative::_cleanup,
- CarlaEngineNative::_get_parameter_count,
- CarlaEngineNative::_get_parameter_info,
- CarlaEngineNative::_get_parameter_value,
- /* _get_midi_program_count */ nullptr,
- /* _get_midi_program_info */ nullptr,
- CarlaEngineNative::_set_parameter_value,
- /* _set_midi_program */ nullptr,
- /* _set_custom_data */ nullptr,
- #ifndef CARLA_ENGINE_WITHOUT_UI
- CarlaEngineNative::_ui_show,
- #else
- nullptr,
- #endif
- CarlaEngineNative::_ui_idle,
- CarlaEngineNative::_ui_set_parameter_value,
- /* _ui_set_midi_program */ nullptr,
- /* _ui_set_custom_data */ nullptr,
- CarlaEngineNative::_activate,
- CarlaEngineNative::_deactivate,
- CarlaEngineNative::_process,
- CarlaEngineNative::_get_state,
- CarlaEngineNative::_set_state,
- CarlaEngineNative::_dispatcher,
- /* _render_inline_dsplay */ nullptr,
- /* cvIns */ 8,
- /* cvOuts */ 8,
- /* _get_buffer_port_name */ nullptr,
- /* _get_buffer_port_range */ nullptr,
- /* ui_width */ kUiWidth,
- /* ui_height */ kUiHeight
- };
-
- static const NativePluginDescriptor carlaPatchbayCV32Desc = {
- /* category */ NATIVE_PLUGIN_CATEGORY_OTHER,
- /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_SYNTH
- |NATIVE_PLUGIN_HAS_UI
- |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
- |NATIVE_PLUGIN_USES_CONTROL_VOLTAGE
- |NATIVE_PLUGIN_USES_STATE
- |NATIVE_PLUGIN_USES_TIME
- |NATIVE_PLUGIN_USES_UI_SIZE),
- /* supports */ static_cast<NativePluginSupports>(NATIVE_PLUGIN_SUPPORTS_EVERYTHING),
- /* audioIns */ 64,
- /* audioOuts */ 64,
- /* midiIns */ 1,
- /* midiOuts */ 1,
- /* paramIns */ kNumInParams,
- /* paramOuts */ kNumOutParams,
- /* name */ "Carla-Patchbay (CV32)",
- /* label */ "carlapatchbaycv",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- CarlaEngineNative::_instantiatePatchbayCV32,
- CarlaEngineNative::_cleanup,
- CarlaEngineNative::_get_parameter_count,
- CarlaEngineNative::_get_parameter_info,
- CarlaEngineNative::_get_parameter_value,
- /* _get_midi_program_count */ nullptr,
- /* _get_midi_program_info */ nullptr,
- CarlaEngineNative::_set_parameter_value,
- /* _set_midi_program */ nullptr,
- /* _set_custom_data */ nullptr,
- #ifndef CARLA_ENGINE_WITHOUT_UI
- CarlaEngineNative::_ui_show,
- #else
- nullptr,
- #endif
- CarlaEngineNative::_ui_idle,
- CarlaEngineNative::_ui_set_parameter_value,
- /* _ui_set_midi_program */ nullptr,
- /* _ui_set_custom_data */ nullptr,
- CarlaEngineNative::_activate,
- CarlaEngineNative::_deactivate,
- CarlaEngineNative::_process,
- CarlaEngineNative::_get_state,
- CarlaEngineNative::_set_state,
- CarlaEngineNative::_dispatcher,
- /* _render_inline_dsplay */ nullptr,
- /* cvIns */ 32,
- /* cvOuts */ 32,
- /* _get_buffer_port_name */ nullptr,
- /* _get_buffer_port_range */ nullptr,
- /* ui_width */ kUiWidth,
- /* ui_height */ kUiHeight
- };
-
- CARLA_BACKEND_END_NAMESPACE
-
- // -----------------------------------------------------------------------
-
- CARLA_API_EXPORT
- void carla_register_native_plugin_carla();
-
- void carla_register_native_plugin_carla()
- {
- CARLA_BACKEND_USE_NAMESPACE;
- carla_register_native_plugin(&carlaRackDesc);
- carla_register_native_plugin(&carlaRackNoMidiOutDesc);
- carla_register_native_plugin(&carlaPatchbayDesc);
- carla_register_native_plugin(&carlaPatchbay3sDesc);
- carla_register_native_plugin(&carlaPatchbay16Desc);
- carla_register_native_plugin(&carlaPatchbay32Desc);
- carla_register_native_plugin(&carlaPatchbay64Desc);
- carla_register_native_plugin(&carlaPatchbayCVDesc);
- }
-
- // -----------------------------------------------------------------------
-
- const NativePluginDescriptor* carla_get_native_rack_plugin()
- {
- CARLA_BACKEND_USE_NAMESPACE;
- return &carlaRackDesc;
- }
-
- const NativePluginDescriptor* carla_get_native_patchbay_plugin()
- {
- CARLA_BACKEND_USE_NAMESPACE;
- return &carlaPatchbayDesc;
- }
-
- const NativePluginDescriptor* carla_get_native_patchbay16_plugin()
- {
- CARLA_BACKEND_USE_NAMESPACE;
- return &carlaPatchbay16Desc;
- }
-
- const NativePluginDescriptor* carla_get_native_patchbay32_plugin()
- {
- CARLA_BACKEND_USE_NAMESPACE;
- return &carlaPatchbay32Desc;
- }
-
- const NativePluginDescriptor* carla_get_native_patchbay64_plugin()
- {
- CARLA_BACKEND_USE_NAMESPACE;
- return &carlaPatchbay64Desc;
- }
-
- const NativePluginDescriptor* carla_get_native_patchbay_cv_plugin()
- {
- CARLA_BACKEND_USE_NAMESPACE;
- return &carlaPatchbayCVDesc;
- }
-
- const NativePluginDescriptor* carla_get_native_patchbay_cv8_plugin()
- {
- CARLA_BACKEND_USE_NAMESPACE;
- return &carlaPatchbayCV8Desc;
- }
-
- const NativePluginDescriptor* carla_get_native_patchbay_cv32_plugin()
- {
- CARLA_BACKEND_USE_NAMESPACE;
- return &carlaPatchbayCV32Desc;
- }
-
- // -----------------------------------------------------------------------
- // Extra stuff for linking purposes
-
- #ifdef CARLA_PLUGIN_BUILD
-
- CARLA_BACKEND_START_NAMESPACE
-
- namespace EngineInit {
-
- CarlaEngine* newJack() { return nullptr; }
-
- #ifdef USING_JUCE_AUDIO_DEVICES
- CarlaEngine* newJuce(const AudioApi) { return nullptr; }
- uint getJuceApiCount() { return 0; }
- const char* getJuceApiName(const uint) { return nullptr; }
- const char* const* getJuceApiDeviceNames(const uint) { return nullptr; }
- const EngineDriverDeviceInfo* getJuceDeviceInfo(const uint, const char* const) { return nullptr; }
- bool showJuceDeviceControlPanel(const uint, const char* const) { return false; }
- #endif
-
- #ifdef USING_RTAUDIO
- CarlaEngine* newRtAudio(const AudioApi) { return nullptr; }
- uint getRtAudioApiCount() { return 0; }
- const char* getRtAudioApiName(const uint) { return nullptr; }
- const char* const* getRtAudioApiDeviceNames(const uint) { return nullptr; }
- const EngineDriverDeviceInfo* getRtAudioDeviceInfo(const uint, const char* const) { return nullptr; }
- #endif
-
- #ifdef HAVE_SDL
- CarlaEngine* newSDL() { return nullptr; }
- const char* const* getSDLDeviceNames() { return nullptr; }
- #endif
-
- }
-
- CARLA_BACKEND_END_NAMESPACE
-
- #define CARLA_PLUGIN_UI_CLASS_PREFIX Plugin
- #include "CarlaPluginUI.cpp"
- # undef CARLA_PLUGIN_UI_CLASS_PREFIX
- #include "CarlaDssiUtils.cpp"
- #include "CarlaMacUtils.cpp"
- #include "CarlaPatchbayUtils.cpp"
- #include "CarlaPipeUtils.cpp"
- #include "CarlaProcessUtils.cpp"
- #include "CarlaStateUtils.cpp"
-
- #endif /* CARLA_PLUGIN_BUILD */
-
- // -----------------------------------------------------------------------
|