|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515 |
- /*
- * Carla Engine
- * Copyright (C) 2012-2013 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 GPL.txt file
- */
-
- #include "CarlaEngineInternal.hpp"
- #include "CarlaBackendUtils.hpp"
- #include "CarlaStateUtils.hpp"
- #include "CarlaMIDI.h"
-
- #include <QtCore/QDir>
- #include <QtCore/QFile>
- #include <QtCore/QFileInfo>
- #include <QtCore/QTextStream>
-
- // -------------------------------------------------------------------------------------------------------------------
- // Register native engine plugin
-
- #ifndef BUILD_BRIDGE
- # include "CarlaNative.h"
-
- void carla_register_native_plugin_carla()
- {
- CARLA_BACKEND_USE_NAMESPACE;
- CarlaEngine::registerNativePlugin();
- }
- #endif
-
- // -------------------------------------------------------------------------------------------------------------------
-
- CARLA_BACKEND_START_NAMESPACE
-
- // -------------------------------------------------------------------------------------------------------------------
- // Fallback data
-
- static const EngineEvent kFallbackEngineEvent;
-
- #ifndef BUILD_BRIDGE
- // -------------------------------------------------------------------------------------------------------------------
- // Bridge Helper, defined in CarlaPlugin.cpp
-
- extern BinaryType CarlaPluginGetBridgeBinaryType(CarlaPlugin* const plugin);
-
- // -------------------------------------------------------------------------------------------------------------------
- // Engine Helpers
-
- void registerEnginePlugin(CarlaEngine* const engine, const unsigned int id, CarlaPlugin* const plugin)
- {
- CarlaEngineProtectedData::registerEnginePlugin(engine, id, plugin);
- }
- #endif
-
- // -------------------------------------------------------------------------------------------------------------------
- // Carla Engine port (Abstract)
-
- CarlaEnginePort::CarlaEnginePort(const bool isInput, const ProcessMode processMode)
- : kIsInput(isInput),
- kProcessMode(processMode)
- {
- carla_debug("CarlaEnginePort::CarlaEnginePort(%s, %s)", bool2str(isInput), ProcessMode2Str(processMode));
- }
-
- CarlaEnginePort::~CarlaEnginePort()
- {
- carla_debug("CarlaEnginePort::~CarlaEnginePort()");
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // Carla Engine Audio port
-
- CarlaEngineAudioPort::CarlaEngineAudioPort(const bool isInput, const ProcessMode processMode)
- : CarlaEnginePort(isInput, processMode),
- fBuffer(nullptr)
- {
- carla_debug("CarlaEngineAudioPort::CarlaEngineAudioPort(%s, %s)", bool2str(isInput), ProcessMode2Str(processMode));
-
- if (kProcessMode == PROCESS_MODE_PATCHBAY)
- fBuffer = new float[PATCHBAY_BUFFER_SIZE];
- }
-
- CarlaEngineAudioPort::~CarlaEngineAudioPort()
- {
- carla_debug("CarlaEngineAudioPort::~CarlaEngineAudioPort()");
-
- if (kProcessMode == PROCESS_MODE_PATCHBAY)
- {
- CARLA_ASSERT(fBuffer != nullptr);
-
- if (fBuffer != nullptr)
- delete[] fBuffer;
- }
- }
-
- void CarlaEngineAudioPort::initBuffer(CarlaEngine* const)
- {
- if (kProcessMode == PROCESS_MODE_PATCHBAY && ! kIsInput)
- carla_zeroFloat(fBuffer, PATCHBAY_BUFFER_SIZE);
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // Carla Engine Event port
-
- CarlaEngineEventPort::CarlaEngineEventPort(const bool isInput, const ProcessMode processMode)
- : CarlaEnginePort(isInput, processMode),
- fBuffer(nullptr)
- {
- carla_debug("CarlaEngineEventPort::CarlaEngineEventPort(%s, %s)", bool2str(isInput), ProcessMode2Str(processMode));
-
- if (kProcessMode == PROCESS_MODE_PATCHBAY)
- fBuffer = new EngineEvent[INTERNAL_EVENT_COUNT];
- }
-
- CarlaEngineEventPort::~CarlaEngineEventPort()
- {
- carla_debug("CarlaEngineEventPort::~CarlaEngineEventPort()");
-
- if (kProcessMode == PROCESS_MODE_PATCHBAY)
- {
- CARLA_ASSERT(fBuffer != nullptr);
-
- if (fBuffer != nullptr)
- delete[] fBuffer;
- }
- }
-
- void CarlaEngineEventPort::initBuffer(CarlaEngine* const engine)
- {
- CARLA_ASSERT(engine != nullptr);
-
- if (engine == nullptr)
- {
- fBuffer = nullptr;
- return;
- }
-
- if (kProcessMode == PROCESS_MODE_CONTINUOUS_RACK || kProcessMode == PROCESS_MODE_BRIDGE)
- {
- fBuffer = engine->getInternalEventBuffer(kIsInput);
- return;
- }
-
- if (kProcessMode == PROCESS_MODE_PATCHBAY && ! kIsInput)
- carla_zeroStruct<EngineEvent>(fBuffer, INTERNAL_EVENT_COUNT);
- }
-
- uint32_t CarlaEngineEventPort::getEventCount() const
- {
- CARLA_ASSERT(kIsInput);
- CARLA_ASSERT(fBuffer != nullptr);
- CARLA_ASSERT(kProcessMode != PROCESS_MODE_SINGLE_CLIENT && kProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS);
-
- if (! kIsInput)
- return 0;
- if (fBuffer == nullptr)
- return 0;
- if (kProcessMode == PROCESS_MODE_SINGLE_CLIENT || kProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS)
- return 0;
-
- for (uint32_t i=0; i < INTERNAL_EVENT_COUNT; ++i)
- {
- if (fBuffer[i].type == kEngineEventTypeNull)
- return i;
- }
-
- CARLA_ASSERT(false); // should never happen
- return 0;
- }
-
- const EngineEvent& CarlaEngineEventPort::getEvent(const uint32_t index)
- {
- CARLA_ASSERT(kIsInput);
- CARLA_ASSERT(fBuffer != nullptr);
- CARLA_ASSERT(kProcessMode != PROCESS_MODE_SINGLE_CLIENT && kProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS);
- CARLA_ASSERT(index < INTERNAL_EVENT_COUNT);
-
- if (! kIsInput)
- return kFallbackEngineEvent;
- if (fBuffer == nullptr)
- return kFallbackEngineEvent;
- if (kProcessMode == PROCESS_MODE_SINGLE_CLIENT || kProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS)
- return kFallbackEngineEvent;
- if (index >= INTERNAL_EVENT_COUNT)
- return kFallbackEngineEvent;
-
- return fBuffer[index];
- }
-
- void CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEventType type, const uint16_t param, const float value)
- {
- CARLA_ASSERT(! kIsInput);
- CARLA_ASSERT(fBuffer != nullptr);
- CARLA_ASSERT(kProcessMode != PROCESS_MODE_SINGLE_CLIENT && kProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS);
- CARLA_ASSERT(type != kEngineControlEventTypeNull);
- CARLA_ASSERT(channel < MAX_MIDI_CHANNELS);
- CARLA_SAFE_ASSERT(value >= 0.0f && value <= 1.0f);
-
- if (kIsInput)
- return;
- if (fBuffer == nullptr)
- return;
- if (kProcessMode == PROCESS_MODE_SINGLE_CLIENT || kProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS)
- return;
- if (type == kEngineControlEventTypeNull)
- return;
- if (channel >= MAX_MIDI_CHANNELS)
- return;
- if (type == kEngineControlEventTypeParameter)
- {
- CARLA_ASSERT(! MIDI_IS_CONTROL_BANK_SELECT(param));
- }
-
- for (uint32_t i=0; i < INTERNAL_EVENT_COUNT; ++i)
- {
- if (fBuffer[i].type != kEngineEventTypeNull)
- continue;
-
- fBuffer[i].type = kEngineEventTypeControl;
- fBuffer[i].time = time;
- fBuffer[i].channel = channel;
-
- fBuffer[i].ctrl.type = type;
- fBuffer[i].ctrl.param = param;
- fBuffer[i].ctrl.value = carla_fixValue<float>(0.0f, 1.0f, value);
- return;
- }
-
- carla_stderr2("CarlaEngineEventPort::writeControlEvent() - buffer full");
- }
-
- void CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t channel, const uint8_t port, const uint8_t* const data, const uint8_t size)
- {
- CARLA_ASSERT(! kIsInput);
- CARLA_ASSERT(fBuffer != nullptr);
- CARLA_ASSERT(kProcessMode != PROCESS_MODE_SINGLE_CLIENT && kProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS);
- CARLA_ASSERT(channel < MAX_MIDI_CHANNELS);
- CARLA_ASSERT(data != nullptr);
- CARLA_ASSERT(size > 0);
-
- if (kIsInput)
- return;
- if (fBuffer == nullptr)
- return;
- if (kProcessMode == PROCESS_MODE_SINGLE_CLIENT || kProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS)
- return;
- if (channel >= MAX_MIDI_CHANNELS)
- return;
- if (data == nullptr)
- return;
- if (size == 0 || size > 4)
- return;
-
- for (uint32_t i=0; i < INTERNAL_EVENT_COUNT; ++i)
- {
- if (fBuffer[i].type != kEngineEventTypeNull)
- continue;
-
- fBuffer[i].type = kEngineEventTypeMidi;
- fBuffer[i].time = time;
- fBuffer[i].channel = channel;
-
- fBuffer[i].midi.port = port;
- fBuffer[i].midi.size = size;
-
- carla_copy<uint8_t>(fBuffer[i].midi.data, data, size);
-
- // strip MIDI channel from 1st byte
- fBuffer[i].midi.data[0] = MIDI_GET_STATUS_FROM_DATA(fBuffer[i].midi.data);
- return;
- }
-
- carla_stderr2("CarlaEngineEventPort::writeMidiEvent() - buffer full");
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // Carla Engine client (Abstract)
-
- CarlaEngineClient::CarlaEngineClient(const EngineType engineType, const ProcessMode processMode)
- : kEngineType(engineType),
- kProcessMode(processMode),
- fActive(false),
- fLatency(0)
- {
- CARLA_ASSERT(engineType != kEngineTypeNull);
- carla_debug("CarlaEngineClient::CarlaEngineClient(%s, %s)", EngineType2Str(engineType), ProcessMode2Str(processMode));
- }
-
- CarlaEngineClient::~CarlaEngineClient()
- {
- CARLA_ASSERT(! fActive);
- carla_debug("CarlaEngineClient::~CarlaEngineClient()");
- }
-
- void CarlaEngineClient::activate()
- {
- CARLA_ASSERT(! fActive);
- carla_debug("CarlaEngineClient::activate()");
-
- fActive = true;
- }
-
- void CarlaEngineClient::deactivate()
- {
- CARLA_ASSERT(fActive);
- carla_debug("CarlaEngineClient::deactivate()");
-
- fActive = false;
- }
-
- bool CarlaEngineClient::isActive() const
- {
- carla_debug("CarlaEngineClient::isActive()");
-
- return fActive;
- }
-
- bool CarlaEngineClient::isOk() const
- {
- carla_debug("CarlaEngineClient::isOk()");
-
- return true;
- }
-
- uint32_t CarlaEngineClient::getLatency() const
- {
- return fLatency;
- }
-
- void CarlaEngineClient::setLatency(const uint32_t samples)
- {
- fLatency = samples;
- }
-
- CarlaEnginePort* CarlaEngineClient::addPort(const EnginePortType portType, const char* const name, const bool isInput)
- {
- carla_debug("CarlaEngineClient::addPort(%s, \"%s\", %s)", EnginePortType2Str(portType), name, bool2str(isInput));
-
- switch (portType)
- {
- case kEnginePortTypeNull:
- break;
- case kEnginePortTypeAudio:
- return new CarlaEngineAudioPort(isInput, kProcessMode);
- case kEnginePortTypeEvent:
- return new CarlaEngineEventPort(isInput, kProcessMode);
- }
-
- carla_stderr("CarlaEngineClient::addPort(%i, \"%s\", %s) - invalid type", portType, name, bool2str(isInput));
- return nullptr;
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // Carla Engine
-
- CarlaEngine::CarlaEngine()
- : fBufferSize(0),
- fSampleRate(0.0),
- kData(new CarlaEngineProtectedData(this))
- {
- carla_debug("CarlaEngine::CarlaEngine()");
- }
-
- CarlaEngine::~CarlaEngine()
- {
- carla_debug("CarlaEngine::~CarlaEngine()");
-
- delete kData;
- }
-
- // -----------------------------------------------------------------------
- // Helpers
-
- void doPluginIdle(CarlaEngineProtectedData* const kData, const bool unlock)
- {
- CARLA_ASSERT(kData->curPluginCount > 0);
-
- kData->nextAction.opcode = kEnginePostActionNull;
-
- if (unlock)
- kData->nextAction.mutex.unlock();
- }
-
- void doPluginRemove(CarlaEngineProtectedData* const kData, const bool unlock)
- {
- CARLA_ASSERT(kData->curPluginCount > 0);
- kData->curPluginCount--;
-
- const unsigned int id = kData->nextAction.pluginId;
-
- // reset current plugin
- kData->plugins[id].plugin = nullptr;
-
- CarlaPlugin* plugin;
-
- // move all plugins 1 spot backwards
- for (unsigned int i=id; i < kData->curPluginCount; ++i)
- {
- plugin = kData->plugins[i+1].plugin;
-
- CARLA_ASSERT(plugin != nullptr);
-
- if (plugin == nullptr)
- break;
-
- plugin->setId(i);
-
- kData->plugins[i].plugin = plugin;
- kData->plugins[i].insPeak[0] = 0.0f;
- kData->plugins[i].insPeak[1] = 0.0f;
- kData->plugins[i].outsPeak[0] = 0.0f;
- kData->plugins[i].outsPeak[1] = 0.0f;
- }
-
- kData->nextAction.opcode = kEnginePostActionNull;
-
- if (unlock)
- kData->nextAction.mutex.unlock();
- }
-
- void doPluginsSwitch(CarlaEngineProtectedData* const kData, const bool unlock)
- {
- CARLA_ASSERT(kData->curPluginCount >= 2);
-
- const unsigned int idA = kData->nextAction.pluginId;
- const unsigned int idB = kData->nextAction.value;
-
- CarlaPlugin* const tmp = kData->plugins[idA].plugin;
- kData->plugins[idA].plugin = kData->plugins[idB].plugin;
- kData->plugins[idB].plugin = tmp;
-
- kData->nextAction.opcode = kEnginePostActionNull;
-
- if (unlock)
- kData->nextAction.mutex.unlock();
- }
-
- const char* findDSSIGUI(const char* const filename, const char* const label)
- {
- QString guiFilename;
- guiFilename.clear();
-
- QString pluginDir(filename);
- pluginDir.resize(pluginDir.lastIndexOf("."));
-
- QString shortName = QFileInfo(pluginDir).baseName();
-
- QString checkLabel = QString(label);
- QString checkSName = shortName;
-
- if (! checkLabel.endsWith("_")) checkLabel += "_";
- if (! checkSName.endsWith("_")) checkSName += "_";
-
- QStringList guiFiles = QDir(pluginDir).entryList();
-
- foreach (const QString& gui, guiFiles)
- {
- if (gui.startsWith(checkLabel) || gui.startsWith(checkSName))
- {
- QFileInfo finalname(pluginDir + QDir::separator() + gui);
- guiFilename = finalname.absoluteFilePath();
- break;
- }
- }
-
- if (guiFilename.isEmpty())
- return nullptr;
-
- return carla_strdup(guiFilename.toUtf8().constData());
- }
-
- // -----------------------------------------------------------------------
- // Static values and calls
-
- unsigned int CarlaEngine::getDriverCount()
- {
- carla_debug("CarlaEngine::getDriverCount()");
-
- unsigned int count = 1; // JACK
-
- #ifdef WANT_RTAUDIO
- count += getRtAudioApiCount();
- #endif
-
- return count;
- }
-
- const char* CarlaEngine::getDriverName(unsigned int index)
- {
- carla_debug("CarlaEngine::getDriverName(%i)", index);
-
- if (index == 0)
- return "JACK";
- else
- index -= 1;
-
- #ifdef WANT_RTAUDIO
- if (index < getRtAudioApiCount())
- return getRtAudioApiName(index);
- #endif
-
- carla_stderr("CarlaEngine::getDriverName(%i) - invalid index", index);
- return nullptr;
- }
-
- const char** CarlaEngine::getDriverDeviceNames(unsigned int index)
- {
- carla_debug("CarlaEngine::getDriverDeviceNames(%i)", index);
-
- if (index == 0)
- return nullptr;
- else
- index -= 1;
-
- #ifdef WANT_RTAUDIO
- if (index < getRtAudioApiCount())
- return getRtAudioApiDeviceNames(index);
- #endif
-
- carla_stderr("CarlaEngine::getDriverDeviceNames(%i) - invalid index", index);
- return nullptr;
- }
-
- CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName)
- {
- carla_debug("CarlaEngine::newDriverByName(\"%s\")", driverName);
-
- if (std::strcmp(driverName, "JACK") == 0)
- return newJack();
-
- #ifdef WANT_RTAUDIO
- # ifdef __LINUX_ALSA__
- if (std::strcmp(driverName, "ALSA") == 0)
- return newRtAudio(RTAUDIO_LINUX_ALSA);
- # endif
- # ifdef __LINUX_PULSE__
- if (std::strcmp(driverName, "PulseAudio") == 0)
- return newRtAudio(RTAUDIO_LINUX_PULSE);
- # endif
- # ifdef __LINUX_OSS__
- if (std::strcmp(driverName, "OSS") == 0)
- return newRtAudio(RTAUDIO_LINUX_OSS);
- # endif
- # ifdef __UNIX_JACK__
- if (std::strncmp(driverName, "JACK ", 5) == 0)
- return newRtAudio(RTAUDIO_UNIX_JACK);
- # endif
- # ifdef __MACOSX_CORE__
- if (std::strcmp(driverName, "CoreAudio") == 0)
- return newRtAudio(RTAUDIO_MACOSX_CORE);
- # endif
- # ifdef __WINDOWS_ASIO__
- if (std::strcmp(driverName, "ASIO") == 0)
- return newRtAudio(RTAUDIO_WINDOWS_ASIO);
- # endif
- # ifdef __WINDOWS_DS__
- if (std::strcmp(driverName, "DirectSound") == 0)
- return newRtAudio(RTAUDIO_WINDOWS_DS);
- # endif
- #endif
-
- return nullptr;
- }
-
- // -----------------------------------------------------------------------
- // Maximum values
-
- unsigned int CarlaEngine::maxClientNameSize() const
- {
- return STR_MAX/2;
- }
-
- unsigned int CarlaEngine::maxPortNameSize() const
- {
- return STR_MAX;
- }
-
- unsigned int CarlaEngine::currentPluginCount() const
- {
- return kData->curPluginCount;
- }
-
- unsigned int CarlaEngine::maxPluginNumber() const
- {
- return kData->maxPluginNumber;
- }
-
- // -----------------------------------------------------------------------
- // Virtual, per-engine type calls
-
- bool CarlaEngine::init(const char* const clientName)
- {
- CARLA_ASSERT(kData->oscData == nullptr);
- CARLA_ASSERT(kData->plugins == nullptr);
- carla_debug("CarlaEngine::init(\"%s\")", clientName);
-
- CARLA_ASSERT(kData->bufEvent.in == nullptr);
- CARLA_ASSERT(kData->bufEvent.out == nullptr);
-
- fName = clientName;
- fName.toBasic();
-
- fTimeInfo.clear();
-
- kData->aboutToClose = false;
- kData->curPluginCount = 0;
- kData->maxPluginNumber = 0;
-
- switch (fOptions.processMode)
- {
- case PROCESS_MODE_SINGLE_CLIENT:
- case PROCESS_MODE_MULTIPLE_CLIENTS:
- kData->maxPluginNumber = MAX_DEFAULT_PLUGINS;
- break;
-
- case PROCESS_MODE_CONTINUOUS_RACK:
- kData->maxPluginNumber = MAX_RACK_PLUGINS;
- kData->bufEvent.in = new EngineEvent[INTERNAL_EVENT_COUNT];
- kData->bufEvent.out = new EngineEvent[INTERNAL_EVENT_COUNT];
- break;
-
- case PROCESS_MODE_PATCHBAY:
- kData->maxPluginNumber = MAX_PATCHBAY_PLUGINS;
- break;
-
- case PROCESS_MODE_BRIDGE:
- kData->maxPluginNumber = 1;
- kData->bufEvent.in = new EngineEvent[INTERNAL_EVENT_COUNT];
- kData->bufEvent.out = new EngineEvent[INTERNAL_EVENT_COUNT];
- break;
- }
-
- kData->plugins = new EnginePluginData[kData->maxPluginNumber];
-
- kData->osc.init(clientName);
-
- #ifndef BUILD_BRIDGE
- kData->oscData = kData->osc.getControlData();
- #endif
-
- if (type() != kEngineTypePlugin)
- carla_setprocname(clientName);
-
- kData->nextAction.ready();
- kData->thread.startNow();
-
- return true;
- }
-
- bool CarlaEngine::close()
- {
- CARLA_ASSERT(kData->plugins != nullptr);
- carla_debug("CarlaEngine::close()");
-
- kData->thread.stopNow();
- kData->nextAction.ready();
-
- #ifndef BUILD_BRIDGE
- osc_send_control_exit();
- #endif
- kData->osc.close();
-
- kData->oscData = nullptr;
-
- kData->aboutToClose = true;
- kData->curPluginCount = 0;
- kData->maxPluginNumber = 0;
-
- if (kData->plugins != nullptr)
- {
- delete[] kData->plugins;
- kData->plugins = nullptr;
- }
-
- if (kData->bufEvent.in != nullptr)
- {
- delete[] kData->bufEvent.in;
- kData->bufEvent.in = nullptr;
- }
-
- if (kData->bufEvent.out != nullptr)
- {
- delete[] kData->bufEvent.out;
- kData->bufEvent.out = nullptr;
- }
-
- fName.clear();
-
- return true;
- }
-
- void CarlaEngine::idle()
- {
- CARLA_ASSERT(kData->plugins != nullptr);
-
- for (unsigned int i=0; i < kData->curPluginCount; ++i)
- {
- CarlaPlugin* const plugin = kData->plugins[i].plugin;
-
- if (plugin != nullptr && plugin->enabled())
- plugin->idleGui();
- }
- }
-
- CarlaEngineClient* CarlaEngine::addClient(CarlaPlugin* const)
- {
- return new CarlaEngineClient(type(), fOptions.processMode);
- }
-
- // -----------------------------------------------------------------------
- // Plugin management
-
- bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, const void* const extra)
- {
- CARLA_ASSERT(btype != BINARY_NONE);
- CARLA_ASSERT(ptype != PLUGIN_NONE);
- carla_debug("CarlaEngine::addPlugin(%s, %s, \"%s\", \"%s\", \"%s\", %p)", BinaryType2Str(btype), PluginType2Str(ptype), filename, name, label, extra);
-
- if (kData->curPluginCount == kData->maxPluginNumber)
- {
- setLastError("Maximum number of plugins reached");
- return false;
- }
-
- const unsigned int id = kData->curPluginCount;
-
- CarlaPlugin::Initializer init = {
- this,
- id,
- filename,
- name,
- label
- };
-
- CarlaPlugin* plugin = nullptr;
-
- #ifndef BUILD_BRIDGE
- const char* bridgeBinary;
-
- switch (btype)
- {
- case BINARY_POSIX32:
- bridgeBinary = fOptions.bridge_posix32.isNotEmpty() ? (const char*)fOptions.bridge_posix32 : nullptr;
- break;
- case BINARY_POSIX64:
- bridgeBinary = fOptions.bridge_posix64.isNotEmpty() ? (const char*)fOptions.bridge_posix64 : nullptr;
- break;
- case BINARY_WIN32:
- bridgeBinary = fOptions.bridge_win32.isNotEmpty() ? (const char*)fOptions.bridge_win32 : nullptr;
- break;
- case BINARY_WIN64:
- bridgeBinary = fOptions.bridge_win64.isNotEmpty() ? (const char*)fOptions.bridge_win64 : nullptr;
- break;
- default:
- bridgeBinary = nullptr;
- break;
- }
-
- #ifndef Q_OS_WIN
- if (btype == BINARY_NATIVE && fOptions.bridge_native.isNotEmpty())
- bridgeBinary = (const char*)fOptions.bridge_native;
- #endif
-
- if (bridgeBinary != nullptr && (btype != BINARY_NATIVE || fOptions.preferPluginBridges))
- {
- plugin = CarlaPlugin::newBridge(init, btype, ptype, bridgeBinary);
- }
- else
- #endif // BUILD_BRIDGE
- {
- switch (ptype)
- {
- case PLUGIN_NONE:
- break;
-
- case PLUGIN_INTERNAL:
- plugin = CarlaPlugin::newNative(init);
- break;
-
- case PLUGIN_LADSPA:
- plugin = CarlaPlugin::newLADSPA(init, (const LADSPA_RDF_Descriptor*)extra);
- break;
-
- case PLUGIN_DSSI:
- plugin = CarlaPlugin::newDSSI(init, (const char*)extra);
- break;
-
- case PLUGIN_LV2:
- plugin = CarlaPlugin::newLV2(init);
- break;
-
- case PLUGIN_VST:
- plugin = CarlaPlugin::newVST(init);
- break;
-
- case PLUGIN_VST3:
- plugin = CarlaPlugin::newVST3(init);
- break;
-
- case PLUGIN_GIG:
- plugin = CarlaPlugin::newGIG(init, (extra != nullptr));
- break;
-
- case PLUGIN_SF2:
- plugin = CarlaPlugin::newSF2(init, (extra != nullptr));
- break;
-
- case PLUGIN_SFZ:
- plugin = CarlaPlugin::newSFZ(init, (extra != nullptr));
- break;
- }
- }
-
- if (plugin == nullptr)
- return false;
-
- plugin->registerToOscClient();
-
- kData->plugins[id].plugin = plugin;
- kData->plugins[id].insPeak[0] = 0.0f;
- kData->plugins[id].insPeak[1] = 0.0f;
- kData->plugins[id].outsPeak[0] = 0.0f;
- kData->plugins[id].outsPeak[1] = 0.0f;
-
- kData->curPluginCount += 1;
-
- callback(CALLBACK_PLUGIN_ADDED, id, 0, 0, 0.0f, plugin->name());
- return true;
- }
-
- bool CarlaEngine::removePlugin(const unsigned int id)
- {
- CARLA_ASSERT(kData->curPluginCount > 0);
- CARLA_ASSERT(id < kData->curPluginCount);
- CARLA_ASSERT(kData->plugins != nullptr);
- carla_debug("CarlaEngine::removePlugin(%i)", id);
-
- if (kData->plugins == nullptr)
- {
- setLastError("Critical error: no plugins are currently loaded!");
- return false;
- }
-
- CarlaPlugin* const plugin = kData->plugins[id].plugin;
-
- if (plugin == nullptr)
- {
- setLastError("Could not find plugin to remove");
- return false;
- }
-
- CARLA_ASSERT(plugin->id() == id);
-
- kData->thread.stopNow();
-
- kData->nextAction.pluginId = id;
- kData->nextAction.opcode = kEnginePostActionRemovePlugin;
-
- kData->nextAction.mutex.lock();
-
- if (isRunning())
- {
- carla_stderr("CarlaEngine::removePlugin(%i) - remove blocking START", id);
- // block wait for unlock on proccessing side
- kData->nextAction.mutex.lock();
- carla_stderr("CarlaEngine::removePlugin(%i) - remove blocking DONE", id);
- }
- else
- {
- doPluginRemove(kData, false);
- }
-
- #ifndef BUILD_BRIDGE
- if (isOscControlRegistered())
- osc_send_control_remove_plugin(id);
- #endif
-
- delete plugin;
-
- kData->nextAction.mutex.unlock();
-
- if (isRunning() && ! kData->aboutToClose)
- kData->thread.startNow();
-
- callback(CALLBACK_PLUGIN_REMOVED, id, 0, 0, 0.0f, nullptr);
- return true;
- }
-
- void CarlaEngine::removeAllPlugins()
- {
- carla_debug("CarlaEngine::removeAllPlugins() - START");
-
- kData->thread.stopNow();
-
- if (kData->curPluginCount > 0)
- {
- const unsigned int oldCount = kData->curPluginCount;
-
- kData->curPluginCount = 0;
-
- for (unsigned int i=0; i < oldCount; ++i)
- {
- CarlaPlugin* const plugin = kData->plugins[i].plugin;
-
- CARLA_ASSERT(plugin != nullptr);
-
- kData->plugins[i].plugin = nullptr;
-
- if (plugin != nullptr)
- delete plugin;
-
- // clear this plugin
- kData->plugins[i].insPeak[0] = 0.0f;
- kData->plugins[i].insPeak[1] = 0.0f;
- kData->plugins[i].outsPeak[0] = 0.0f;
- kData->plugins[i].outsPeak[1] = 0.0f;
- }
- }
-
- if (isRunning() && ! kData->aboutToClose)
- kData->thread.startNow();
-
- carla_debug("CarlaEngine::removeAllPlugins() - END");
- }
-
- const char* CarlaEngine::renamePlugin(const unsigned int id, const char* const newName)
- {
- CARLA_ASSERT(kData->curPluginCount > 0);
- CARLA_ASSERT(id < kData->curPluginCount);
- CARLA_ASSERT(kData->plugins != nullptr);
- CARLA_ASSERT(newName != nullptr);
- carla_debug("CarlaEngine::renamePlugin(%i, \"%s\")", id, newName);
-
- if (kData->plugins == nullptr)
- {
- setLastError("Critical error: no plugins are currently loaded!");
- return nullptr;
- }
-
- CarlaPlugin* const plugin = kData->plugins[id].plugin;
-
- if (plugin == nullptr)
- {
- carla_stderr("CarlaEngine::clonePlugin(%i) - could not find plugin", id);
- return nullptr;
- }
-
- CARLA_ASSERT(plugin->id() == id);
-
- if (const char* const name = getUniquePluginName(newName))
- {
- plugin->setName(name);
-
- return name;
- }
-
- return nullptr;
- }
-
- bool CarlaEngine::clonePlugin(const unsigned int id)
- {
- CARLA_ASSERT(kData->curPluginCount > 0);
- CARLA_ASSERT(id < kData->curPluginCount);
- CARLA_ASSERT(kData->plugins != nullptr);
- carla_debug("CarlaEngine::clonePlugin(%i)", id);
-
- if (kData->plugins == nullptr)
- {
- setLastError("Critical error: no plugins are currently loaded!");
- return false;
- }
-
- CarlaPlugin* const plugin = kData->plugins[id].plugin;
-
- if (plugin == nullptr)
- {
- carla_stderr("CarlaEngine::clonePlugin(%i) - could not find plugin", id);
- return false;
- }
-
- CARLA_ASSERT(plugin->id() == id);
-
- const SaveState& saveState(plugin->getSaveState());
-
- char label[STR_MAX+1] = { '\0' };
- plugin->getLabel(label);
-
- BinaryType binaryType = BINARY_NATIVE;
-
- #ifndef BUILD_BRIDGE
- if (plugin->hints() & PLUGIN_IS_BRIDGE)
- binaryType = CarlaPluginGetBridgeBinaryType(plugin);
- #endif
-
- const unsigned int pluginsBefore(kData->curPluginCount);
-
- if (! addPlugin(binaryType, plugin->type(), plugin->filename(), plugin->name(), label, plugin->getExtraStuff()))
- return false;
-
- CARLA_ASSERT(pluginsBefore+1 == kData->curPluginCount);
-
- CarlaPlugin* const newPlugin = kData->plugins[kData->curPluginCount-1].plugin;
-
- CARLA_ASSERT(newPlugin != nullptr);
-
- newPlugin->loadSaveState(saveState);
-
- return true;
- }
-
- bool CarlaEngine::replacePlugin(const unsigned int id)
- {
- CARLA_ASSERT(kData->curPluginCount > 0);
- CARLA_ASSERT(id < kData->curPluginCount);
- CARLA_ASSERT(kData->plugins != nullptr);
- carla_debug("CarlaEngine::replacePlugin(%i)", id);
-
- setLastError("Not implemented yet");
- return false;
- }
-
- bool CarlaEngine::switchPlugins(const unsigned int idA, const unsigned int idB)
- {
- CARLA_ASSERT(kData->curPluginCount > 0);
- CARLA_ASSERT(idA < kData->curPluginCount);
- CARLA_ASSERT(idB < kData->curPluginCount);
- CARLA_ASSERT(kData->plugins != nullptr);
- carla_debug("CarlaEngine::switchPlugins(%i)", idA, idB);
-
- if (kData->plugins == nullptr)
- {
- setLastError("Critical error: no plugins are currently loaded!");
- return false;
- }
-
- kData->thread.stopNow();
-
- kData->nextAction.pluginId = idA;
- kData->nextAction.value = idB;
- kData->nextAction.opcode = kEnginePostActionSwitchPlugins;
-
- kData->nextAction.mutex.lock();
-
- if (isRunning())
- {
- carla_stderr("CarlaEngine::switchPlugins(%i, %i) - switch blocking START", idA, idB);
- // block wait for unlock on proccessing side
- kData->nextAction.mutex.lock();
- carla_stderr("CarlaEngine::switchPlugins(%i, %i) - switch blocking DONE", idA, idB);
- }
- else
- {
- doPluginsSwitch(kData, false);
- }
-
- #ifndef BUILD_BRIDGE // TODO
- //if (isOscControlRegistered())
- // osc_send_control_remove_plugin(id);
- #endif
-
- kData->nextAction.mutex.unlock();
-
- if (isRunning() && ! kData->aboutToClose)
- kData->thread.startNow();
-
- return true;
- }
-
- CarlaPlugin* CarlaEngine::getPlugin(const unsigned int id) const
- {
- CARLA_ASSERT(kData->curPluginCount > 0);
- CARLA_ASSERT(id < kData->curPluginCount);
- CARLA_ASSERT(kData->plugins != nullptr);
- carla_debug("CarlaEngine::getPlugin(%i) [count:%i]", id, kData->curPluginCount);
-
- if (id < kData->curPluginCount && kData->plugins != nullptr)
- return kData->plugins[id].plugin;
-
- return nullptr;
- }
-
- CarlaPlugin* CarlaEngine::getPluginUnchecked(const unsigned int id) const
- {
- return kData->plugins[id].plugin;
- }
-
- const char* CarlaEngine::getUniquePluginName(const char* const name)
- {
- CARLA_ASSERT(kData->maxPluginNumber > 0);
- CARLA_ASSERT(kData->plugins != nullptr);
- CARLA_ASSERT(name != nullptr);
- carla_debug("CarlaEngine::getUniquePluginName(\"%s\")", name);
-
- static CarlaString sname;
- sname = name;
-
- if (sname.isEmpty() || kData->plugins == nullptr)
- {
- sname = "(No name)";
- return (const char*)sname;
- }
-
- sname.truncate(maxClientNameSize()-5-1); // 5 = strlen(" (10)")
- sname.replace(':', '.'); // ':' is used in JACK1 to split client/port names
-
- for (unsigned short i=0; i < kData->curPluginCount; ++i)
- {
- CARLA_ASSERT(kData->plugins[i].plugin);
-
- if (kData->plugins[i].plugin == nullptr)
- continue;
-
- // Check if unique name doesn't exist
- if (const char* const pluginName = kData->plugins[i].plugin->name())
- {
- if (sname != pluginName)
- continue;
- }
-
- // Check if string has already been modified
- {
- const size_t len = sname.length();
-
- // 1 digit, ex: " (2)"
- if (sname[len-4] == ' ' && sname[len-3] == '(' && sname.isDigit(len-2) && sname[len-1] == ')')
- {
- int number = sname[len-2] - '0';
-
- if (number == 9)
- {
- // next number is 10, 2 digits
- sname.truncate(len-4);
- sname += " (10)";
- //sname.replace(" (9)", " (10)");
- }
- else
- sname[len-2] = char('0' + number + 1);
-
- continue;
- }
-
- // 2 digits, ex: " (11)"
- if (sname[len-5] == ' ' && sname[len-4] == '(' && sname.isDigit(len-3) && sname.isDigit(len-2) && sname[len-1] == ')')
- {
- char n2 = sname[len-2];
- char n3 = sname[len-3];
-
- if (n2 == '9')
- {
- n2 = '0';
- n3 += 1;
- }
- else
- n2 += 1;
-
- sname[len-2] = n2;
- sname[len-3] = n3;
-
- continue;
- }
- }
-
- // Modify string if not
- sname += " (2)";
- }
-
- return (const char*)sname;
- }
-
- // -----------------------------------------------------------------------
- // Project management
-
- bool CarlaEngine::loadFilename(const char* const filename)
- {
- CARLA_ASSERT(filename != nullptr);
- carla_debug("CarlaEngine::loadFilename(\"%s\")", filename);
-
- QFileInfo fileInfo(filename);
-
- if (! fileInfo.exists())
- {
- setLastError("File does not exist");
- return false;
- }
-
- if (! fileInfo.isFile())
- {
- setLastError("Not a file");
- return false;
- }
-
- if (! fileInfo.isReadable())
- {
- setLastError("File is not readable");
- return false;
- }
-
- CarlaString baseName(fileInfo.baseName().toUtf8().constData());
- CarlaString extension(fileInfo.suffix().toLower().toUtf8().constData());
-
- // -------------------------------------------------------------------
-
- if (extension == "carxp" || extension == "carxs")
- return loadProject(filename);
-
- // -------------------------------------------------------------------
-
- if (extension == "gig")
- return addPlugin(PLUGIN_GIG, filename, baseName, baseName);
-
- if (extension == "sf2")
- return addPlugin(PLUGIN_SF2, filename, baseName, baseName);
-
- if (extension == "sfz")
- return addPlugin(PLUGIN_SFZ, filename, baseName, baseName);
-
- // -------------------------------------------------------------------
-
- if (extension == "aiff" || extension == "flac" || extension == "oga" || extension == "ogg" || extension == "w64" || extension == "wav")
- {
- #ifdef WANT_AUDIOFILE
- if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "audiofile"))
- {
- if (CarlaPlugin* const plugin = getPlugin(kData->curPluginCount-1))
- plugin->setCustomData(CUSTOM_DATA_STRING, "file", filename, true);
- return true;
- }
- return false;
- #else
- setLastError("This Carla build does not have Audio file support");
- return false;
- #endif
- }
-
- if (extension == "3g2" || extension == "3gp" || extension == "aac" || extension == "ac3" || extension == "amr" || extension == "ape" ||
- extension == "mp2" || extension == "mp3" || extension == "mpc" || extension == "wma")
- {
- #ifdef WANT_AUDIOFILE
- # ifdef HAVE_FFMPEG
- if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "audiofile"))
- {
- if (CarlaPlugin* const plugin = getPlugin(kData->curPluginCount-1))
- plugin->setCustomData(CUSTOM_DATA_STRING, "file", filename, true);
- return true;
- }
- return false;
- # else
- setLastError("This Carla build has Audio file support, but not libav/ffmpeg");
- return false;
- # endif
- #else
- setLastError("This Carla build does not have Audio file support");
- return false;
- #endif
- }
-
- // -------------------------------------------------------------------
-
- if (extension == "mid" || extension == "midi")
- {
- #ifdef WANT_MIDIFILE
- if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "midifile"))
- {
- if (CarlaPlugin* const plugin = getPlugin(kData->curPluginCount-1))
- plugin->setCustomData(CUSTOM_DATA_STRING, "file", filename, true);
- return true;
- }
- return false;
- #else
- setLastError("This Carla build does not have MIDI file support");
- return false;
- #endif
- }
-
- // -------------------------------------------------------------------
- // ZynAddSubFX
-
- if (extension == "xmz" || extension == "xiz")
- {
- #ifdef WANT_ZYNADDSUBFX
- if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "zynaddsubfx"))
- {
- if (CarlaPlugin* const plugin = getPlugin(kData->curPluginCount-1))
- plugin->setCustomData(CUSTOM_DATA_STRING, (extension == "xmz") ? "CarlaAlternateFile1" : "CarlaAlternateFile2", filename, true);
- return true;
- }
- return false;
- #else
- setLastError("This Carla build does not have ZynAddSubFX support");
- return false;
- #endif
- }
-
- // -------------------------------------------------------------------
-
- setLastError("Unknown file extension");
- return false;
- }
-
- bool CarlaEngine::loadProject(const char* const filename)
- {
- CARLA_ASSERT(filename != nullptr);
- carla_debug("CarlaEngine::loadProject(\"%s\")", filename);
-
- QFile file(filename);
-
- if (! file.open(QIODevice::ReadOnly | QIODevice::Text))
- return false;
-
- QDomDocument xml;
- xml.setContent(file.readAll());
- file.close();
-
- QDomNode xmlNode(xml.documentElement());
-
- if (xmlNode.toElement().tagName() != "CARLA-PROJECT" && xmlNode.toElement().tagName() != "CARLA-PRESET")
- {
- setLastError("Not a valid Carla project or preset file");
- return false;
- }
-
- const bool isPreset(xmlNode.toElement().tagName() == "CARLA-PRESET");
-
- QDomNode node(xmlNode.firstChild());
-
- while (! node.isNull())
- {
- if (isPreset || node.toElement().tagName() == "Plugin")
- {
- const SaveState& saveState(getSaveStateDictFromXML(isPreset ? xmlNode : node));
- CARLA_ASSERT(saveState.type != nullptr);
-
- if (saveState.type == nullptr)
- continue;
-
- const void* extraStuff = nullptr;
-
- if (std::strcmp(saveState.type, "DSSI") == 0)
- extraStuff = findDSSIGUI(saveState.binary, saveState.label);
-
- // TODO - proper find&load plugins
- if (addPlugin(getPluginTypeFromString(saveState.type), saveState.binary, saveState.name, saveState.label, extraStuff))
- {
- if (CarlaPlugin* plugin = getPlugin(kData->curPluginCount-1))
- plugin->loadSaveState(saveState);
- }
- }
-
- if (isPreset)
- break;
-
- node = node.nextSibling();
- }
-
- return true;
- }
-
- bool CarlaEngine::saveProject(const char* const filename)
- {
- CARLA_ASSERT(filename != nullptr);
- carla_debug("CarlaEngine::saveProject(\"%s\")", filename);
-
- QFile file(filename);
-
- if (! file.open(QIODevice::WriteOnly | QIODevice::Text))
- return false;
-
- QTextStream out(&file);
- out << "<?xml version='1.0' encoding='UTF-8'?>\n";
- out << "<!DOCTYPE CARLA-PROJECT>\n";
- out << "<CARLA-PROJECT VERSION='1.0'>\n";
-
- bool firstPlugin = true;
- char strBuf[STR_MAX+1];
-
- for (unsigned int i=0; i < kData->curPluginCount; ++i)
- {
- CarlaPlugin* const plugin = kData->plugins[i].plugin;
-
- if (plugin != nullptr && plugin->enabled())
- {
- if (! firstPlugin)
- out << "\n";
-
- plugin->getRealName(strBuf);
-
- if (*strBuf != 0)
- out << QString(" <!-- %1 -->\n").arg(xmlSafeString(strBuf, true));
-
- out << " <Plugin>\n";
- out << getXMLFromSaveState(plugin->getSaveState());
- out << " </Plugin>\n";
-
- firstPlugin = false;
- }
- }
-
- out << "</CARLA-PROJECT>\n";
-
- file.close();
- return true;
- }
-
- // -----------------------------------------------------------------------
- // Information (peaks)
-
- float CarlaEngine::getInputPeak(const unsigned int pluginId, const unsigned short id) const
- {
- CARLA_ASSERT(pluginId < kData->curPluginCount);
- CARLA_ASSERT(id-1 < MAX_PEAKS);
-
- if (id == 0 || id > MAX_PEAKS)
- return 0.0f;
-
- return kData->plugins[pluginId].insPeak[id-1];
- }
-
- float CarlaEngine::getOutputPeak(const unsigned int pluginId, const unsigned short id) const
- {
- CARLA_ASSERT(pluginId < kData->curPluginCount);
- CARLA_ASSERT(id-1 < MAX_PEAKS);
-
- if (id == 0 || id > MAX_PEAKS)
- return 0.0f;
-
- return kData->plugins[pluginId].outsPeak[id-1];
- }
-
- // -----------------------------------------------------------------------
- // Callback
-
- void CarlaEngine::callback(const CallbackType action, const unsigned int pluginId, const int value1, const int value2, const float value3, const char* const valueStr)
- {
- carla_debug("CarlaEngine::callback(%s, %i, %i, %i, %f, \"%s\")", CallbackType2Str(action), pluginId, value1, value2, value3, valueStr);
-
- if (kData->callback)
- kData->callback(kData->callbackPtr, action, pluginId, value1, value2, value3, valueStr);
- }
-
- void CarlaEngine::setCallback(const CallbackFunc func, void* const ptr)
- {
- CARLA_ASSERT(func != nullptr);
- carla_debug("CarlaEngine::setCallback(%p, %p)", func, ptr);
-
- kData->callback = func;
- kData->callbackPtr = ptr;
- }
-
- // -----------------------------------------------------------------------
- // Patchbay
-
- bool CarlaEngine::patchbayConnect(int, int)
- {
- setLastError("Unsupported operation");
- return false;
- }
-
- bool CarlaEngine::patchbayDisconnect(int)
- {
- setLastError("Unsupported operation");
- return false;
- }
-
- void CarlaEngine::patchbayRefresh()
- {
- // nothing
- }
-
- // -----------------------------------------------------------------------
- // Transport
-
- void CarlaEngine::transportPlay()
- {
- kData->time.playing = true;
- }
-
- void CarlaEngine::transportPause()
- {
- kData->time.playing = false;
- }
-
- void CarlaEngine::transportRelocate(const uint32_t frame)
- {
- kData->time.frame = frame;
- }
-
- // -----------------------------------------------------------------------
- // Error handling
-
- const char* CarlaEngine::getLastError() const
- {
- return (const char*)kData->lastError;
- }
-
- void CarlaEngine::setLastError(const char* const error)
- {
- kData->lastError = error;
- }
-
- void CarlaEngine::setAboutToClose()
- {
- carla_debug("CarlaEngine::setAboutToClose()");
- kData->aboutToClose = true;
- }
-
- // -----------------------------------------------------------------------
- // Global options
-
- #define CARLA_ENGINE_SET_OPTION_RUNNING_CHECK \
- if (isRunning()) \
- return carla_stderr("CarlaEngine::setOption(%s, %i, \"%s\") - Cannot set this option while engine is running!", OptionsType2Str(option), value, valueStr);
-
- void CarlaEngine::setOption(const OptionsType option, const int value, const char* const valueStr)
- {
- carla_debug("CarlaEngine::setOption(%s, %i, \"%s\")", OptionsType2Str(option), value, valueStr);
-
- switch (option)
- {
- case OPTION_PROCESS_NAME:
- carla_setprocname(valueStr);
- break;
-
- case OPTION_PROCESS_MODE:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
-
- if (value < PROCESS_MODE_SINGLE_CLIENT || value > PROCESS_MODE_BRIDGE)
- return carla_stderr("CarlaEngine::setOption(%s, %i, \"%s\") - invalid value", OptionsType2Str(option), value, valueStr);
-
- fOptions.processMode = static_cast<ProcessMode>(value);
- break;
-
- case OPTION_TRANSPORT_MODE:
- // FIXME: Always enable JACK transport for now
- #if 0
- if (value < CarlaBackend::TRANSPORT_MODE_INTERNAL || value > CarlaBackend::TRANSPORT_MODE_BRIDGE)
- return carla_stderr2("carla_set_engine_option(OPTION_TRANSPORT_MODE, %i, \"%s\") - invalid value", value, valueStr);
-
- fOptions.transportMode = static_cast<CarlaBackend::TransportMode>(value);
- #endif
- break;
-
- case OPTION_MAX_PARAMETERS:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
-
- if (value < 0)
- return; // TODO error here
-
- fOptions.maxParameters = static_cast<uint>(value);
- break;
-
- case OPTION_FORCE_STEREO:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
- fOptions.forceStereo = (value != 0);
- break;
-
- #ifdef WANT_DSSI
- case OPTION_USE_DSSI_VST_CHUNKS:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
- fOptions.useDssiVstChunks = (value != 0);
- break;
- #endif
-
- case OPTION_PREFER_PLUGIN_BRIDGES:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
- fOptions.preferPluginBridges = (value != 0);
- break;
-
- case OPTION_PREFER_UI_BRIDGES:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
- fOptions.preferUiBridges = (value != 0);
- break;
-
- case OPTION_OSC_UI_TIMEOUT:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
- fOptions.oscUiTimeout = static_cast<uint>(value);
- break;
-
- case OPTION_JACK_AUTOCONNECT:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
- fOptions.jackAutoConnect = (value != 0);
- break;
-
- case OPTION_JACK_TIMEMASTER:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
- fOptions.jackTimeMaster = (value != 0);
- break;
-
- #ifdef WANT_RTAUDIO
- case OPTION_RTAUDIO_BUFFER_SIZE:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
- fOptions.rtaudioBufferSize = static_cast<uint>(value);
- break;
-
- case OPTION_RTAUDIO_SAMPLE_RATE:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
- fOptions.rtaudioSampleRate = static_cast<uint>(value);
- break;
-
- case OPTION_RTAUDIO_DEVICE:
- CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
- fOptions.rtaudioDevice = valueStr;
- break;
- #endif
-
- case OPTION_PATH_RESOURCES:
- fOptions.resourceDir = valueStr;
- break;
-
- #ifndef BUILD_BRIDGE
- case OPTION_PATH_BRIDGE_NATIVE:
- fOptions.bridge_native = valueStr;
- break;
- case OPTION_PATH_BRIDGE_POSIX32:
- fOptions.bridge_posix32 = valueStr;
- break;
- case OPTION_PATH_BRIDGE_POSIX64:
- fOptions.bridge_posix64 = valueStr;
- break;
- case OPTION_PATH_BRIDGE_WIN32:
- fOptions.bridge_win32 = valueStr;
- break;
- case OPTION_PATH_BRIDGE_WIN64:
- fOptions.bridge_win64 = valueStr;
- break;
- #endif
-
- #ifdef WANT_LV2
- case OPTION_PATH_BRIDGE_LV2_GTK2:
- fOptions.bridge_lv2Gtk2 = valueStr;
- break;
- case OPTION_PATH_BRIDGE_LV2_GTK3:
- fOptions.bridge_lv2Gtk3 = valueStr;
- break;
- case OPTION_PATH_BRIDGE_LV2_QT4:
- fOptions.bridge_lv2Qt4 = valueStr;
- break;
- case OPTION_PATH_BRIDGE_LV2_QT5:
- fOptions.bridge_lv2Qt5 = valueStr;
- break;
- case OPTION_PATH_BRIDGE_LV2_COCOA:
- fOptions.bridge_lv2Cocoa = valueStr;
- break;
- case OPTION_PATH_BRIDGE_LV2_WINDOWS:
- fOptions.bridge_lv2Win = valueStr;
- break;
- case OPTION_PATH_BRIDGE_LV2_X11:
- fOptions.bridge_lv2X11 = valueStr;
- break;
- #endif
-
- #ifdef WANT_VST
- case OPTION_PATH_BRIDGE_VST_COCOA:
- fOptions.bridge_vstCocoa = valueStr;
- break;
- case OPTION_PATH_BRIDGE_VST_HWND:
- fOptions.bridge_vstHWND = valueStr;
- break;
- case OPTION_PATH_BRIDGE_VST_X11:
- fOptions.bridge_vstX11 = valueStr;
- break;
- #endif
- }
- }
-
- // -----------------------------------------------------------------------
- // OSC Stuff
-
- #ifdef BUILD_BRIDGE
- bool CarlaEngine::isOscBridgeRegistered() const
- {
- return (kData->oscData != nullptr);
- }
- #else
- bool CarlaEngine::isOscControlRegistered() const
- {
- return kData->osc.isControlRegistered();
- }
- #endif
-
- void CarlaEngine::idleOsc()
- {
- kData->osc.idle();
- }
-
- const char* CarlaEngine::getOscServerPathTCP() const
- {
- return kData->osc.getServerPathTCP();
- }
-
- const char* CarlaEngine::getOscServerPathUDP() const
- {
- return kData->osc.getServerPathUDP();
- }
-
- #ifdef BUILD_BRIDGE
- void CarlaEngine::setOscBridgeData(const CarlaOscData* const oscData)
- {
- kData->oscData = oscData;
- }
- #endif
-
- // -----------------------------------------------------------------------
- // protected calls
-
- void CarlaEngine::bufferSizeChanged(const uint32_t newBufferSize)
- {
- carla_debug("CarlaEngine::bufferSizeChanged(%i)", newBufferSize);
-
- for (unsigned int i=0; i < kData->curPluginCount; ++i)
- {
- CarlaPlugin* const plugin = kData->plugins[i].plugin;
-
- if (plugin != nullptr && plugin->enabled())
- plugin->bufferSizeChanged(newBufferSize);
- }
-
- callback(CALLBACK_BUFFER_SIZE_CHANGED, 0, newBufferSize, 0, 0.0f, nullptr);
- }
-
- void CarlaEngine::sampleRateChanged(const double newSampleRate)
- {
- carla_debug("CarlaEngine::sampleRateChanged(%g)", newSampleRate);
-
- for (unsigned int i=0; i < kData->curPluginCount; ++i)
- {
- CarlaPlugin* const plugin = kData->plugins[i].plugin;
-
- if (plugin != nullptr && plugin->enabled())
- plugin->sampleRateChanged(newSampleRate);
- }
-
- callback(CALLBACK_SAMPLE_RATE_CHANGED, 0, 0, 0, newSampleRate, nullptr);
- }
-
- void CarlaEngine::proccessPendingEvents()
- {
- //carla_stderr("proccessPendingEvents(%i)", kData->nextAction.opcode);
-
- switch (kData->nextAction.opcode)
- {
- case kEnginePostActionNull:
- break;
- case kEnginePostActionIdle:
- doPluginIdle(kData, true);
- break;
- case kEnginePostActionRemovePlugin:
- doPluginRemove(kData, true);
- break;
- case kEnginePostActionSwitchPlugins:
- doPluginsSwitch(kData, true);
- break;
- }
-
- if (kData->time.playing)
- kData->time.frame += fBufferSize;
-
- if (fOptions.transportMode == CarlaBackend::TRANSPORT_MODE_INTERNAL)
- {
- fTimeInfo.playing = kData->time.playing;
- fTimeInfo.frame = kData->time.frame;
- }
-
- for (unsigned int i=0; i < kData->curPluginCount; ++i)
- {
- // TODO - peak values?
- }
- }
-
- void CarlaEngine::setPeaks(const unsigned int pluginId, float const inPeaks[MAX_PEAKS], float const outPeaks[MAX_PEAKS])
- {
- kData->plugins[pluginId].insPeak[0] = inPeaks[0];
- kData->plugins[pluginId].insPeak[1] = inPeaks[1];
- kData->plugins[pluginId].outsPeak[0] = outPeaks[0];
- kData->plugins[pluginId].outsPeak[1] = outPeaks[1];
- }
-
- EngineEvent* CarlaEngine::getInternalEventBuffer(const bool isInput) const
- {
- return isInput ? kData->bufEvent.in : kData->bufEvent.out;
- }
-
- #ifndef BUILD_BRIDGE
- void setValueIfHigher(float& value, const float& compare)
- {
- if (value < compare)
- value = compare;
- }
-
- void CarlaEngine::processRack(float* inBuf[2], float* outBuf[2], const uint32_t frames)
- {
- CARLA_ASSERT(kData->bufEvent.in != nullptr);
- CARLA_ASSERT(kData->bufEvent.out != nullptr);
-
- // initialize outputs (zero)
- carla_zeroFloat(outBuf[0], frames);
- carla_zeroFloat(outBuf[1], frames);
- carla_zeroMem(kData->bufEvent.out, sizeof(EngineEvent)*INTERNAL_EVENT_COUNT);
-
- bool processed = false;
-
- // process plugins
- for (unsigned int i=0; i < kData->curPluginCount; ++i)
- {
- CarlaPlugin* const plugin = kData->plugins[i].plugin;
-
- if (plugin == nullptr || ! plugin->enabled() || ! plugin->tryLock())
- continue;
-
- if (processed)
- {
- // initialize inputs (from previous outputs)
- carla_copyFloat(inBuf[0], outBuf[0], frames);
- carla_copyFloat(inBuf[1], outBuf[1], frames);
- std::memcpy(kData->bufEvent.in, kData->bufEvent.out, sizeof(EngineEvent)*INTERNAL_EVENT_COUNT);
-
- // initialize outputs (zero)
- carla_zeroFloat(outBuf[0], frames);
- carla_zeroFloat(outBuf[1], frames);
- carla_zeroMem(kData->bufEvent.out, sizeof(EngineEvent)*INTERNAL_EVENT_COUNT);
- }
-
- // process
- plugin->initBuffers();
- plugin->process(inBuf, outBuf, frames);
- plugin->unlock();
-
- #if 0
- // if plugin has no audio inputs, add previous buffers
- if (plugin->audioInCount() == 0)
- {
- for (uint32_t j=0; j < frames; ++j)
- {
- outBuf[0][j] += inBuf[0][j];
- outBuf[1][j] += inBuf[1][j];
- }
- }
- // if plugin has no midi output, add previous events
- if (plugin->midiOutCount() == 0)
- {
- for (uint32_t j=0, k=0; j < frames; ++j)
- {
-
- }
- std::memcpy(kData->rack.out, kData->rack.in, sizeof(EngineEvent)*RACK_EVENT_COUNT);
- }
- #endif
-
- // set peaks
- {
- float inPeak1 = 0.0f;
- float inPeak2 = 0.0f;
- float outPeak1 = 0.0f;
- float outPeak2 = 0.0f;
-
- for (uint32_t k=0; k < frames; ++k)
- {
- setValueIfHigher(inPeak1, std::fabs(inBuf[0][k]));
- setValueIfHigher(inPeak2, std::fabs(inBuf[1][k]));
- setValueIfHigher(outPeak1, std::fabs(outBuf[0][k]));
- setValueIfHigher(outPeak2, std::fabs(outBuf[1][k]));
- }
-
- kData->plugins[i].insPeak[0] = inPeak1;
- kData->plugins[i].insPeak[1] = inPeak2;
- kData->plugins[i].outsPeak[0] = outPeak1;
- kData->plugins[i].outsPeak[1] = outPeak2;
- }
-
- processed = true;
- }
- }
-
- void CarlaEngine::processPatchbay(float** inBuf, float** outBuf, const uint32_t bufCount[2], const uint32_t frames)
- {
- // TODO
- return;
-
- // unused, for now
- (void)inBuf;
- (void)outBuf;
- (void)bufCount;
- (void)frames;
- }
- #endif
-
- // -------------------------------------------------------------------------------------------------------------------
- // Carla Engine OSC stuff
-
- #ifndef BUILD_BRIDGE
- void CarlaEngine::osc_send_control_add_plugin_start(const int32_t pluginId, const char* const pluginName)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- CARLA_ASSERT(pluginName != nullptr);
- carla_debug("CarlaEngine::osc_send_control_add_plugin_start(%i, \"%s\")", pluginId, pluginName);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+18];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/add_plugin_start");
- lo_send(kData->oscData->target, targetPath, "is", pluginId, pluginName);
- }
- }
-
- void CarlaEngine::osc_send_control_add_plugin_end(const int32_t pluginId)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- carla_debug("CarlaEngine::osc_send_control_add_plugin_end(%i)", pluginId);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+16];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/add_plugin_end");
- lo_send(kData->oscData->target, targetPath, "i", pluginId);
- }
- }
-
- void CarlaEngine::osc_send_control_remove_plugin(const int32_t pluginId)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->curPluginCount));
- carla_debug("CarlaEngine::osc_send_control_remove_plugin(%i)", pluginId);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+15];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/remove_plugin");
- lo_send(kData->oscData->target, targetPath, "i", pluginId);
- }
- }
-
- void CarlaEngine::osc_send_control_set_plugin_data(const int32_t pluginId, const int32_t type, const int32_t category, const int32_t hints, const char* const realName, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- CARLA_ASSERT(type != PLUGIN_NONE);
- CARLA_ASSERT(realName != nullptr);
- CARLA_ASSERT(label != nullptr);
- CARLA_ASSERT(maker != nullptr);
- CARLA_ASSERT(copyright != nullptr);
- carla_debug("CarlaEngine::osc_send_control_set_plugin_data(%i, %i, %i, %i, \"%s\", \"%s\", \"%s\", \"%s\", " P_INT64 ")", pluginId, type, category, hints, realName, label, maker, copyright, uniqueId);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+17];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_plugin_data");
- lo_send(kData->oscData->target, targetPath, "iiiissssh", pluginId, type, category, hints, realName, label, maker, copyright, uniqueId);
- }
- }
-
- void CarlaEngine::osc_send_control_set_plugin_ports(const int32_t pluginId, const int32_t audioIns, const int32_t audioOuts, const int32_t midiIns, const int32_t midiOuts, const int32_t cIns, const int32_t cOuts, const int32_t cTotals)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- carla_debug("CarlaEngine::osc_send_control_set_plugin_ports(%i, %i, %i, %i, %i, %i, %i, %i)", pluginId, audioIns, audioOuts, midiIns, midiOuts, cIns, cOuts, cTotals);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+18];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_plugin_ports");
- lo_send(kData->oscData->target, targetPath, "iiiiiiii", pluginId, audioIns, audioOuts, midiIns, midiOuts, cIns, cOuts, cTotals);
- }
- }
-
- void CarlaEngine::osc_send_control_set_parameter_data(const int32_t pluginId, const int32_t index, const int32_t type, const int32_t hints, const char* const name, const char* const label, const float current)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- CARLA_ASSERT(index >= 0);
- CARLA_ASSERT(type != PARAMETER_UNKNOWN);
- CARLA_ASSERT(name != nullptr);
- CARLA_ASSERT(label != nullptr);
- carla_debug("CarlaEngine::osc_send_control_set_parameter_data(%i, %i, %i, %i, \"%s\", \"%s\", %f)", pluginId, index, type, hints, name, label, current);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+20];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_parameter_data");
- lo_send(kData->oscData->target, targetPath, "iiiissf", pluginId, index, type, hints, name, label, current);
- }
- }
-
- void CarlaEngine::osc_send_control_set_parameter_ranges(const int32_t pluginId, const int32_t index, const float min, const float max, const float def, const float step, const float stepSmall, const float stepLarge)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- CARLA_ASSERT(index >= 0);
- CARLA_ASSERT(min < max);
- carla_debug("CarlaEngine::osc_send_control_set_parameter_ranges(%i, %i, %f, %f, %f, %f, %f, %f)", pluginId, index, min, max, def, step, stepSmall, stepLarge);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+22];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_parameter_ranges");
- lo_send(kData->oscData->target, targetPath, "iiffffff", pluginId, index, min, max, def, step, stepSmall, stepLarge);
- }
- }
-
- void CarlaEngine::osc_send_control_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- CARLA_ASSERT(index >= 0);
- carla_debug("CarlaEngine::osc_send_control_set_parameter_midi_cc(%i, %i, %i)", pluginId, index, cc);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+23];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_parameter_midi_cc");
- lo_send(kData->oscData->target, targetPath, "iii", pluginId, index, cc);
- }
- }
-
- void CarlaEngine::osc_send_control_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- CARLA_ASSERT(index >= 0);
- CARLA_ASSERT(channel >= 0 && channel < 16);
- carla_debug("CarlaEngine::osc_send_control_set_parameter_midi_channel(%i, %i, %i)", pluginId, index, channel);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+28];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_parameter_midi_channel");
- lo_send(kData->oscData->target, targetPath, "iii", pluginId, index, channel);
- }
- }
-
- void CarlaEngine::osc_send_control_set_parameter_value(const int32_t pluginId, const int32_t index, const float value)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- #if DEBUG
- if (index < 0)
- carla_debug("CarlaEngine::osc_send_control_set_parameter_value(%i, %s, %f)", pluginId, InternalParametersIndex2Str((InternalParametersIndex)index), value);
- else
- carla_debug("CarlaEngine::osc_send_control_set_parameter_value(%i, %i, %f)", pluginId, index, value);
- #endif
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+21];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_parameter_value");
- lo_send(kData->oscData->target, targetPath, "iif", pluginId, index, value);
- }
- }
-
- void CarlaEngine::osc_send_control_set_default_value(const int32_t pluginId, const int32_t index, const float value)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- CARLA_ASSERT(index >= 0);
- carla_debug("CarlaEngine::osc_send_control_set_default_value(%i, %i, %f)", pluginId, index, value);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+19];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_default_value");
- lo_send(kData->oscData->target, targetPath, "iif", pluginId, index, value);
- }
- }
-
- void CarlaEngine::osc_send_control_set_program(const int32_t pluginId, const int32_t index)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- carla_debug("CarlaEngine::osc_send_control_set_program(%i, %i)", pluginId, index);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+13];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_program");
- lo_send(kData->oscData->target, targetPath, "ii", pluginId, index);
- }
- }
-
- void CarlaEngine::osc_send_control_set_program_count(const int32_t pluginId, const int32_t count)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- CARLA_ASSERT(count >= 0);
- carla_debug("CarlaEngine::osc_send_control_set_program_count(%i, %i)", pluginId, count);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+19];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_program_count");
- lo_send(kData->oscData->target, targetPath, "ii", pluginId, count);
- }
- }
-
- void CarlaEngine::osc_send_control_set_program_name(const int32_t pluginId, const int32_t index, const char* const name)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- CARLA_ASSERT(index >= 0);
- CARLA_ASSERT(name != nullptr);
- carla_debug("CarlaEngine::osc_send_control_set_program_name(%i, %i, \"%s\")", pluginId, index, name);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+18];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_program_name");
- lo_send(kData->oscData->target, targetPath, "iis", pluginId, index, name);
- }
- }
-
- void CarlaEngine::osc_send_control_set_midi_program(const int32_t pluginId, const int32_t index)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- carla_debug("CarlaEngine::osc_send_control_set_midi_program(%i, %i)", pluginId, index);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+18];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_midi_program");
- lo_send(kData->oscData->target, targetPath, "ii", pluginId, index);
- }
- }
-
- void CarlaEngine::osc_send_control_set_midi_program_count(const int32_t pluginId, const int32_t count)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- CARLA_ASSERT(count >= 0);
- carla_debug("CarlaEngine::osc_send_control_set_midi_program_count(%i, %i)", pluginId, count);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+24];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_midi_program_count");
- lo_send(kData->oscData->target, targetPath, "ii", pluginId, count);
- }
- }
-
- void CarlaEngine::osc_send_control_set_midi_program_data(const int32_t pluginId, const int32_t index, const int32_t bank, const int32_t program, const char* const name)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->maxPluginNumber));
- CARLA_ASSERT(index >= 0);
- CARLA_ASSERT(bank >= 0);
- CARLA_ASSERT(program >= 0);
- CARLA_ASSERT(name != nullptr);
- carla_debug("CarlaEngine::osc_send_control_set_midi_program_data(%i, %i, %i, %i, \"%s\")", pluginId, index, bank, program, name);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+23];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_midi_program_data");
- lo_send(kData->oscData->target, targetPath, "iiiis", pluginId, index, bank, program, name);
- }
- }
-
- void CarlaEngine::osc_send_control_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->curPluginCount));
- CARLA_ASSERT(channel >= 0 && channel < MAX_MIDI_CHANNELS);
- CARLA_ASSERT(note >= 0 && note < MAX_MIDI_NOTE);
- CARLA_ASSERT(velo > 0 && velo < MAX_MIDI_VALUE);
- carla_debug("CarlaEngine::osc_send_control_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+9];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/note_on");
- lo_send(kData->oscData->target, targetPath, "iiii", pluginId, channel, note, velo);
- }
- }
-
- void CarlaEngine::osc_send_control_note_off(const int32_t pluginId, const int32_t channel, const int32_t note)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->curPluginCount));
- CARLA_ASSERT(channel >= 0 && channel < MAX_MIDI_CHANNELS);
- CARLA_ASSERT(note >= 0 && note < MAX_MIDI_NOTE);
- carla_debug("CarlaEngine::osc_send_control_note_off(%i, %i, %i)", pluginId, channel, note);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+10];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/note_off");
- lo_send(kData->oscData->target, targetPath, "iii", pluginId, channel, note);
- }
- }
-
- void CarlaEngine::osc_send_control_set_peaks(const int32_t pluginId)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast<int32_t>(kData->curPluginCount));
-
- const EnginePluginData& pData = kData->plugins[pluginId];
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+22];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/set_peaks");
- lo_send(kData->oscData->target, targetPath, "iffff", pluginId, pData.insPeak[0], pData.insPeak[1], pData.outsPeak[0], pData.outsPeak[1]);
- }
- }
-
- void CarlaEngine::osc_send_control_exit()
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- carla_debug("CarlaEngine::osc_send_control_exit()");
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+6];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/exit");
- lo_send(kData->oscData->target, targetPath, "");
- }
- }
- #else
- void CarlaEngine::osc_send_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(total >= 0 && total >= ins + outs);
- carla_debug("CarlaEngine::osc_send_bridge_audio_count(%i, %i, %i)", ins, outs, total);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+20];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_audio_count");
- lo_send(kData->oscData->target, targetPath, "iii", ins, outs, total);
- }
- }
-
- void CarlaEngine::osc_send_bridge_midi_count(const int32_t ins, const int32_t outs, const int32_t total)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(total >= 0 && total >= ins + outs);
- carla_debug("CarlaEngine::osc_send_bridge_midi_count(%i, %i, %i)", ins, outs, total);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+19];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_midi_count");
- lo_send(kData->oscData->target, targetPath, "iii", ins, outs, total);
- }
- }
-
- void CarlaEngine::osc_send_bridge_parameter_count(const int32_t ins, const int32_t outs, const int32_t total)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(total >= 0 && total >= ins + outs);
- carla_debug("CarlaEngine::osc_send_bridge_parameter_count(%i, %i, %i)", ins, outs, total);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+24];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_parameter_count");
- lo_send(kData->oscData->target, targetPath, "iii", ins, outs, total);
- }
- }
-
- void CarlaEngine::osc_send_bridge_program_count(const int32_t count)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(count >= 0);
- carla_debug("CarlaEngine::osc_send_bridge_program_count(%i)", count);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+22];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_program_count");
- lo_send(kData->oscData->target, targetPath, "i", count);
- }
- }
-
- void CarlaEngine::osc_send_bridge_midi_program_count(const int32_t count)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(count >= 0);
- carla_debug("CarlaEngine::osc_send_bridge_midi_program_count(%i)", count);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+27];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_midi_program_count");
- lo_send(kData->oscData->target, targetPath, "i", count);
- }
- }
-
- void CarlaEngine::osc_send_bridge_plugin_info(const int32_t category, const int32_t hints, const char* const name, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(name != nullptr);
- CARLA_ASSERT(label != nullptr);
- CARLA_ASSERT(maker != nullptr);
- CARLA_ASSERT(copyright != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_plugin_info(%i, %i, \"%s\", \"%s\", \"%s\", \"%s\", " P_INT64 ")", category, hints, name, label, maker, copyright, uniqueId);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+20];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_plugin_info");
- lo_send(kData->oscData->target, targetPath, "iissssh", category, hints, name, label, maker, copyright, uniqueId);
- }
- }
-
- void CarlaEngine::osc_send_bridge_parameter_info(const int32_t index, const char* const name, const char* const unit)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(name != nullptr);
- CARLA_ASSERT(unit != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_parameter_info(%i, \"%s\", \"%s\")", index, name, unit);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+23];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_parameter_info");
- lo_send(kData->oscData->target, targetPath, "iss", index, name, unit);
- }
- }
-
- void CarlaEngine::osc_send_bridge_parameter_data(const int32_t index, const int32_t type, const int32_t rindex, const int32_t hints, const int32_t midiChannel, const int32_t midiCC)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_parameter_data(%i, %i, %i, %i, %i, %i)", index, type, rindex, hints, midiChannel, midiCC);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+23];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_parameter_data");
- lo_send(kData->oscData->target, targetPath, "iiiiii", index, type, rindex, hints, midiChannel, midiCC);
- }
- }
-
- void CarlaEngine::osc_send_bridge_parameter_ranges(const int32_t index, const float def, const float min, const float max, const float step, const float stepSmall, const float stepLarge)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_parameter_ranges(%i, %f, %f, %f, %f, %f, %f)", index, def, min, max, step, stepSmall, stepLarge);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+25];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_parameter_ranges");
- lo_send(kData->oscData->target, targetPath, "iffffff", index, def, min, max, step, stepSmall, stepLarge);
- }
- }
-
- void CarlaEngine::osc_send_bridge_program_info(const int32_t index, const char* const name)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_program_info(%i, \"%s\")", index, name);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+21];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_program_info");
- lo_send(kData->oscData->target, targetPath, "is", index, name);
- }
- }
-
- void CarlaEngine::osc_send_bridge_midi_program_info(const int32_t index, const int32_t bank, const int32_t program, const char* const label)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_midi_program_info(%i, %i, %i, \"%s\")", index, bank, program, label);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+26];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_midi_program_info");
- lo_send(kData->oscData->target, targetPath, "iiis", index, bank, program, label);
- }
- }
-
- void CarlaEngine::osc_send_bridge_configure(const char* const key, const char* const value)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- CARLA_ASSERT(key != nullptr);
- CARLA_ASSERT(value != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_configure(\"%s\", \"%s\")", key, value);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+18];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_configure");
- lo_send(kData->oscData->target, targetPath, "ss", key, value);
- }
- }
-
- void CarlaEngine::osc_send_bridge_set_parameter_value(const int32_t index, const float value)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_set_parameter_value(%i, %f)", index, value);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+28];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_set_parameter_value");
- lo_send(kData->oscData->target, targetPath, "if", index, value);
- }
- }
-
- void CarlaEngine::osc_send_bridge_set_default_value(const int32_t index, const float value)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_set_default_value(%i, %f)", index, value);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+26];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_set_default_value");
- lo_send(kData->oscData->target, targetPath, "if", index, value);
- }
- }
-
- void CarlaEngine::osc_send_bridge_set_program(const int32_t index)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_set_program(%i)", index);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+20];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_set_program");
- lo_send(kData->oscData->target, targetPath, "i", index);
- }
- }
-
- void CarlaEngine::osc_send_bridge_set_midi_program(const int32_t index)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_set_midi_program(%i)", index);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+25];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_set_midi_program");
- lo_send(kData->oscData->target, targetPath, "i", index);
- }
- }
-
- void CarlaEngine::osc_send_bridge_set_custom_data(const char* const type, const char* const key, const char* const value)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_set_custom_data(\"%s\", \"%s\", \"%s\")", type, key, value);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+24];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_set_custom_data");
- lo_send(kData->oscData->target, targetPath, "sss", type, key, value);
- }
- }
-
- void CarlaEngine::osc_send_bridge_set_chunk_data(const char* const chunkFile)
- {
- CARLA_ASSERT(kData->oscData != nullptr);
- carla_debug("CarlaEngine::osc_send_bridge_set_chunk_data(\"%s\")", chunkFile);
-
- if (kData->oscData != nullptr && kData->oscData->target != nullptr)
- {
- char targetPath[std::strlen(kData->oscData->path)+23];
- std::strcpy(targetPath, kData->oscData->path);
- std::strcat(targetPath, "/bridge_set_chunk_data");
- lo_send(kData->oscData->target, targetPath, "s", chunkFile);
- }
- }
- #endif
-
- CARLA_BACKEND_END_NAMESPACE
|