Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2922 lines
111KB

  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. /* TODO:
  18. * - complete processRack(): carefully add to input, sorted events
  19. * - implement processPatchbay()
  20. * - implement oscSend_control_switch_plugins()
  21. * - proper find&load plugins
  22. * - something about the peaks?
  23. * - patchbayDisconnect should return false sometimes
  24. */
  25. #include "CarlaEngineInternal.hpp"
  26. #include "CarlaPlugin.hpp"
  27. #include "CarlaBackendUtils.hpp"
  28. #include "CarlaEngineUtils.hpp"
  29. #include "CarlaMathUtils.hpp"
  30. #include "CarlaStateUtils.hpp"
  31. #include "CarlaMIDI.h"
  32. #include <QtCore/QDir>
  33. #include <QtCore/QFile>
  34. #include <QtCore/QFileInfo>
  35. #include <QtCore/QTextStream>
  36. #include <QtXml/QDomNode>
  37. // -----------------------------------------------------------------------
  38. CARLA_BACKEND_START_NAMESPACE
  39. #if 0
  40. } // Fix editor indentation
  41. #endif
  42. // -----------------------------------------------------------------------
  43. // Fallback data
  44. static const EngineEvent kFallbackEngineEvent = { kEngineEventTypeNull, 0, 0, {{ kEngineControlEventTypeNull, 0, 0.0f }} };
  45. // -----------------------------------------------------------------------
  46. // Carla Engine port (Abstract)
  47. CarlaEnginePort::CarlaEnginePort(const CarlaEngine& engine, const bool isInputPort)
  48. : fEngine(engine),
  49. fIsInput(isInputPort)
  50. {
  51. carla_debug("CarlaEnginePort::CarlaEnginePort(%s)", bool2str(isInputPort));
  52. }
  53. CarlaEnginePort::~CarlaEnginePort()
  54. {
  55. carla_debug("CarlaEnginePort::~CarlaEnginePort()");
  56. }
  57. // -----------------------------------------------------------------------
  58. // Carla Engine Audio port
  59. CarlaEngineAudioPort::CarlaEngineAudioPort(const CarlaEngine& engine, const bool isInputPort)
  60. : CarlaEnginePort(engine, isInputPort),
  61. fBuffer(nullptr)
  62. {
  63. carla_debug("CarlaEngineAudioPort::CarlaEngineAudioPort(%s)", bool2str(isInputPort));
  64. }
  65. CarlaEngineAudioPort::~CarlaEngineAudioPort()
  66. {
  67. carla_debug("CarlaEngineAudioPort::~CarlaEngineAudioPort()");
  68. }
  69. void CarlaEngineAudioPort::initBuffer() noexcept
  70. {
  71. }
  72. // -----------------------------------------------------------------------
  73. // Carla Engine CV port
  74. CarlaEngineCVPort::CarlaEngineCVPort(const CarlaEngine& engine, const bool isInputPort)
  75. : CarlaEnginePort(engine, isInputPort),
  76. fBuffer(nullptr),
  77. fProcessMode(engine.getProccessMode())
  78. {
  79. carla_debug("CarlaEngineCVPort::CarlaEngineCVPort(%s)", bool2str(isInputPort));
  80. if (fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
  81. fBuffer = new float[engine.getBufferSize()];
  82. }
  83. CarlaEngineCVPort::~CarlaEngineCVPort()
  84. {
  85. carla_debug("CarlaEngineCVPort::~CarlaEngineCVPort()");
  86. if (fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
  87. {
  88. CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr,);
  89. delete[] fBuffer;
  90. fBuffer = nullptr;
  91. }
  92. }
  93. void CarlaEngineCVPort::initBuffer() noexcept
  94. {
  95. CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr,);
  96. CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS,);
  97. carla_zeroFloat(fBuffer, fEngine.getBufferSize());
  98. }
  99. void CarlaEngineCVPort::setBufferSize(const uint32_t bufferSize)
  100. {
  101. CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr,);
  102. CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS,);
  103. delete[] fBuffer;
  104. fBuffer = new float[bufferSize];
  105. }
  106. // -----------------------------------------------------------------------
  107. // Carla Engine Event port
  108. CarlaEngineEventPort::CarlaEngineEventPort(const CarlaEngine& engine, const bool isInputPort)
  109. : CarlaEnginePort(engine, isInputPort),
  110. fBuffer(nullptr),
  111. fProcessMode(engine.getProccessMode())
  112. {
  113. carla_debug("CarlaEngineEventPort::CarlaEngineEventPort(%s)", bool2str(isInputPort));
  114. if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY)
  115. fBuffer = new EngineEvent[kMaxEngineEventInternalCount];
  116. }
  117. CarlaEngineEventPort::~CarlaEngineEventPort()
  118. {
  119. carla_debug("CarlaEngineEventPort::~CarlaEngineEventPort()");
  120. if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY)
  121. {
  122. CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr,);
  123. delete[] fBuffer;
  124. fBuffer = nullptr;
  125. }
  126. }
  127. void CarlaEngineEventPort::initBuffer() noexcept
  128. {
  129. if (fProcessMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || fProcessMode == ENGINE_PROCESS_MODE_BRIDGE)
  130. fBuffer = fEngine.getInternalEventBuffer(fIsInput);
  131. else if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY && ! fIsInput)
  132. carla_zeroStruct<EngineEvent>(fBuffer, kMaxEngineEventInternalCount);
  133. }
  134. uint32_t CarlaEngineEventPort::getEventCount() const noexcept
  135. {
  136. CARLA_SAFE_ASSERT_RETURN(fIsInput, 0);
  137. CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, 0);
  138. CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, 0);
  139. uint32_t i=0;
  140. for (; i < kMaxEngineEventInternalCount; ++i)
  141. {
  142. if (fBuffer[i].type == kEngineEventTypeNull)
  143. break;
  144. }
  145. return i;
  146. }
  147. const EngineEvent& CarlaEngineEventPort::getEvent(const uint32_t index) const noexcept
  148. {
  149. CARLA_SAFE_ASSERT_RETURN(fIsInput, kFallbackEngineEvent);
  150. CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, kFallbackEngineEvent);
  151. CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, kFallbackEngineEvent);
  152. CARLA_SAFE_ASSERT_RETURN(index < kMaxEngineEventInternalCount, kFallbackEngineEvent);
  153. return fBuffer[index];
  154. }
  155. const EngineEvent& CarlaEngineEventPort::getEventUnchecked(const uint32_t index) const noexcept
  156. {
  157. return fBuffer[index];
  158. }
  159. bool CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEventType type, const uint16_t param, const float value) noexcept
  160. {
  161. CARLA_SAFE_ASSERT_RETURN(! fIsInput, false);
  162. CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, false);
  163. CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, false);
  164. CARLA_SAFE_ASSERT_RETURN(type != kEngineControlEventTypeNull, false);
  165. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, false);
  166. CARLA_SAFE_ASSERT(value >= 0.0f && value <= 1.0f);
  167. if (type == kEngineControlEventTypeParameter) {
  168. CARLA_SAFE_ASSERT(! MIDI_IS_CONTROL_BANK_SELECT(param));
  169. }
  170. // FIXME? should not fix range if midi-program
  171. const float fixedValue(carla_fixValue<float>(0.0f, 1.0f, value));
  172. for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i)
  173. {
  174. EngineEvent& event(fBuffer[i]);
  175. if (event.type != kEngineEventTypeNull)
  176. continue;
  177. event.type = kEngineEventTypeControl;
  178. event.time = time;
  179. event.channel = channel;
  180. event.ctrl.type = type;
  181. event.ctrl.param = param;
  182. event.ctrl.value = fixedValue;
  183. return true;
  184. }
  185. carla_stderr2("CarlaEngineEventPort::writeControlEvent() - buffer full");
  186. return false;
  187. }
  188. bool CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEvent& ctrl) noexcept
  189. {
  190. return writeControlEvent(time, channel, ctrl.type, ctrl.param, ctrl.value);
  191. }
  192. bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t channel, const uint8_t port, const uint8_t size, const uint8_t* const data) noexcept
  193. {
  194. CARLA_SAFE_ASSERT_RETURN(! fIsInput, false);
  195. CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, false);
  196. CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, false);
  197. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, false);
  198. CARLA_SAFE_ASSERT_RETURN(size > 0 && size <= EngineMidiEvent::kDataSize, false);
  199. CARLA_SAFE_ASSERT_RETURN(data != nullptr, false);
  200. for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i)
  201. {
  202. EngineEvent& event(fBuffer[i]);
  203. if (event.type != kEngineEventTypeNull)
  204. continue;
  205. event.type = kEngineEventTypeMidi;
  206. event.time = time;
  207. event.channel = channel;
  208. event.midi.port = port;
  209. event.midi.size = size;
  210. event.midi.data[0] = uint8_t(MIDI_GET_STATUS_FROM_DATA(data));
  211. uint8_t j=1;
  212. for (; j < size; ++j)
  213. event.midi.data[j] = data[j];
  214. for (; j < EngineMidiEvent::kDataSize; ++j)
  215. event.midi.data[j] = 0;
  216. return true;
  217. }
  218. carla_stderr2("CarlaEngineEventPort::writeMidiEvent() - buffer full");
  219. return false;
  220. }
  221. bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t size, const uint8_t* const data) noexcept
  222. {
  223. return writeMidiEvent(time, uint8_t(MIDI_GET_CHANNEL_FROM_DATA(data)), 0, size, data);
  224. }
  225. bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t channel, const EngineMidiEvent& midi) noexcept
  226. {
  227. return writeMidiEvent(time, channel, midi.port, midi.size, midi.data);
  228. }
  229. // -----------------------------------------------------------------------
  230. // Carla Engine client (Abstract)
  231. CarlaEngineClient::CarlaEngineClient(const CarlaEngine& engine)
  232. : fEngine(engine),
  233. fActive(false),
  234. fLatency(0)
  235. {
  236. carla_debug("CarlaEngineClient::CarlaEngineClient()");
  237. }
  238. CarlaEngineClient::~CarlaEngineClient()
  239. {
  240. CARLA_ASSERT(! fActive);
  241. carla_debug("CarlaEngineClient::~CarlaEngineClient()");
  242. }
  243. void CarlaEngineClient::activate() noexcept
  244. {
  245. CARLA_ASSERT(! fActive);
  246. carla_debug("CarlaEngineClient::activate()");
  247. fActive = true;
  248. }
  249. void CarlaEngineClient::deactivate() noexcept
  250. {
  251. CARLA_ASSERT(fActive);
  252. carla_debug("CarlaEngineClient::deactivate()");
  253. fActive = false;
  254. }
  255. bool CarlaEngineClient::isActive() const noexcept
  256. {
  257. return fActive;
  258. }
  259. bool CarlaEngineClient::isOk() const noexcept
  260. {
  261. return true;
  262. }
  263. uint32_t CarlaEngineClient::getLatency() const noexcept
  264. {
  265. return fLatency;
  266. }
  267. void CarlaEngineClient::setLatency(const uint32_t samples) noexcept
  268. {
  269. fLatency = samples;
  270. }
  271. CarlaEnginePort* CarlaEngineClient::addPort(const EnginePortType portType, const char* const name, const bool isInput)
  272. {
  273. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', nullptr);
  274. carla_debug("CarlaEngineClient::addPort(%i:%s, \"%s\", %s)", portType, EnginePortType2Str(portType), name, bool2str(isInput));
  275. switch (portType)
  276. {
  277. case kEnginePortTypeNull:
  278. break;
  279. case kEnginePortTypeAudio:
  280. return new CarlaEngineAudioPort(fEngine, isInput);
  281. case kEnginePortTypeCV:
  282. return new CarlaEngineCVPort(fEngine, isInput);
  283. case kEnginePortTypeEvent:
  284. return new CarlaEngineEventPort(fEngine, isInput);
  285. }
  286. carla_stderr("CarlaEngineClient::addPort(%i, \"%s\", %s) - invalid type", portType, name, bool2str(isInput));
  287. return nullptr;
  288. }
  289. // -----------------------------------------------------------------------
  290. // Carla Engine
  291. CarlaEngine::CarlaEngine()
  292. : pData(new CarlaEngineProtectedData(this))
  293. {
  294. carla_debug("CarlaEngine::CarlaEngine()");
  295. }
  296. CarlaEngine::~CarlaEngine()
  297. {
  298. carla_debug("CarlaEngine::~CarlaEngine()");
  299. delete pData;
  300. }
  301. // -----------------------------------------------------------------------
  302. // Static calls
  303. unsigned int CarlaEngine::getDriverCount()
  304. {
  305. carla_debug("CarlaEngine::getDriverCount()");
  306. unsigned int count = 1; // JACK
  307. #ifndef BUILD_BRIDGE
  308. count += getRtAudioApiCount();
  309. # ifdef HAVE_JUCE
  310. count += getJuceApiCount();
  311. # endif
  312. #endif
  313. return count;
  314. }
  315. const char* CarlaEngine::getDriverName(const unsigned int index)
  316. {
  317. carla_debug("CarlaEngine::getDriverName(%i)", index);
  318. if (index == 0)
  319. return "JACK";
  320. #ifndef BUILD_BRIDGE
  321. const unsigned int rtAudioIndex(index-1);
  322. if (rtAudioIndex < getRtAudioApiCount())
  323. return getRtAudioApiName(rtAudioIndex);
  324. # ifdef HAVE_JUCE
  325. const unsigned int juceIndex(index-rtAudioIndex-1);
  326. if (juceIndex < getJuceApiCount())
  327. return getJuceApiName(juceIndex);
  328. # endif
  329. #endif
  330. carla_stderr("CarlaEngine::getDriverName(%i) - invalid index", index);
  331. return nullptr;
  332. }
  333. const char* const* CarlaEngine::getDriverDeviceNames(const unsigned int index)
  334. {
  335. carla_debug("CarlaEngine::getDriverDeviceNames(%i)", index);
  336. if (index == 0) // JACK
  337. {
  338. static const char* ret[3] = { "Auto-Connect OFF", "Auto-Connect ON", nullptr };
  339. return ret;
  340. }
  341. #ifndef BUILD_BRIDGE
  342. const unsigned int rtAudioIndex(index-1);
  343. if (rtAudioIndex < getRtAudioApiCount())
  344. return getRtAudioApiDeviceNames(rtAudioIndex);
  345. # ifdef HAVE_JUCE
  346. const unsigned int juceIndex(index-rtAudioIndex-1);
  347. if (juceIndex < getJuceApiCount())
  348. return getJuceApiDeviceNames(juceIndex);
  349. # endif
  350. #endif
  351. carla_stderr("CarlaEngine::getDriverDeviceNames(%i) - invalid index", index);
  352. return nullptr;
  353. }
  354. const EngineDriverDeviceInfo* CarlaEngine::getDriverDeviceInfo(const unsigned int index, const char* const deviceName)
  355. {
  356. carla_debug("CarlaEngine::getDriverDeviceInfo(%i, \"%s\")", index, deviceName);
  357. if (index == 0) // JACK
  358. {
  359. static uint32_t bufSizes[11] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 0 };
  360. static EngineDriverDeviceInfo devInfo;
  361. devInfo.hints = ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE;
  362. devInfo.bufferSizes = bufSizes;
  363. devInfo.sampleRates = nullptr;
  364. return &devInfo;
  365. }
  366. #ifndef BUILD_BRIDGE
  367. const unsigned int rtAudioIndex(index-1);
  368. if (rtAudioIndex < getRtAudioApiCount())
  369. return getRtAudioDeviceInfo(rtAudioIndex, deviceName);
  370. # ifdef HAVE_JUCE
  371. const unsigned int juceIndex(index-rtAudioIndex-1);
  372. if (juceIndex < getJuceApiCount())
  373. return getJuceDeviceInfo(juceIndex, deviceName);
  374. # endif
  375. #endif
  376. carla_stderr("CarlaEngine::getDriverDeviceNames(%i, \"%s\") - invalid index", index, deviceName);
  377. return nullptr;
  378. }
  379. CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName)
  380. {
  381. CARLA_SAFE_ASSERT_RETURN(driverName != nullptr && driverName[0] != '\0', nullptr);
  382. carla_debug("CarlaEngine::newDriverByName(\"%s\")", driverName);
  383. if (std::strcmp(driverName, "JACK") == 0)
  384. return newJack();
  385. // common
  386. if (std::strncmp(driverName, "JACK ", 5) == 0)
  387. return newRtAudio(AUDIO_API_JACK);
  388. // linux
  389. #if 0//def HAVE_JUCE
  390. if (std::strcmp(driverName, "ALSA") == 0)
  391. return newJuce(AUDIO_API_ALSA);
  392. #else
  393. if (std::strcmp(driverName, "ALSA") == 0)
  394. return newRtAudio(AUDIO_API_ALSA);
  395. #endif
  396. if (std::strcmp(driverName, "OSS") == 0)
  397. return newRtAudio(AUDIO_API_OSS);
  398. if (std::strcmp(driverName, "PulseAudio") == 0)
  399. return newRtAudio(AUDIO_API_PULSE);
  400. // macos
  401. #if 0//def HAVE_JUCE
  402. if (std::strcmp(driverName, "CoreAudio") == 0)
  403. return newJuce(AUDIO_API_CORE);
  404. #else
  405. if (std::strcmp(driverName, "CoreAudio") == 0)
  406. return newRtAudio(AUDIO_API_CORE);
  407. #endif
  408. // windows
  409. #if 0//def HAVE_JUCE
  410. if (std::strcmp(driverName, "ASIO") == 0)
  411. return newJuce(AUDIO_API_ASIO);
  412. if (std::strcmp(driverName, "DirectSound") == 0)
  413. return newJuce(AUDIO_API_DS);
  414. #else
  415. if (std::strcmp(driverName, "ASIO") == 0)
  416. return newRtAudio(AUDIO_API_ASIO);
  417. if (std::strcmp(driverName, "DirectSound") == 0)
  418. return newRtAudio(AUDIO_API_DS);
  419. #endif
  420. carla_stderr("CarlaEngine::newDriverByName(\"%s\") - invalid driver name", driverName);
  421. return nullptr;
  422. }
  423. // -----------------------------------------------------------------------
  424. // Maximum values
  425. unsigned int CarlaEngine::getMaxClientNameSize() const noexcept
  426. {
  427. return STR_MAX/2;
  428. }
  429. unsigned int CarlaEngine::getMaxPortNameSize() const noexcept
  430. {
  431. return STR_MAX;
  432. }
  433. unsigned int CarlaEngine::getCurrentPluginCount() const noexcept
  434. {
  435. return pData->curPluginCount;
  436. }
  437. unsigned int CarlaEngine::getMaxPluginNumber() const noexcept
  438. {
  439. return pData->maxPluginNumber;
  440. }
  441. // -----------------------------------------------------------------------
  442. // Virtual, per-engine type calls
  443. bool CarlaEngine::init(const char* const clientName)
  444. {
  445. CARLA_SAFE_ASSERT_RETURN_ERR(pData->name.isEmpty(), "Invalid engine internal data (err #1)");
  446. CARLA_SAFE_ASSERT_RETURN_ERR(pData->oscData == nullptr, "Invalid engine internal data (err #2)");
  447. CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins == nullptr, "Invalid engine internal data (err #3)");
  448. CARLA_SAFE_ASSERT_RETURN_ERR(pData->bufEvents.in == nullptr, "Invalid engine internal data (err #4)");
  449. CARLA_SAFE_ASSERT_RETURN_ERR(pData->bufEvents.out == nullptr, "Invalid engine internal data (err #5)");
  450. CARLA_SAFE_ASSERT_RETURN_ERR(clientName != nullptr && clientName[0] != '\0', "Invalid client name");
  451. carla_debug("CarlaEngine::init(\"%s\")", clientName);
  452. CARLA_ENGINE_THREAD_SAFE_SECTION;
  453. pData->aboutToClose = false;
  454. pData->curPluginCount = 0;
  455. pData->maxPluginNumber = 0;
  456. pData->nextPluginId = 0;
  457. switch (pData->options.processMode)
  458. {
  459. case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
  460. case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
  461. pData->maxPluginNumber = MAX_DEFAULT_PLUGINS;
  462. break;
  463. case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  464. pData->maxPluginNumber = MAX_RACK_PLUGINS;
  465. pData->bufEvents.in = new EngineEvent[kMaxEngineEventInternalCount];
  466. pData->bufEvents.out = new EngineEvent[kMaxEngineEventInternalCount];
  467. break;
  468. case ENGINE_PROCESS_MODE_PATCHBAY:
  469. pData->maxPluginNumber = MAX_PATCHBAY_PLUGINS;
  470. break;
  471. case ENGINE_PROCESS_MODE_BRIDGE:
  472. pData->maxPluginNumber = 1;
  473. pData->bufEvents.in = new EngineEvent[kMaxEngineEventInternalCount];
  474. pData->bufEvents.out = new EngineEvent[kMaxEngineEventInternalCount];
  475. break;
  476. }
  477. CARLA_SAFE_ASSERT_RETURN_ERR(pData->maxPluginNumber != 0, "Invalid engine process mode");
  478. pData->nextPluginId = pData->maxPluginNumber;
  479. pData->name = clientName;
  480. pData->name.toBasic();
  481. pData->timeInfo.clear();
  482. pData->plugins = new EnginePluginData[pData->maxPluginNumber];
  483. for (uint i=0; i < pData->maxPluginNumber; ++i)
  484. pData->plugins[i].clear();
  485. pData->osc.init(clientName);
  486. #ifndef BUILD_BRIDGE
  487. pData->oscData = pData->osc.getControlData();
  488. #endif
  489. pData->nextAction.ready();
  490. pData->thread.start();
  491. callback(ENGINE_CALLBACK_ENGINE_STARTED, 0, 0, 0, 0.0f, getCurrentDriverName());
  492. return true;
  493. }
  494. bool CarlaEngine::close()
  495. {
  496. CARLA_SAFE_ASSERT_RETURN_ERR(pData->name.isNotEmpty(), "Invalid engine internal data (err #6)");
  497. CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data (err #7)");
  498. CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextPluginId == pData->maxPluginNumber, "Invalid engine internal data (err #8)");
  499. CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #9)");
  500. carla_debug("CarlaEngine::close()");
  501. CARLA_ENGINE_THREAD_SAFE_SECTION;
  502. pData->aboutToClose = true;
  503. if (pData->curPluginCount != 0)
  504. removeAllPlugins();
  505. pData->thread.stop(500);
  506. pData->nextAction.ready();
  507. #ifndef BUILD_BRIDGE
  508. if (pData->osc.isControlRegistered())
  509. oscSend_control_exit();
  510. #endif
  511. pData->osc.close();
  512. pData->oscData = nullptr;
  513. pData->curPluginCount = 0;
  514. pData->maxPluginNumber = 0;
  515. pData->nextPluginId = 0;
  516. if (pData->plugins != nullptr)
  517. {
  518. delete[] pData->plugins;
  519. pData->plugins = nullptr;
  520. }
  521. if (pData->bufEvents.in != nullptr)
  522. {
  523. delete[] pData->bufEvents.in;
  524. pData->bufEvents.in = nullptr;
  525. }
  526. if (pData->bufEvents.out != nullptr)
  527. {
  528. delete[] pData->bufEvents.out;
  529. pData->bufEvents.out = nullptr;
  530. }
  531. pData->name.clear();
  532. callback(ENGINE_CALLBACK_ENGINE_STOPPED, 0, 0, 0, 0.0f, nullptr);
  533. return true;
  534. }
  535. void CarlaEngine::idle()
  536. {
  537. CARLA_ASSERT(pData->nextAction.opcode == kEnginePostActionNull); // TESTING, remove later
  538. CARLA_ASSERT(pData->nextPluginId == pData->maxPluginNumber); // TESTING, remove later
  539. CARLA_ASSERT(pData->plugins != nullptr); // this one too maybe
  540. CARLA_ENGINE_THREAD_SAFE_SECTION;
  541. for (unsigned int i=0; i < pData->curPluginCount; ++i)
  542. {
  543. CarlaPlugin* const plugin(pData->plugins[i].plugin);
  544. if (plugin != nullptr && plugin->isEnabled())
  545. plugin->idle();
  546. }
  547. }
  548. CarlaEngineClient* CarlaEngine::addClient(CarlaPlugin* const)
  549. {
  550. return new CarlaEngineClient(*this);
  551. }
  552. // -----------------------------------------------------------------------
  553. // Plugin management
  554. bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const void* const extra)
  555. {
  556. CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data (err #10)");
  557. CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextPluginId <= pData->maxPluginNumber, "Invalid engine internal data (err #11)");
  558. CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #12)");
  559. CARLA_SAFE_ASSERT_RETURN_ERR(btype != BINARY_NONE, "Invalid plugin params (err #1)");
  560. CARLA_SAFE_ASSERT_RETURN_ERR(ptype != PLUGIN_NONE, "Invalid plugin params (err #2)");
  561. CARLA_SAFE_ASSERT_RETURN_ERR((filename != nullptr && filename[0] != '\0') || (label != nullptr && label[0] != '\0'), "Invalid plugin params (err #3)");
  562. carla_debug("CarlaEngine::addPlugin(%i:%s, %i:%s, \"%s\", \"%s\", \"%s\", " P_INT64 ", %p)", btype, BinaryType2Str(btype), ptype, PluginType2Str(ptype), filename, name, label, uniqueId, extra);
  563. CARLA_ENGINE_THREAD_SAFE_SECTION;
  564. unsigned int id;
  565. CarlaPlugin* oldPlugin = nullptr;
  566. if (pData->nextPluginId < pData->curPluginCount)
  567. {
  568. id = pData->nextPluginId;
  569. pData->nextPluginId = pData->maxPluginNumber;
  570. oldPlugin = pData->plugins[id].plugin;
  571. CARLA_SAFE_ASSERT_RETURN_ERR(oldPlugin != nullptr, "Invalid replace plugin Id");
  572. }
  573. else
  574. {
  575. id = pData->curPluginCount;
  576. if (id == pData->maxPluginNumber)
  577. {
  578. setLastError("Maximum number of plugins reached");
  579. return false;
  580. }
  581. CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins[id].plugin == nullptr, "Invalid engine internal data (err #13)");
  582. }
  583. CarlaPlugin::Initializer initializer = {
  584. this,
  585. id,
  586. filename,
  587. name,
  588. label,
  589. uniqueId
  590. };
  591. CarlaPlugin* plugin = nullptr;
  592. #ifndef BUILD_BRIDGE
  593. CarlaString bridgeBinary(pData->options.binaryDir);
  594. if (bridgeBinary.isNotEmpty())
  595. {
  596. # ifdef CARLA_OS_LINUX
  597. // test for local build
  598. if (bridgeBinary.endsWith("/source/backend/"))
  599. bridgeBinary += "../bridges/";
  600. # endif
  601. # ifndef CARLA_OS_WIN
  602. if (btype == BINARY_NATIVE)
  603. {
  604. bridgeBinary += "carla-bridge-native";
  605. }
  606. else
  607. # endif
  608. {
  609. switch (btype)
  610. {
  611. case BINARY_POSIX32:
  612. bridgeBinary += "carla-bridge-posix32";
  613. break;
  614. case BINARY_POSIX64:
  615. bridgeBinary += "carla-bridge-posix64";
  616. break;
  617. case BINARY_WIN32:
  618. bridgeBinary += "carla-bridge-win32.exe";
  619. break;
  620. case BINARY_WIN64:
  621. bridgeBinary += "carla-bridge-win64.exe";
  622. break;
  623. default:
  624. bridgeBinary.clear();
  625. break;
  626. }
  627. }
  628. QFile file(bridgeBinary.buffer());
  629. if (! file.exists())
  630. bridgeBinary.clear();
  631. }
  632. if (ptype != PLUGIN_INTERNAL && ptype != PLUGIN_JACK && (btype != BINARY_NATIVE || (pData->options.preferPluginBridges && bridgeBinary.isNotEmpty())))
  633. {
  634. if (bridgeBinary.isNotEmpty())
  635. {
  636. plugin = CarlaPlugin::newBridge(initializer, btype, ptype, bridgeBinary);
  637. }
  638. # ifdef CARLA_OS_LINUX
  639. else if (btype == BINARY_WIN32)
  640. {
  641. // fallback to dssi-vst
  642. QFileInfo fileInfo(filename);
  643. CarlaString label2(fileInfo.fileName().toUtf8().constData());
  644. label2.replace(' ', '*');
  645. CarlaPlugin::Initializer init2 = {
  646. this,
  647. id,
  648. "/usr/lib/dssi/dssi-vst.so",
  649. name,
  650. label2,
  651. uniqueId
  652. };
  653. char* const oldVstPath(getenv("VST_PATH"));
  654. carla_setenv("VST_PATH", fileInfo.absoluteDir().absolutePath().toUtf8().constData());
  655. plugin = CarlaPlugin::newDSSI(init2);
  656. if (oldVstPath != nullptr)
  657. carla_setenv("VST_PATH", oldVstPath);
  658. }
  659. # endif
  660. else
  661. {
  662. setLastError("This Carla build cannot handle this binary");
  663. return false;
  664. }
  665. }
  666. else
  667. #endif // ! BUILD_BRIDGE
  668. {
  669. bool use16Outs;
  670. setLastError("Invalid or unsupported plugin type");
  671. switch (ptype)
  672. {
  673. case PLUGIN_NONE:
  674. break;
  675. case PLUGIN_INTERNAL:
  676. if (std::strcmp(label, "Csound") == 0)
  677. {
  678. plugin = CarlaPlugin::newCsound(initializer);
  679. }
  680. else if (std::strcmp(label, "FluidSynth") == 0)
  681. {
  682. use16Outs = (extra != nullptr && std::strcmp((const char*)extra, "true") == 0);
  683. plugin = CarlaPlugin::newFluidSynth(initializer, use16Outs);
  684. }
  685. else if (std::strcmp(label, "LinuxSampler (GIG)") == 0)
  686. {
  687. use16Outs = (extra != nullptr && std::strcmp((const char*)extra, "true") == 0);
  688. plugin = CarlaPlugin::newLinuxSampler(initializer, "GIG", use16Outs);
  689. }
  690. else if (std::strcmp(label, "LinuxSampler (SF2)") == 0)
  691. {
  692. use16Outs = (extra != nullptr && std::strcmp((const char*)extra, "true") == 0);
  693. plugin = CarlaPlugin::newLinuxSampler(initializer, "SF2", use16Outs);
  694. }
  695. else if (std::strcmp(label, "LinuxSampler (SFZ)") == 0)
  696. {
  697. use16Outs = (extra != nullptr && std::strcmp((const char*)extra, "true") == 0);
  698. plugin = CarlaPlugin::newLinuxSampler(initializer, "SFZ", use16Outs);
  699. }
  700. else
  701. {
  702. plugin = CarlaPlugin::newNative(initializer);
  703. }
  704. break;
  705. case PLUGIN_LADSPA:
  706. plugin = CarlaPlugin::newLADSPA(initializer, (const LADSPA_RDF_Descriptor*)extra);
  707. break;
  708. case PLUGIN_DSSI:
  709. plugin = CarlaPlugin::newDSSI(initializer);
  710. break;
  711. case PLUGIN_LV2:
  712. plugin = CarlaPlugin::newLV2(initializer);
  713. break;
  714. case PLUGIN_VST:
  715. plugin = CarlaPlugin::newVST(initializer);
  716. break;
  717. case PLUGIN_VST3:
  718. plugin = CarlaPlugin::newVST3(initializer);
  719. break;
  720. case PLUGIN_AU:
  721. plugin = CarlaPlugin::newAU(initializer);
  722. break;
  723. case PLUGIN_JACK:
  724. plugin = CarlaPlugin::newJACK(initializer);
  725. break;
  726. case PLUGIN_REWIRE:
  727. plugin = CarlaPlugin::newReWire(initializer);
  728. break;
  729. case PLUGIN_FILE_CSD:
  730. plugin = CarlaPlugin::newFileCSD(initializer);
  731. break;
  732. case PLUGIN_FILE_GIG:
  733. use16Outs = (extra != nullptr && std::strcmp((const char*)extra, "true") == 0);
  734. plugin = CarlaPlugin::newFileGIG(initializer, use16Outs);
  735. break;
  736. case PLUGIN_FILE_SF2:
  737. use16Outs = (extra != nullptr && std::strcmp((const char*)extra, "true") == 0);
  738. plugin = CarlaPlugin::newFileSF2(initializer, use16Outs);
  739. break;
  740. case PLUGIN_FILE_SFZ:
  741. plugin = CarlaPlugin::newFileSFZ(initializer);
  742. break;
  743. }
  744. }
  745. if (plugin == nullptr)
  746. {
  747. pData->plugins[id].plugin = oldPlugin;
  748. return false;
  749. }
  750. plugin->registerToOscClient();
  751. EnginePluginData& pluginData(pData->plugins[id]);
  752. pluginData.plugin = plugin;
  753. pluginData.insPeak[0] = 0.0f;
  754. pluginData.insPeak[1] = 0.0f;
  755. pluginData.outsPeak[0] = 0.0f;
  756. pluginData.outsPeak[1] = 0.0f;
  757. if (oldPlugin != nullptr)
  758. {
  759. delete oldPlugin;
  760. callback(ENGINE_CALLBACK_RELOAD_ALL, id, 0, 0, 0.0f, plugin->getName());
  761. }
  762. else
  763. {
  764. ++pData->curPluginCount;
  765. callback(ENGINE_CALLBACK_PLUGIN_ADDED, id, 0, 0, 0.0f, plugin->getName());
  766. if (pData->curPluginCount == 1 && pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
  767. callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED, 0, PATCHBAY_ICON_CARLA, 0, 0.0f, nullptr);
  768. }
  769. return true;
  770. }
  771. bool CarlaEngine::addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const void* const extra)
  772. {
  773. return addPlugin(BINARY_NATIVE, ptype, filename, name, label, uniqueId, extra);
  774. }
  775. bool CarlaEngine::removePlugin(const unsigned int id)
  776. {
  777. CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data (err #14)");
  778. CARLA_SAFE_ASSERT_RETURN_ERR(pData->curPluginCount != 0, "Invalid engine internal data (err #15)");
  779. CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #16)");
  780. CARLA_SAFE_ASSERT_RETURN_ERR(id < pData->curPluginCount, "Invalid plugin Id (err #1)");
  781. carla_debug("CarlaEngine::removePlugin(%i)", id);
  782. CARLA_ENGINE_THREAD_SAFE_SECTION;
  783. CarlaPlugin* const plugin(pData->plugins[id].plugin);
  784. CARLA_SAFE_ASSERT_RETURN_ERR(plugin != nullptr, "Could not find plugin to remove");
  785. CARLA_SAFE_ASSERT_RETURN_ERR(plugin->getId() == id, "Invalid engine internal data (err #17)");
  786. pData->thread.stop(500);
  787. const bool lockWait(isRunning() && pData->options.processMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS);
  788. const CarlaEngineProtectedData::ScopedActionLock sal(pData, kEnginePostActionRemovePlugin, id, 0, lockWait);
  789. #ifndef BUILD_BRIDGE
  790. if (isOscControlRegistered())
  791. oscSend_control_remove_plugin(id);
  792. #endif
  793. delete plugin;
  794. if (isRunning() && ! pData->aboutToClose)
  795. pData->thread.start();
  796. callback(ENGINE_CALLBACK_PLUGIN_REMOVED, id, 0, 0, 0.0f, nullptr);
  797. return true;
  798. }
  799. bool CarlaEngine::removeAllPlugins()
  800. {
  801. CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data (err #18)");
  802. CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextPluginId == pData->maxPluginNumber, "Invalid engine internal data (err #19)");
  803. CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #20)");
  804. carla_debug("CarlaEngine::removeAllPlugins()");
  805. CARLA_ENGINE_THREAD_SAFE_SECTION;
  806. if (pData->curPluginCount == 0)
  807. return true;
  808. pData->thread.stop(500);
  809. const bool lockWait(isRunning());
  810. const CarlaEngineProtectedData::ScopedActionLock sal(pData, kEnginePostActionZeroCount, 0, 0, lockWait);
  811. callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr);
  812. for (unsigned int i=0; i < pData->maxPluginNumber; ++i)
  813. {
  814. EnginePluginData& pluginData(pData->plugins[i]);
  815. if (pluginData.plugin != nullptr)
  816. {
  817. delete pluginData.plugin;
  818. pluginData.plugin = nullptr;
  819. }
  820. pluginData.insPeak[0] = 0.0f;
  821. pluginData.insPeak[1] = 0.0f;
  822. pluginData.outsPeak[0] = 0.0f;
  823. pluginData.outsPeak[1] = 0.0f;
  824. callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr);
  825. }
  826. if (isRunning() && ! pData->aboutToClose)
  827. pData->thread.start();
  828. return true;
  829. }
  830. const char* CarlaEngine::renamePlugin(const unsigned int id, const char* const newName)
  831. {
  832. CARLA_SAFE_ASSERT_RETURN_ERRN(pData->plugins != nullptr, "Invalid engine internal data (err #21)");
  833. CARLA_SAFE_ASSERT_RETURN_ERRN(pData->curPluginCount != 0, "Invalid engine internal data (err #22)");
  834. CARLA_SAFE_ASSERT_RETURN_ERRN(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #23)");
  835. CARLA_SAFE_ASSERT_RETURN_ERRN(id < pData->curPluginCount, "Invalid plugin Id (err #2)");
  836. CARLA_SAFE_ASSERT_RETURN_ERRN(newName != nullptr && newName[0] != '\0', "Invalid plugin name");
  837. carla_debug("CarlaEngine::renamePlugin(%i, \"%s\")", id, newName);
  838. CARLA_ENGINE_THREAD_SAFE_SECTION;
  839. CarlaPlugin* const plugin(pData->plugins[id].plugin);
  840. CARLA_SAFE_ASSERT_RETURN_ERRN(plugin != nullptr, "Could not find plugin to rename");
  841. CARLA_SAFE_ASSERT_RETURN_ERRN(plugin->getId() == id, "Invalid engine internal data (err #24)");
  842. if (const char* const name = getUniquePluginName(newName))
  843. {
  844. plugin->setName(name);
  845. return name;
  846. }
  847. setLastError("Unable to get new unique plugin name");
  848. return nullptr;
  849. }
  850. bool CarlaEngine::clonePlugin(const unsigned int id)
  851. {
  852. CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data (err #25)");
  853. CARLA_SAFE_ASSERT_RETURN_ERR(pData->curPluginCount != 0, "Invalid engine internal data (err #26)");
  854. CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #27)");
  855. CARLA_SAFE_ASSERT_RETURN_ERR(id < pData->curPluginCount, "Invalid plugin Id (err #3)");
  856. carla_debug("CarlaEngine::clonePlugin(%i)", id);
  857. CARLA_ENGINE_THREAD_SAFE_SECTION;
  858. CarlaPlugin* const plugin(pData->plugins[id].plugin);
  859. CARLA_SAFE_ASSERT_RETURN_ERR(plugin != nullptr, "Could not find plugin to clone");
  860. CARLA_SAFE_ASSERT_RETURN_ERR(plugin->getId() == id, "Invalid engine internal data (err #28)");
  861. char label[STR_MAX+1];
  862. carla_zeroChar(label, STR_MAX+1);
  863. plugin->getLabel(label);
  864. const unsigned int pluginCountBefore(pData->curPluginCount);
  865. if (! addPlugin(plugin->getBinaryType(), plugin->getType(), plugin->getFilename(), plugin->getName(), label, plugin->getUniqueId(), plugin->getExtraStuff()))
  866. return false;
  867. CARLA_ASSERT(pluginCountBefore+1 == pData->curPluginCount);
  868. if (CarlaPlugin* const newPlugin = pData->plugins[pluginCountBefore].plugin)
  869. newPlugin->loadSaveState(plugin->getSaveState());
  870. return true;
  871. }
  872. bool CarlaEngine::replacePlugin(const unsigned int id)
  873. {
  874. CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data (err #29)");
  875. CARLA_SAFE_ASSERT_RETURN_ERR(pData->curPluginCount != 0, "Invalid engine internal data (err #30)");
  876. CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #31)");
  877. carla_debug("CarlaEngine::replacePlugin(%i)", id);
  878. CARLA_ENGINE_THREAD_SAFE_SECTION;
  879. // might use this to reset
  880. if (id == pData->curPluginCount || id == pData->maxPluginNumber)
  881. {
  882. pData->nextPluginId = pData->maxPluginNumber;
  883. return true;
  884. }
  885. CARLA_SAFE_ASSERT_RETURN_ERR(id < pData->curPluginCount, "Invalid plugin Id (err #4)");
  886. CarlaPlugin* const plugin(pData->plugins[id].plugin);
  887. CARLA_SAFE_ASSERT_RETURN_ERR(plugin != nullptr, "Could not find plugin to replace");
  888. CARLA_SAFE_ASSERT_RETURN_ERR(plugin->getId() == id, "Invalid engine internal data (err #32)");
  889. pData->nextPluginId = id;
  890. return true;
  891. }
  892. bool CarlaEngine::switchPlugins(const unsigned int idA, const unsigned int idB)
  893. {
  894. CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data (err #33)");
  895. CARLA_SAFE_ASSERT_RETURN_ERR(pData->curPluginCount >= 2, "Invalid engine internal data (err #34)");
  896. CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #35)");
  897. CARLA_SAFE_ASSERT_RETURN_ERR(idA != idB, "Invalid operation, cannot switch plugin with itself");
  898. CARLA_SAFE_ASSERT_RETURN_ERR(idA < pData->curPluginCount, "Invalid plugin Id (err #5)");
  899. CARLA_SAFE_ASSERT_RETURN_ERR(idB < pData->curPluginCount, "Invalid plugin Id (err #6)");
  900. carla_debug("CarlaEngine::switchPlugins(%i)", idA, idB);
  901. CARLA_ENGINE_THREAD_SAFE_SECTION;
  902. CarlaPlugin* const pluginA(pData->plugins[idA].plugin);
  903. CarlaPlugin* const pluginB(pData->plugins[idB].plugin);
  904. CARLA_SAFE_ASSERT_RETURN_ERR(pluginA != nullptr, "Could not find plugin to switch (err #1)");
  905. CARLA_SAFE_ASSERT_RETURN_ERR(pluginA != nullptr, "Could not find plugin to switch (err #2)");
  906. CARLA_SAFE_ASSERT_RETURN_ERR(pluginA->getId() == idA, "Invalid engine internal data (err #36)");
  907. CARLA_SAFE_ASSERT_RETURN_ERR(pluginB->getId() == idB, "Invalid engine internal data (err #37)");
  908. pData->thread.stop(500);
  909. const bool lockWait(isRunning() && pData->options.processMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS);
  910. const CarlaEngineProtectedData::ScopedActionLock sal(pData, kEnginePostActionSwitchPlugins, idA, idB, lockWait);
  911. #ifndef BUILD_BRIDGE // TODO
  912. //if (isOscControlRegistered())
  913. // oscSend_control_switch_plugins(idA, idB);
  914. #endif
  915. if (isRunning() && ! pData->aboutToClose)
  916. pData->thread.start();
  917. return true;
  918. }
  919. CarlaPlugin* CarlaEngine::getPlugin(const unsigned int id) const
  920. {
  921. CARLA_SAFE_ASSERT_RETURN_ERRN(pData->plugins != nullptr, "Invalid engine internal data (err #38)");
  922. CARLA_SAFE_ASSERT_RETURN_ERRN(pData->curPluginCount != 0, "Invalid engine internal data (err #39)");
  923. CARLA_SAFE_ASSERT_RETURN_ERRN(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #40)");
  924. CARLA_SAFE_ASSERT_RETURN_ERRN(id < pData->curPluginCount, "Invalid plugin Id (err #7)");
  925. carla_debug("CarlaEngine::getPlugin(%i) [count:%i]", id, pData->curPluginCount);
  926. return pData->plugins[id].plugin;
  927. }
  928. CarlaPlugin* CarlaEngine::getPluginUnchecked(const unsigned int id) const noexcept
  929. {
  930. return pData->plugins[id].plugin;
  931. }
  932. const char* CarlaEngine::getUniquePluginName(const char* const name) const
  933. {
  934. CARLA_SAFE_ASSERT_RETURN(pData->nextAction.opcode == kEnginePostActionNull, nullptr);
  935. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', nullptr);
  936. carla_debug("CarlaEngine::getUniquePluginName(\"%s\")", name);
  937. CarlaString sname;
  938. sname = name;
  939. if (sname.isEmpty())
  940. {
  941. sname = "(No name)";
  942. return sname.dup();
  943. }
  944. const size_t maxNameSize(carla_min<uint>(getMaxClientNameSize(), 0xff, 6) - 6); // 6 = strlen(" (10)") + 1
  945. if (maxNameSize == 0 || ! isRunning())
  946. return sname.dup();
  947. sname.truncate(maxNameSize);
  948. sname.replace(':', '.'); // ':' is used in JACK1 to split client/port names
  949. for (unsigned short i=0; i < pData->curPluginCount; ++i)
  950. {
  951. CARLA_SAFE_ASSERT_BREAK(pData->plugins[i].plugin != nullptr);
  952. // Check if unique name doesn't exist
  953. if (const char* const pluginName = pData->plugins[i].plugin->getName())
  954. {
  955. if (sname != pluginName)
  956. continue;
  957. }
  958. // Check if string has already been modified
  959. {
  960. const size_t len(sname.length());
  961. // 1 digit, ex: " (2)"
  962. if (sname[len-4] == ' ' && sname[len-3] == '(' && sname.isDigit(len-2) && sname[len-1] == ')')
  963. {
  964. int number = sname[len-2] - '0';
  965. if (number == 9)
  966. {
  967. // next number is 10, 2 digits
  968. sname.truncate(len-4);
  969. sname += " (10)";
  970. //sname.replace(" (9)", " (10)");
  971. }
  972. else
  973. sname[len-2] = char('0' + number + 1);
  974. continue;
  975. }
  976. // 2 digits, ex: " (11)"
  977. if (sname[len-5] == ' ' && sname[len-4] == '(' && sname.isDigit(len-3) && sname.isDigit(len-2) && sname[len-1] == ')')
  978. {
  979. char n2 = sname[len-2];
  980. char n3 = sname[len-3];
  981. if (n2 == '9')
  982. {
  983. n2 = '0';
  984. n3 = static_cast<char>(n3 + 1);
  985. }
  986. else
  987. n2 = static_cast<char>(n2 + 1);
  988. sname[len-2] = n2;
  989. sname[len-3] = n3;
  990. continue;
  991. }
  992. }
  993. // Modify string if not
  994. sname += " (2)";
  995. }
  996. return sname.dup();
  997. }
  998. // -----------------------------------------------------------------------
  999. // Project management
  1000. bool CarlaEngine::loadFile(const char* const filename)
  1001. {
  1002. CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename (err #1)");
  1003. carla_debug("CarlaEngine::loadFile(\"%s\")", filename);
  1004. CARLA_ENGINE_THREAD_SAFE_SECTION;
  1005. QFileInfo fileInfo(filename);
  1006. if (! fileInfo.exists())
  1007. {
  1008. setLastError("File does not exist");
  1009. return false;
  1010. }
  1011. if (! fileInfo.isFile())
  1012. {
  1013. setLastError("Not a file");
  1014. return false;
  1015. }
  1016. if (! fileInfo.isReadable())
  1017. {
  1018. setLastError("File is not readable");
  1019. return false;
  1020. }
  1021. CarlaString baseName(fileInfo.baseName().toUtf8().constData());
  1022. CarlaString extension(fileInfo.suffix().toLower().toUtf8().constData());
  1023. extension.toLower();
  1024. // -------------------------------------------------------------------
  1025. if (extension == "carxp" || extension == "carxs")
  1026. return loadProject(filename);
  1027. // -------------------------------------------------------------------
  1028. if (extension == "csd")
  1029. return addPlugin(PLUGIN_FILE_CSD, filename, baseName, baseName, 0, nullptr);
  1030. if (extension == "gig")
  1031. return addPlugin(PLUGIN_FILE_GIG, filename, baseName, baseName, 0, nullptr);
  1032. if (extension == "sf2")
  1033. return addPlugin(PLUGIN_FILE_SF2, filename, baseName, baseName, 0, nullptr);
  1034. if (extension == "sfz")
  1035. return addPlugin(PLUGIN_FILE_SFZ, filename, baseName, baseName, 0, nullptr);
  1036. // -------------------------------------------------------------------
  1037. if (extension == "aiff" || extension == "flac" || extension == "oga" || extension == "ogg" || extension == "w64" || extension == "wav")
  1038. {
  1039. #ifdef WANT_AUDIOFILE
  1040. if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "audiofile", 0, nullptr))
  1041. {
  1042. if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1))
  1043. plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, "file", filename, true);
  1044. return true;
  1045. }
  1046. return false;
  1047. #else
  1048. setLastError("This Carla build does not have Audio file support");
  1049. return false;
  1050. #endif
  1051. }
  1052. if (extension == "3g2" || extension == "3gp" || extension == "aac" || extension == "ac3" || extension == "amr" || extension == "ape" ||
  1053. extension == "mp2" || extension == "mp3" || extension == "mpc" || extension == "wma")
  1054. {
  1055. #ifdef WANT_AUDIOFILE
  1056. # ifdef HAVE_FFMPEG
  1057. if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "audiofile", 0, nullptr))
  1058. {
  1059. if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1))
  1060. plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, "file", filename, true);
  1061. return true;
  1062. }
  1063. return false;
  1064. # else
  1065. setLastError("This Carla build has Audio file support, but not libav/ffmpeg");
  1066. return false;
  1067. # endif
  1068. #else
  1069. setLastError("This Carla build does not have Audio file support");
  1070. return false;
  1071. #endif
  1072. }
  1073. // -------------------------------------------------------------------
  1074. if (extension == "mid" || extension == "midi")
  1075. {
  1076. #ifdef WANT_MIDIFILE
  1077. if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "midifile", 0, nullptr))
  1078. {
  1079. if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1))
  1080. plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, "file", filename, true);
  1081. return true;
  1082. }
  1083. return false;
  1084. #else
  1085. setLastError("This Carla build does not have MIDI file support");
  1086. return false;
  1087. #endif
  1088. }
  1089. // -------------------------------------------------------------------
  1090. // ZynAddSubFX
  1091. if (extension == "xmz" || extension == "xiz")
  1092. {
  1093. #ifdef WANT_ZYNADDSUBFX
  1094. if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "zynaddsubfx", 0, nullptr))
  1095. {
  1096. if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1))
  1097. plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, (extension == "xmz") ? "CarlaAlternateFile1" : "CarlaAlternateFile2", filename, true);
  1098. return true;
  1099. }
  1100. return false;
  1101. #else
  1102. setLastError("This Carla build does not have ZynAddSubFX support");
  1103. return false;
  1104. #endif
  1105. }
  1106. // -------------------------------------------------------------------
  1107. setLastError("Unknown file extension");
  1108. return false;
  1109. }
  1110. bool CarlaEngine::loadProject(const char* const filename)
  1111. {
  1112. CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename (err #2)");
  1113. carla_debug("CarlaEngine::loadProject(\"%s\")", filename);
  1114. CARLA_ENGINE_THREAD_SAFE_SECTION;
  1115. QFile file(filename);
  1116. if (! file.open(QIODevice::ReadOnly | QIODevice::Text))
  1117. return false;
  1118. QDomDocument xml;
  1119. xml.setContent(file.readAll());
  1120. file.close();
  1121. QDomNode xmlNode(xml.documentElement());
  1122. const bool isPreset(xmlNode.toElement().tagName().compare("carla-preset", Qt::CaseInsensitive) == 0);
  1123. if (xmlNode.toElement().tagName().compare("carla-project", Qt::CaseInsensitive) != 0 && ! isPreset)
  1124. {
  1125. setLastError("Not a valid Carla project or preset file");
  1126. return false;
  1127. }
  1128. // handle plugins first
  1129. for (QDomNode node = xmlNode.firstChild(); ! node.isNull(); node = node.nextSibling())
  1130. {
  1131. if (isPreset || node.toElement().tagName().compare("plugin", Qt::CaseInsensitive) == 0)
  1132. {
  1133. SaveState saveState;
  1134. fillSaveStateFromXmlNode(saveState, isPreset ? xmlNode : node);
  1135. callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr);
  1136. CARLA_SAFE_ASSERT_CONTINUE(saveState.type != nullptr);
  1137. const void* extraStuff = nullptr;
  1138. // check if using GIG, SF2 or SFZ 16outs
  1139. static const char kUse16OutsSuffix[] = " (16 outs)";
  1140. const PluginType ptype(getPluginTypeFromString(saveState.type));
  1141. if (CarlaString(saveState.label).endsWith(kUse16OutsSuffix))
  1142. {
  1143. if (ptype == PLUGIN_FILE_GIG || ptype == PLUGIN_FILE_SF2)
  1144. extraStuff = "true";
  1145. }
  1146. // TODO - proper find&load plugins
  1147. if (addPlugin(ptype, saveState.binary, saveState.name, saveState.label, saveState.uniqueId, extraStuff))
  1148. {
  1149. if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1))
  1150. plugin->loadSaveState(saveState);
  1151. }
  1152. }
  1153. if (isPreset)
  1154. return true;
  1155. }
  1156. #ifndef BUILD_BRIDGE
  1157. callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr);
  1158. // now connections
  1159. for (QDomNode node = xmlNode.firstChild(); ! node.isNull(); node = node.nextSibling())
  1160. {
  1161. if (node.toElement().tagName().compare("patchbay", Qt::CaseInsensitive) == 0)
  1162. {
  1163. CarlaString sourcePort, targetPort;
  1164. for (QDomNode patchNode = node.firstChild(); ! patchNode.isNull(); patchNode = patchNode.nextSibling())
  1165. {
  1166. sourcePort.clear();
  1167. targetPort.clear();
  1168. if (patchNode.toElement().tagName().compare("connection", Qt::CaseInsensitive) != 0)
  1169. continue;
  1170. for (QDomNode connNode = patchNode.firstChild(); ! connNode.isNull(); connNode = connNode.nextSibling())
  1171. {
  1172. const QString tag(connNode.toElement().tagName());
  1173. const QString text(connNode.toElement().text().trimmed());
  1174. if (tag.compare("source", Qt::CaseInsensitive) == 0)
  1175. sourcePort = text.toUtf8().constData();
  1176. else if (tag.compare("target", Qt::CaseInsensitive) == 0)
  1177. targetPort = text.toUtf8().constData();
  1178. }
  1179. if (sourcePort.isNotEmpty() && targetPort.isNotEmpty())
  1180. restorePatchbayConnection(sourcePort, targetPort);
  1181. }
  1182. break;
  1183. }
  1184. }
  1185. #endif
  1186. return true;
  1187. }
  1188. bool CarlaEngine::saveProject(const char* const filename)
  1189. {
  1190. CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename (err #3)");
  1191. carla_debug("CarlaEngine::saveProject(\"%s\")", filename);
  1192. CARLA_ENGINE_THREAD_SAFE_SECTION;
  1193. QFile file(filename);
  1194. if (! file.open(QIODevice::WriteOnly | QIODevice::Text))
  1195. return false;
  1196. QTextStream out(&file);
  1197. out << "<?xml version='1.0' encoding='UTF-8'?>\n";
  1198. out << "<!DOCTYPE CARLA-PROJECT>\n";
  1199. out << "<CARLA-PROJECT VERSION='2.0'>\n";
  1200. bool firstPlugin = true;
  1201. char strBuf[STR_MAX+1];
  1202. for (unsigned int i=0; i < pData->curPluginCount; ++i)
  1203. {
  1204. CarlaPlugin* const plugin(pData->plugins[i].plugin);
  1205. if (plugin != nullptr && plugin->isEnabled())
  1206. {
  1207. if (! firstPlugin)
  1208. out << "\n";
  1209. strBuf[0] = '\0';
  1210. plugin->getRealName(strBuf);
  1211. //if (strBuf[0] != '\0')
  1212. // out << QString(" <!-- %1 -->\n").arg(xmlSafeString(strBuf, true));
  1213. QString content;
  1214. fillXmlStringFromSaveState(content, plugin->getSaveState());
  1215. out << " <Plugin>\n";
  1216. out << content;
  1217. out << " </Plugin>\n";
  1218. firstPlugin = false;
  1219. }
  1220. }
  1221. #ifndef BUILD_BRIDGE
  1222. if (const char* const* patchbayConns = getPatchbayConnections())
  1223. {
  1224. if (! firstPlugin)
  1225. out << "\n";
  1226. out << " <Patchbay>\n";
  1227. for (int i=0; patchbayConns[i] != nullptr && patchbayConns[i+1] != nullptr; ++i, ++i )
  1228. {
  1229. const char* const connSource(patchbayConns[i]);
  1230. const char* const connTarget(patchbayConns[i+1]);
  1231. CARLA_SAFE_ASSERT_CONTINUE(connSource != nullptr && connSource[0] != '\0');
  1232. CARLA_SAFE_ASSERT_CONTINUE(connTarget != nullptr && connTarget[0] != '\0');
  1233. out << " <Connection>\n";
  1234. out << " <Source>" << connSource << "</Source>\n";
  1235. out << " <Target>" << connTarget << "</Target>\n";
  1236. out << " </Connection>\n";
  1237. delete[] connSource;
  1238. delete[] connTarget;
  1239. }
  1240. out << " </Patchbay>\n";
  1241. }
  1242. #endif
  1243. out << "</CARLA-PROJECT>\n";
  1244. file.close();
  1245. return true;
  1246. }
  1247. // -----------------------------------------------------------------------
  1248. // Information (base)
  1249. unsigned int CarlaEngine::getHints() const noexcept
  1250. {
  1251. return pData->hints;
  1252. }
  1253. uint32_t CarlaEngine::getBufferSize() const noexcept
  1254. {
  1255. return pData->bufferSize;
  1256. }
  1257. double CarlaEngine::getSampleRate() const noexcept
  1258. {
  1259. return pData->sampleRate;
  1260. }
  1261. const char* CarlaEngine::getName() const noexcept
  1262. {
  1263. return pData->name;
  1264. }
  1265. EngineProcessMode CarlaEngine::getProccessMode() const noexcept
  1266. {
  1267. return pData->options.processMode;
  1268. }
  1269. const EngineOptions& CarlaEngine::getOptions() const noexcept
  1270. {
  1271. return pData->options;
  1272. }
  1273. const EngineTimeInfo& CarlaEngine::getTimeInfo() const noexcept
  1274. {
  1275. return pData->timeInfo;
  1276. }
  1277. // -----------------------------------------------------------------------
  1278. // Information (peaks)
  1279. float CarlaEngine::getInputPeak(const unsigned int pluginId, const bool isLeft) const noexcept
  1280. {
  1281. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount, 0.0f);
  1282. return pData->plugins[pluginId].insPeak[isLeft ? 0 : 1];
  1283. }
  1284. float CarlaEngine::getOutputPeak(const unsigned int pluginId, const bool isLeft) const noexcept
  1285. {
  1286. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount, 0.0f);
  1287. return pData->plugins[pluginId].outsPeak[isLeft ? 0 : 1];
  1288. }
  1289. // -----------------------------------------------------------------------
  1290. // Callback
  1291. void CarlaEngine::callback(const EngineCallbackOpcode action, const unsigned int pluginId, const int value1, const int value2, const float value3, const char* const valueStr) noexcept
  1292. {
  1293. carla_debug("CarlaEngine::callback(%s, %i, %i, %i, %f, \"%s\")", EngineCallbackOpcode2Str(action), pluginId, value1, value2, value3, valueStr);
  1294. if (pData->callback != nullptr)
  1295. {
  1296. try {
  1297. pData->callback(pData->callbackPtr, action, pluginId, value1, value2, value3, valueStr);
  1298. } catch(...) {}
  1299. }
  1300. }
  1301. void CarlaEngine::setCallback(const EngineCallbackFunc func, void* const ptr) noexcept
  1302. {
  1303. carla_debug("CarlaEngine::setCallback(%p, %p)", func, ptr);
  1304. CARLA_ENGINE_THREAD_SAFE_SECTION;
  1305. pData->callback = func;
  1306. pData->callbackPtr = ptr;
  1307. }
  1308. // -----------------------------------------------------------------------
  1309. // File Callback
  1310. const char* CarlaEngine::runFileCallback(const FileCallbackOpcode action, const bool isDir, const char* const title, const char* const filter) noexcept
  1311. {
  1312. CARLA_SAFE_ASSERT_RETURN(title != nullptr && title[0] != '\0', nullptr);
  1313. CARLA_SAFE_ASSERT_RETURN(filter != nullptr, nullptr);
  1314. carla_debug("CarlaEngine::runFileCallback(%i:%s, %s, \"%s\", \"%s\")", action, FileCallbackOpcode2Str(action), bool2str(isDir), title, filter);
  1315. CARLA_ENGINE_THREAD_SAFE_SECTION;
  1316. const char* ret = nullptr;
  1317. if (pData->fileCallback != nullptr)
  1318. {
  1319. try {
  1320. ret = pData->fileCallback(pData->fileCallbackPtr, action, isDir, title, filter);
  1321. } catch(...) {}
  1322. }
  1323. return ret;
  1324. }
  1325. void CarlaEngine::setFileCallback(const FileCallbackFunc func, void* const ptr) noexcept
  1326. {
  1327. CARLA_ENGINE_THREAD_SAFE_SECTION;
  1328. pData->fileCallback = func;
  1329. pData->fileCallbackPtr = ptr;
  1330. }
  1331. #ifndef BUILD_BRIDGE
  1332. // -----------------------------------------------------------------------
  1333. // Patchbay
  1334. bool CarlaEngine::patchbayConnect(const int portA, const int portB)
  1335. {
  1336. CARLA_SAFE_ASSERT_RETURN(pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY, false);
  1337. CARLA_SAFE_ASSERT_RETURN(pData->bufAudio.isReady, false);
  1338. carla_debug("CarlaEngineRtAudio::patchbayConnect(%i, %i)", portA, portB);
  1339. CARLA_ENGINE_THREAD_SAFE_SECTION;
  1340. if (pData->bufAudio.usePatchbay)
  1341. {
  1342. // not implemented yet
  1343. return false;
  1344. }
  1345. EngineRackBuffers* const rack(pData->bufAudio.rack);
  1346. CARLA_SAFE_ASSERT_RETURN_ERR(portA > RACK_PATCHBAY_PORT_MAX, "Invalid output port");
  1347. CARLA_SAFE_ASSERT_RETURN_ERR(portB > RACK_PATCHBAY_PORT_MAX, "Invalid input port");
  1348. // only allow connections between Carla and other ports
  1349. if (portA < 0 && portB < 0)
  1350. {
  1351. setLastError("Invalid connection (1)");
  1352. return false;
  1353. }
  1354. if (portA >= 0 && portB >= 0)
  1355. {
  1356. setLastError("Invalid connection (2)");
  1357. return false;
  1358. }
  1359. const int carlaPort = (portA < 0) ? portA : portB;
  1360. const int targetPort = (carlaPort == portA) ? portB : portA;
  1361. bool makeConnection = false;
  1362. switch (carlaPort)
  1363. {
  1364. case RACK_PATCHBAY_PORT_AUDIO_IN1:
  1365. CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_AUDIO_IN*1000);
  1366. CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_AUDIO_IN*1000+999);
  1367. rack->connectLock.enter();
  1368. rack->connectedIn1.append(targetPort - RACK_PATCHBAY_GROUP_AUDIO_IN*1000);
  1369. rack->connectLock.leave();
  1370. makeConnection = true;
  1371. break;
  1372. case RACK_PATCHBAY_PORT_AUDIO_IN2:
  1373. CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_AUDIO_IN*1000);
  1374. CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_AUDIO_IN*1000+999);
  1375. rack->connectLock.enter();
  1376. rack->connectedIn2.append(targetPort - RACK_PATCHBAY_GROUP_AUDIO_IN*1000);
  1377. rack->connectLock.leave();
  1378. makeConnection = true;
  1379. break;
  1380. case RACK_PATCHBAY_PORT_AUDIO_OUT1:
  1381. CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_AUDIO_OUT*1000);
  1382. CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_AUDIO_OUT*1000+999);
  1383. rack->connectLock.enter();
  1384. rack->connectedOut1.append(targetPort - RACK_PATCHBAY_GROUP_AUDIO_OUT*1000);
  1385. rack->connectLock.leave();
  1386. makeConnection = true;
  1387. break;
  1388. case RACK_PATCHBAY_PORT_AUDIO_OUT2:
  1389. CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_AUDIO_OUT*1000);
  1390. CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_AUDIO_OUT*1000+999);
  1391. rack->connectLock.enter();
  1392. rack->connectedOut2.append(targetPort - RACK_PATCHBAY_GROUP_AUDIO_OUT*1000);
  1393. rack->connectLock.leave();
  1394. makeConnection = true;
  1395. break;
  1396. case RACK_PATCHBAY_PORT_MIDI_IN:
  1397. CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_MIDI_IN*1000);
  1398. CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_MIDI_IN*1000+999);
  1399. makeConnection = connectRackMidiInPort(targetPort - RACK_PATCHBAY_GROUP_MIDI_IN*1000);
  1400. break;
  1401. case RACK_PATCHBAY_PORT_MIDI_OUT:
  1402. CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_MIDI_OUT*1000);
  1403. CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_MIDI_OUT*1000+999);
  1404. makeConnection = connectRackMidiOutPort(targetPort - RACK_PATCHBAY_GROUP_MIDI_OUT*1000);
  1405. break;
  1406. }
  1407. if (! makeConnection)
  1408. {
  1409. setLastError("Invalid connection (3)");
  1410. return false;
  1411. }
  1412. ConnectionToId connectionToId;
  1413. connectionToId.id = rack->lastConnectionId;
  1414. connectionToId.portOut = portA;
  1415. connectionToId.portIn = portB;
  1416. callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, portA, portB, 0.0f, nullptr);
  1417. rack->usedConnections.append(connectionToId);
  1418. rack->lastConnectionId++;
  1419. return true;
  1420. }
  1421. bool CarlaEngine::patchbayDisconnect(const uint connectionId)
  1422. {
  1423. CARLA_SAFE_ASSERT_RETURN(pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY, false);
  1424. CARLA_SAFE_ASSERT_RETURN(pData->bufAudio.isReady, false);
  1425. carla_debug("CarlaEngineRtAudio::patchbayDisconnect(%i)", connectionId);
  1426. CARLA_ENGINE_THREAD_SAFE_SECTION;
  1427. if (pData->bufAudio.usePatchbay)
  1428. {
  1429. // not implemented yet
  1430. return false;
  1431. }
  1432. EngineRackBuffers* const rack(pData->bufAudio.rack);
  1433. CARLA_SAFE_ASSERT_RETURN_ERR(rack->usedConnections.count() > 0, "No connections available");
  1434. for (LinkedList<ConnectionToId>::Itenerator it=rack->usedConnections.begin(); it.valid(); it.next())
  1435. {
  1436. const ConnectionToId& connection(it.getValue());
  1437. if (connection.id == connectionId)
  1438. {
  1439. const int otherPort((connection.portOut >= 0) ? connection.portOut : connection.portIn);
  1440. const int carlaPort((otherPort == connection.portOut) ? connection.portIn : connection.portOut);
  1441. if (otherPort >= RACK_PATCHBAY_GROUP_MIDI_OUT*1000)
  1442. {
  1443. CARLA_SAFE_ASSERT_RETURN(carlaPort == RACK_PATCHBAY_PORT_MIDI_IN, false);
  1444. const int portId(otherPort-RACK_PATCHBAY_GROUP_MIDI_OUT*1000);
  1445. disconnectRackMidiInPort(portId);
  1446. }
  1447. else if (otherPort >= RACK_PATCHBAY_GROUP_MIDI_IN*1000)
  1448. {
  1449. CARLA_SAFE_ASSERT_RETURN(carlaPort == RACK_PATCHBAY_PORT_MIDI_OUT, false);
  1450. const int portId(otherPort-RACK_PATCHBAY_GROUP_MIDI_IN*1000);
  1451. disconnectRackMidiOutPort(portId);
  1452. }
  1453. else if (otherPort >= RACK_PATCHBAY_GROUP_AUDIO_OUT*1000)
  1454. {
  1455. CARLA_SAFE_ASSERT_RETURN(carlaPort == RACK_PATCHBAY_PORT_AUDIO_OUT1 || carlaPort == RACK_PATCHBAY_PORT_AUDIO_OUT2, false);
  1456. const int portId(otherPort-RACK_PATCHBAY_GROUP_AUDIO_OUT*1000);
  1457. rack->connectLock.enter();
  1458. if (carlaPort == RACK_PATCHBAY_PORT_AUDIO_OUT1)
  1459. rack->connectedOut1.removeAll(portId);
  1460. else
  1461. rack->connectedOut2.removeAll(portId);
  1462. rack->connectLock.leave();
  1463. }
  1464. else if (otherPort >= RACK_PATCHBAY_GROUP_AUDIO_IN*1000)
  1465. {
  1466. CARLA_SAFE_ASSERT_RETURN(carlaPort == RACK_PATCHBAY_PORT_AUDIO_IN1 || carlaPort == RACK_PATCHBAY_PORT_AUDIO_IN2, false);
  1467. const int portId(otherPort-RACK_PATCHBAY_GROUP_AUDIO_IN*1000);
  1468. rack->connectLock.enter();
  1469. if (carlaPort == RACK_PATCHBAY_PORT_AUDIO_IN1)
  1470. rack->connectedIn1.removeAll(portId);
  1471. else
  1472. rack->connectedIn2.removeAll(portId);
  1473. rack->connectLock.leave();
  1474. }
  1475. else
  1476. {
  1477. CARLA_SAFE_ASSERT_RETURN(false, false);
  1478. }
  1479. callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED, connection.id, connection.portOut, connection.portIn, 0.0f, nullptr);
  1480. rack->usedConnections.remove(it);
  1481. return true;
  1482. }
  1483. }
  1484. setLastError("Failed to find connection");
  1485. return false;
  1486. }
  1487. bool CarlaEngine::patchbayRefresh()
  1488. {
  1489. setLastError("Unsupported operation");
  1490. return false;
  1491. }
  1492. #endif
  1493. // -----------------------------------------------------------------------
  1494. // Transport
  1495. void CarlaEngine::transportPlay() noexcept
  1496. {
  1497. pData->time.playing = true;
  1498. }
  1499. void CarlaEngine::transportPause() noexcept
  1500. {
  1501. pData->time.playing = false;
  1502. }
  1503. void CarlaEngine::transportRelocate(const uint64_t frame) noexcept
  1504. {
  1505. pData->time.frame = frame;
  1506. }
  1507. // -----------------------------------------------------------------------
  1508. // Error handling
  1509. const char* CarlaEngine::getLastError() const noexcept
  1510. {
  1511. return pData->lastError;
  1512. }
  1513. void CarlaEngine::setLastError(const char* const error) const
  1514. {
  1515. CARLA_ENGINE_THREAD_SAFE_SECTION;
  1516. pData->lastError = error;
  1517. }
  1518. void CarlaEngine::setAboutToClose() noexcept
  1519. {
  1520. carla_debug("CarlaEngine::setAboutToClose()");
  1521. pData->aboutToClose = true;
  1522. }
  1523. // -----------------------------------------------------------------------
  1524. // Global options
  1525. void CarlaEngine::setOption(const EngineOption option, const int value, const char* const valueStr)
  1526. {
  1527. carla_debug("CarlaEngine::setOption(%i:%s, %i, \"%s\")", option, EngineOption2Str(option), value, valueStr);
  1528. CARLA_ENGINE_THREAD_SAFE_SECTION;
  1529. if (isRunning() && (option == ENGINE_OPTION_PROCESS_MODE || option == ENGINE_OPTION_AUDIO_NUM_PERIODS || option == ENGINE_OPTION_AUDIO_DEVICE))
  1530. return carla_stderr("CarlaEngine::setOption(%i:%s, %i, \"%s\") - Cannot set this option while engine is running!", option, EngineOption2Str(option), value, valueStr);
  1531. switch (option)
  1532. {
  1533. case ENGINE_OPTION_DEBUG:
  1534. break;
  1535. case ENGINE_OPTION_PROCESS_MODE:
  1536. CARLA_SAFE_ASSERT_RETURN(value >= ENGINE_PROCESS_MODE_SINGLE_CLIENT && value <= ENGINE_PROCESS_MODE_BRIDGE,);
  1537. pData->options.processMode = static_cast<EngineProcessMode>(value);
  1538. break;
  1539. case ENGINE_OPTION_TRANSPORT_MODE:
  1540. CARLA_SAFE_ASSERT_RETURN(value >= ENGINE_TRANSPORT_MODE_INTERNAL && value <= ENGINE_TRANSPORT_MODE_BRIDGE,);
  1541. pData->options.transportMode = static_cast<EngineTransportMode>(value);
  1542. break;
  1543. case ENGINE_OPTION_FORCE_STEREO:
  1544. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  1545. pData->options.forceStereo = (value != 0);
  1546. break;
  1547. case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
  1548. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  1549. pData->options.preferPluginBridges = (value != 0);
  1550. break;
  1551. case ENGINE_OPTION_PREFER_UI_BRIDGES:
  1552. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  1553. pData->options.preferUiBridges = (value != 0);
  1554. break;
  1555. case ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
  1556. CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
  1557. pData->options.uisAlwaysOnTop = (value != 0);
  1558. break;
  1559. case ENGINE_OPTION_MAX_PARAMETERS:
  1560. CARLA_SAFE_ASSERT_RETURN(value >= 0,);
  1561. pData->options.maxParameters = static_cast<uint>(value);
  1562. break;
  1563. case ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
  1564. CARLA_SAFE_ASSERT_RETURN(value >= 0,);
  1565. pData->options.uiBridgesTimeout = static_cast<uint>(value);
  1566. break;
  1567. case ENGINE_OPTION_AUDIO_NUM_PERIODS:
  1568. CARLA_SAFE_ASSERT_RETURN(value >= 2 && value <= 3,);
  1569. pData->options.audioNumPeriods = static_cast<uint>(value);
  1570. break;
  1571. case ENGINE_OPTION_AUDIO_BUFFER_SIZE:
  1572. CARLA_SAFE_ASSERT_RETURN(value >= 8,);
  1573. pData->options.audioBufferSize = static_cast<uint>(value);
  1574. break;
  1575. case ENGINE_OPTION_AUDIO_SAMPLE_RATE:
  1576. CARLA_SAFE_ASSERT_RETURN(value >= 22050,);
  1577. pData->options.audioSampleRate = static_cast<uint>(value);
  1578. break;
  1579. case ENGINE_OPTION_AUDIO_DEVICE:
  1580. CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr,);
  1581. if (pData->options.audioDevice != nullptr)
  1582. delete[] pData->options.audioDevice;
  1583. pData->options.audioDevice = carla_strdup(valueStr);
  1584. break;
  1585. case ENGINE_OPTION_PATH_BINARIES:
  1586. CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
  1587. if (pData->options.binaryDir != nullptr)
  1588. delete[] pData->options.binaryDir;
  1589. pData->options.binaryDir = carla_strdup(valueStr);
  1590. break;
  1591. case ENGINE_OPTION_PATH_RESOURCES:
  1592. CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
  1593. if (pData->options.resourceDir != nullptr)
  1594. delete[] pData->options.resourceDir;
  1595. pData->options.resourceDir = carla_strdup(valueStr);
  1596. break;
  1597. case ENGINE_OPTION_FRONTEND_WIN_ID:
  1598. CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
  1599. const long winId(std::atol(valueStr));
  1600. CARLA_SAFE_ASSERT_RETURN(winId >= 0,);
  1601. pData->options.frontendWinId = static_cast<uintptr_t>(winId);
  1602. break;
  1603. }
  1604. }
  1605. // -----------------------------------------------------------------------
  1606. // OSC Stuff
  1607. #ifdef BUILD_BRIDGE
  1608. bool CarlaEngine::isOscBridgeRegistered() const noexcept
  1609. {
  1610. return (pData->oscData != nullptr);
  1611. }
  1612. #else
  1613. bool CarlaEngine::isOscControlRegistered() const noexcept
  1614. {
  1615. return pData->osc.isControlRegistered();
  1616. }
  1617. #endif
  1618. const char* CarlaEngine::getOscServerPathTCP() const noexcept
  1619. {
  1620. return pData->osc.getServerPathTCP();
  1621. }
  1622. const char* CarlaEngine::getOscServerPathUDP() const noexcept
  1623. {
  1624. return pData->osc.getServerPathUDP();
  1625. }
  1626. #ifdef BUILD_BRIDGE
  1627. void CarlaEngine::setOscBridgeData(const CarlaOscData* const oscData) const noexcept
  1628. {
  1629. CARLA_ENGINE_THREAD_SAFE_SECTION;
  1630. pData->oscData = oscData;
  1631. }
  1632. #endif
  1633. // -----------------------------------------------------------------------
  1634. // Helper functions
  1635. EngineEvent* CarlaEngine::getInternalEventBuffer(const bool isInput) const noexcept
  1636. {
  1637. return isInput ? pData->bufEvents.in : pData->bufEvents.out;
  1638. }
  1639. void CarlaEngine::registerEnginePlugin(const unsigned int id, CarlaPlugin* const plugin) noexcept
  1640. {
  1641. CARLA_SAFE_ASSERT_RETURN(id == pData->curPluginCount,);
  1642. carla_debug("CarlaEngine::registerEnginePlugin(%i, %p)", id, plugin);
  1643. pData->plugins[id].plugin = plugin;
  1644. }
  1645. // -----------------------------------------------------------------------
  1646. // Internal stuff
  1647. void CarlaEngine::bufferSizeChanged(const uint32_t newBufferSize)
  1648. {
  1649. carla_debug("CarlaEngine::bufferSizeChanged(%i)", newBufferSize);
  1650. for (unsigned int i=0; i < pData->curPluginCount; ++i)
  1651. {
  1652. CarlaPlugin* const plugin(pData->plugins[i].plugin);
  1653. if (plugin != nullptr && plugin->isEnabled())
  1654. plugin->bufferSizeChanged(newBufferSize);
  1655. }
  1656. callback(ENGINE_CALLBACK_BUFFER_SIZE_CHANGED, 0, static_cast<int>(newBufferSize), 0, 0.0f, nullptr);
  1657. }
  1658. void CarlaEngine::sampleRateChanged(const double newSampleRate)
  1659. {
  1660. carla_debug("CarlaEngine::sampleRateChanged(%g)", newSampleRate);
  1661. for (unsigned int i=0; i < pData->curPluginCount; ++i)
  1662. {
  1663. CarlaPlugin* const plugin(pData->plugins[i].plugin);
  1664. if (plugin != nullptr && plugin->isEnabled())
  1665. plugin->sampleRateChanged(newSampleRate);
  1666. }
  1667. callback(ENGINE_CALLBACK_SAMPLE_RATE_CHANGED, 0, 0, 0, static_cast<float>(newSampleRate), nullptr);
  1668. }
  1669. void CarlaEngine::offlineModeChanged(const bool isOfflineNow)
  1670. {
  1671. carla_debug("CarlaEngine::offlineModeChanged(%s)", bool2str(isOfflineNow));
  1672. for (unsigned int i=0; i < pData->curPluginCount; ++i)
  1673. {
  1674. CarlaPlugin* const plugin(pData->plugins[i].plugin);
  1675. if (plugin != nullptr && plugin->isEnabled())
  1676. plugin->offlineModeChanged(isOfflineNow);
  1677. }
  1678. }
  1679. void CarlaEngine::runPendingRtEvents() noexcept
  1680. {
  1681. pData->doNextPluginAction(true);
  1682. if (pData->time.playing)
  1683. pData->time.frame += pData->bufferSize;
  1684. if (pData->options.transportMode == ENGINE_TRANSPORT_MODE_INTERNAL)
  1685. {
  1686. pData->timeInfo.playing = pData->time.playing;
  1687. pData->timeInfo.frame = pData->time.frame;
  1688. }
  1689. }
  1690. void CarlaEngine::setPluginPeaks(const unsigned int pluginId, float const inPeaks[2], float const outPeaks[2]) noexcept
  1691. {
  1692. EnginePluginData& pluginData(pData->plugins[pluginId]);
  1693. pluginData.insPeak[0] = inPeaks[0];
  1694. pluginData.insPeak[1] = inPeaks[1];
  1695. pluginData.outsPeak[0] = outPeaks[0];
  1696. pluginData.outsPeak[1] = outPeaks[1];
  1697. }
  1698. #ifndef BUILD_BRIDGE
  1699. // -----------------------------------------------------------------------
  1700. // Patchbay stuff
  1701. const char* const* CarlaEngine::getPatchbayConnections() const
  1702. {
  1703. carla_debug("CarlaEngine::getPatchbayConnections()");
  1704. if (pData->bufAudio.usePatchbay)
  1705. {
  1706. CARLA_SAFE_ASSERT_RETURN(pData->bufAudio.patchbay != nullptr, nullptr);
  1707. return pData->bufAudio.patchbay->getConnections();
  1708. }
  1709. else
  1710. {
  1711. CARLA_SAFE_ASSERT_RETURN(pData->bufAudio.rack != nullptr, nullptr);
  1712. return pData->bufAudio.rack->getConnections();
  1713. }
  1714. }
  1715. static int getCarlaPortIdFromName(const char* const shortname) noexcept
  1716. {
  1717. if (std::strcmp(shortname, "AudioIn1") == 0)
  1718. return RACK_PATCHBAY_PORT_AUDIO_IN1;
  1719. if (std::strcmp(shortname, "AudioIn2") == 0)
  1720. return RACK_PATCHBAY_PORT_AUDIO_IN2;
  1721. if (std::strcmp(shortname, "AudioOut1") == 0)
  1722. return RACK_PATCHBAY_PORT_AUDIO_OUT1;
  1723. if (std::strcmp(shortname, "AudioOut2") == 0)
  1724. return RACK_PATCHBAY_PORT_AUDIO_OUT2;
  1725. if (std::strcmp(shortname, "MidiIn") == 0)
  1726. return RACK_PATCHBAY_PORT_MIDI_IN;
  1727. if (std::strcmp(shortname, "MidiOut") == 0)
  1728. return RACK_PATCHBAY_PORT_MIDI_OUT;
  1729. return RACK_PATCHBAY_PORT_MAX;
  1730. }
  1731. void CarlaEngine::restorePatchbayConnection(const char* const connSource, const char* const connTarget)
  1732. {
  1733. CARLA_SAFE_ASSERT_RETURN(connSource != nullptr && connSource[0] != '\0',);
  1734. CARLA_SAFE_ASSERT_RETURN(connTarget != nullptr && connTarget[0] != '\0',);
  1735. carla_debug("CarlaEngine::restorePatchbayConnection(\"%s\", \"%s\")", connSource, connTarget);
  1736. if (pData->bufAudio.usePatchbay)
  1737. {
  1738. // TODO
  1739. }
  1740. else
  1741. {
  1742. int sourcePort, targetPort;
  1743. if (std::strncmp(connSource, "Carla:", 6) == 0)
  1744. sourcePort = getCarlaPortIdFromName(connSource+6);
  1745. else if (std::strncmp(connSource, "AudioIn:", 8) == 0)
  1746. sourcePort = std::atoi(connSource+8) + RACK_PATCHBAY_GROUP_AUDIO_IN*1000 - 1;
  1747. else if (std::strncmp(connSource, "AudioOut:", 9) == 0)
  1748. sourcePort = std::atoi(connSource+9) + RACK_PATCHBAY_GROUP_AUDIO_OUT*1000 - 1;
  1749. else if (std::strncmp(connSource, "MidiIn:", 7) == 0)
  1750. sourcePort = std::atoi(connSource+7) + RACK_PATCHBAY_GROUP_MIDI_IN*1000 - 1;
  1751. else if (std::strncmp(connSource, "MidiOut:", 8) == 0)
  1752. sourcePort = std::atoi(connSource+8) + RACK_PATCHBAY_GROUP_MIDI_OUT*1000 - 1;
  1753. else
  1754. sourcePort = RACK_PATCHBAY_PORT_MAX;
  1755. if (std::strncmp(connTarget, "Carla:", 6) == 0)
  1756. targetPort = getCarlaPortIdFromName(connTarget+6);
  1757. else if (std::strncmp(connTarget, "AudioIn:", 8) == 0)
  1758. targetPort = std::atoi(connTarget+8) + RACK_PATCHBAY_GROUP_AUDIO_IN*1000 - 1;
  1759. else if (std::strncmp(connTarget, "AudioOut:", 9) == 0)
  1760. targetPort = std::atoi(connTarget+9) + RACK_PATCHBAY_GROUP_AUDIO_OUT*1000 - 1;
  1761. else if (std::strncmp(connTarget, "MidiIn:", 7) == 0)
  1762. targetPort = std::atoi(connTarget+7) + RACK_PATCHBAY_GROUP_MIDI_IN*1000 - 1;
  1763. else if (std::strncmp(connTarget, "MidiOut:", 8) == 0)
  1764. targetPort = std::atoi(connTarget+8) + RACK_PATCHBAY_GROUP_MIDI_OUT*1000 - 1;
  1765. else
  1766. targetPort = RACK_PATCHBAY_PORT_MAX;
  1767. if (sourcePort != RACK_PATCHBAY_PORT_MAX && targetPort != RACK_PATCHBAY_PORT_MAX)
  1768. patchbayConnect(targetPort, sourcePort);
  1769. }
  1770. }
  1771. #endif
  1772. // -----------------------------------------------------------------------
  1773. // Bridge/Controller OSC stuff
  1774. #ifdef BUILD_BRIDGE
  1775. void CarlaEngine::oscSend_bridge_plugin_info1(const PluginCategory category, const uint hints, const int64_t uniqueId) const noexcept
  1776. {
  1777. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1778. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1779. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1780. carla_debug("CarlaEngine::oscSend_bridge_plugin_info1(%i:%s, %X, " P_INT64 ")", category, PluginCategory2Str(category), hints, uniqueId);
  1781. char targetPath[std::strlen(pData->oscData->path)+21];
  1782. std::strcpy(targetPath, pData->oscData->path);
  1783. std::strcat(targetPath, "/bridge_plugin_info1");
  1784. try_lo_send(pData->oscData->target, targetPath, "iih", static_cast<int32_t>(category), static_cast<int32_t>(hints), uniqueId);
  1785. }
  1786. void CarlaEngine::oscSend_bridge_plugin_info2(const char* const realName, const char* const label, const char* const maker, const char* const copyright) const noexcept
  1787. {
  1788. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1789. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1790. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1791. CARLA_SAFE_ASSERT_RETURN(realName != nullptr && realName[0] != '\0',);
  1792. CARLA_SAFE_ASSERT_RETURN(label != nullptr && label[0] != '\0',);
  1793. CARLA_SAFE_ASSERT_RETURN(maker != nullptr,);
  1794. CARLA_SAFE_ASSERT_RETURN(copyright != nullptr,);
  1795. carla_debug("CarlaEngine::oscSend_bridge_plugin_info2(\"%s\", \"%s\", \"%s\", \"%s\")", realName, label, maker, copyright);
  1796. char targetPath[std::strlen(pData->oscData->path)+21];
  1797. std::strcpy(targetPath, pData->oscData->path);
  1798. std::strcat(targetPath, "/bridge_plugin_info2");
  1799. try_lo_send(pData->oscData->target, targetPath, "ssss", realName, label, maker, copyright);
  1800. }
  1801. void CarlaEngine::oscSend_bridge_audio_count(const uint32_t ins, const uint32_t outs) const noexcept
  1802. {
  1803. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1804. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1805. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1806. carla_debug("CarlaEngine::oscSend_bridge_audio_count(%i, %i)", ins, outs);
  1807. char targetPath[std::strlen(pData->oscData->path)+20];
  1808. std::strcpy(targetPath, pData->oscData->path);
  1809. std::strcat(targetPath, "/bridge_audio_count");
  1810. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  1811. }
  1812. void CarlaEngine::oscSend_bridge_midi_count(const uint32_t ins, const uint32_t outs) const noexcept
  1813. {
  1814. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1815. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1816. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1817. carla_debug("CarlaEngine::oscSend_bridge_midi_count(%i, %i)", ins, outs);
  1818. char targetPath[std::strlen(pData->oscData->path)+19];
  1819. std::strcpy(targetPath, pData->oscData->path);
  1820. std::strcat(targetPath, "/bridge_midi_count");
  1821. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  1822. }
  1823. void CarlaEngine::oscSend_bridge_parameter_count(const uint32_t ins, const uint32_t outs) const noexcept
  1824. {
  1825. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1826. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1827. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1828. carla_debug("CarlaEngine::oscSend_bridge_parameter_count(%i, %i)", ins, outs);
  1829. char targetPath[std::strlen(pData->oscData->path)+24];
  1830. std::strcpy(targetPath, pData->oscData->path);
  1831. std::strcat(targetPath, "/bridge_parameter_count");
  1832. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  1833. }
  1834. void CarlaEngine::oscSend_bridge_program_count(const uint32_t count) const noexcept
  1835. {
  1836. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1837. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1838. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1839. carla_debug("CarlaEngine::oscSend_bridge_program_count(%i)", count);
  1840. char targetPath[std::strlen(pData->oscData->path)+23];
  1841. std::strcpy(targetPath, pData->oscData->path);
  1842. std::strcat(targetPath, "/bridge_program_count");
  1843. try_lo_send(pData->oscData->target, targetPath, "i", static_cast<int32_t>(count));
  1844. }
  1845. void CarlaEngine::oscSend_bridge_midi_program_count(const uint32_t count) const noexcept
  1846. {
  1847. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1848. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1849. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1850. carla_debug("CarlaEngine::oscSend_bridge_midi_program_count(%i)", count);
  1851. char targetPath[std::strlen(pData->oscData->path)+27];
  1852. std::strcpy(targetPath, pData->oscData->path);
  1853. std::strcat(targetPath, "/bridge_midi_program_count");
  1854. try_lo_send(pData->oscData->target, targetPath, "i", static_cast<int32_t>(count));
  1855. }
  1856. void CarlaEngine::oscSend_bridge_parameter_data(const uint32_t index, const int32_t rindex, const ParameterType type, const uint hints, const char* const name, const char* const unit) const noexcept
  1857. {
  1858. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1859. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1860. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1861. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  1862. CARLA_SAFE_ASSERT_RETURN(unit != nullptr,);
  1863. carla_debug("CarlaEngine::oscSend_bridge_parameter_data(%i, %i, %i:%s, %X, \"%s\", \"%s\")", index, rindex, type, ParameterType2Str(type), hints, name, unit);
  1864. char targetPath[std::strlen(pData->oscData->path)+23];
  1865. std::strcpy(targetPath, pData->oscData->path);
  1866. std::strcat(targetPath, "/bridge_parameter_data");
  1867. try_lo_send(pData->oscData->target, targetPath, "iiiiss", static_cast<int32_t>(index), static_cast<int32_t>(rindex), static_cast<int32_t>(type), static_cast<int32_t>(hints), name, unit);
  1868. }
  1869. void CarlaEngine::oscSend_bridge_parameter_ranges1(const uint32_t index, const float def, const float min, const float max) const noexcept
  1870. {
  1871. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1872. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1873. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1874. carla_debug("CarlaEngine::oscSend_bridge_parameter_ranges(%i, %f, %f, %f)", index, def, min, max);
  1875. char targetPath[std::strlen(pData->oscData->path)+26];
  1876. std::strcpy(targetPath, pData->oscData->path);
  1877. std::strcat(targetPath, "/bridge_parameter_ranges1");
  1878. try_lo_send(pData->oscData->target, targetPath, "ifff", static_cast<int32_t>(index), def, min, max);
  1879. }
  1880. void CarlaEngine::oscSend_bridge_parameter_ranges2(const uint32_t index, const float step, const float stepSmall, const float stepLarge) const noexcept
  1881. {
  1882. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1883. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1884. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1885. carla_debug("CarlaEngine::oscSend_bridge_parameter_ranges(%i, %f, %f, %f)", index, step, stepSmall, stepLarge);
  1886. char targetPath[std::strlen(pData->oscData->path)+26];
  1887. std::strcpy(targetPath, pData->oscData->path);
  1888. std::strcat(targetPath, "/bridge_parameter_ranges2");
  1889. try_lo_send(pData->oscData->target, targetPath, "ifff", static_cast<int32_t>(index), step, stepSmall, stepLarge);
  1890. }
  1891. void CarlaEngine::oscSend_bridge_parameter_midi_cc(const uint32_t index, const int16_t cc) const noexcept
  1892. {
  1893. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1894. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1895. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1896. carla_debug("CarlaEngine::oscSend_bridge_parameter_midi_cc(%i, %i)", index, cc);
  1897. char targetPath[std::strlen(pData->oscData->path)+26];
  1898. std::strcpy(targetPath, pData->oscData->path);
  1899. std::strcat(targetPath, "/bridge_parameter_midi_cc");
  1900. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(index), static_cast<int32_t>(cc));
  1901. }
  1902. void CarlaEngine::oscSend_bridge_parameter_midi_channel(const uint32_t index, const uint8_t channel) const noexcept
  1903. {
  1904. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1905. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1906. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1907. carla_debug("CarlaEngine::oscSend_bridge_parameter_midi_channel(%i, %i)", index, channel);
  1908. char targetPath[std::strlen(pData->oscData->path)+31];
  1909. std::strcpy(targetPath, pData->oscData->path);
  1910. std::strcat(targetPath, "/bridge_parameter_midi_channel");
  1911. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(index), static_cast<int32_t>(channel));
  1912. }
  1913. void CarlaEngine::oscSend_bridge_parameter_value(const uint32_t index, const float value) const noexcept
  1914. {
  1915. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1916. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1917. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1918. carla_debug("CarlaEngine::oscSend_bridge_parameter_value(%i, %f)", index, value);
  1919. char targetPath[std::strlen(pData->oscData->path)+24];
  1920. std::strcpy(targetPath, pData->oscData->path);
  1921. std::strcat(targetPath, "/bridge_parameter_value");
  1922. try_lo_send(pData->oscData->target, targetPath, "if", static_cast<int32_t>(index), value);
  1923. }
  1924. void CarlaEngine::oscSend_bridge_default_value(const uint32_t index, const float value) const noexcept
  1925. {
  1926. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1927. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1928. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1929. carla_debug("CarlaEngine::oscSend_bridge_default_value(%i, %f)", index, value);
  1930. char targetPath[std::strlen(pData->oscData->path)+22];
  1931. std::strcpy(targetPath, pData->oscData->path);
  1932. std::strcat(targetPath, "/bridge_default_value");
  1933. try_lo_send(pData->oscData->target, targetPath, "if", static_cast<int32_t>(index), value);
  1934. }
  1935. void CarlaEngine::oscSend_bridge_current_program(const int32_t index) const noexcept
  1936. {
  1937. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1938. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1939. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1940. carla_debug("CarlaEngine::oscSend_bridge_current_program(%i)", index);
  1941. char targetPath[std::strlen(pData->oscData->path)+24];
  1942. std::strcpy(targetPath, pData->oscData->path);
  1943. std::strcat(targetPath, "/bridge_current_program");
  1944. try_lo_send(pData->oscData->target, targetPath, "i", index);
  1945. }
  1946. void CarlaEngine::oscSend_bridge_current_midi_program(const int32_t index) const noexcept
  1947. {
  1948. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1949. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1950. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1951. carla_debug("CarlaEngine::oscSend_bridge_current_midi_program(%i)", index);
  1952. char targetPath[std::strlen(pData->oscData->path)+30];
  1953. std::strcpy(targetPath, pData->oscData->path);
  1954. std::strcat(targetPath, "/bridge_current_midi_program");
  1955. try_lo_send(pData->oscData->target, targetPath, "i", index);
  1956. }
  1957. void CarlaEngine::oscSend_bridge_program_name(const uint32_t index, const char* const name) const noexcept
  1958. {
  1959. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1960. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1961. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1962. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  1963. carla_debug("CarlaEngine::oscSend_bridge_program_name(%i, \"%s\")", index, name);
  1964. char targetPath[std::strlen(pData->oscData->path)+21];
  1965. std::strcpy(targetPath, pData->oscData->path);
  1966. std::strcat(targetPath, "/bridge_program_name");
  1967. try_lo_send(pData->oscData->target, targetPath, "is", static_cast<int32_t>(index), name);
  1968. }
  1969. void CarlaEngine::oscSend_bridge_midi_program_data(const uint32_t index, const uint32_t bank, const uint32_t program, const char* const name) const noexcept
  1970. {
  1971. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1972. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1973. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1974. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  1975. carla_debug("CarlaEngine::oscSend_bridge_midi_program_data(%i, %i, %i, \"%s\")", index, bank, program, name);
  1976. char targetPath[std::strlen(pData->oscData->path)+26];
  1977. std::strcpy(targetPath, pData->oscData->path);
  1978. std::strcat(targetPath, "/bridge_midi_program_data");
  1979. try_lo_send(pData->oscData->target, targetPath, "iiis", static_cast<int32_t>(index), static_cast<int32_t>(bank), static_cast<int32_t>(program), name);
  1980. }
  1981. void CarlaEngine::oscSend_bridge_configure(const char* const key, const char* const value) const noexcept
  1982. {
  1983. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1984. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1985. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1986. CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',);
  1987. CARLA_SAFE_ASSERT_RETURN(value != nullptr,);
  1988. carla_debug("CarlaEngine::oscSend_bridge_configure(\"%s\", \"%s\")", key, value);
  1989. char targetPath[std::strlen(pData->oscData->path)+18];
  1990. std::strcpy(targetPath, pData->oscData->path);
  1991. std::strcat(targetPath, "/bridge_configure");
  1992. try_lo_send(pData->oscData->target, targetPath, "ss", key, value);
  1993. }
  1994. void CarlaEngine::oscSend_bridge_set_custom_data(const char* const type, const char* const key, const char* const value) const noexcept
  1995. {
  1996. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  1997. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  1998. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  1999. CARLA_SAFE_ASSERT_RETURN(type != nullptr && type[0] != '\0',);
  2000. CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',);
  2001. CARLA_SAFE_ASSERT_RETURN(value != nullptr,);
  2002. carla_debug("CarlaEngine::oscSend_bridge_set_custom_data(\"%s\", \"%s\", \"%s\")", type, key, value);
  2003. char targetPath[std::strlen(pData->oscData->path)+24];
  2004. std::strcpy(targetPath, pData->oscData->path);
  2005. std::strcat(targetPath, "/bridge_set_custom_data");
  2006. try_lo_send(pData->oscData->target, targetPath, "sss", type, key, value);
  2007. }
  2008. void CarlaEngine::oscSend_bridge_set_chunk_data(const char* const chunkFile) const noexcept
  2009. {
  2010. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2011. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2012. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2013. CARLA_SAFE_ASSERT_RETURN(chunkFile != nullptr && chunkFile[0] != '\0',);
  2014. carla_debug("CarlaEngine::oscSend_bridge_set_chunk_data(\"%s\")", chunkFile);
  2015. char targetPath[std::strlen(pData->oscData->path)+23];
  2016. std::strcpy(targetPath, pData->oscData->path);
  2017. std::strcat(targetPath, "/bridge_set_chunk_data");
  2018. try_lo_send(pData->oscData->target, targetPath, "s", chunkFile);
  2019. }
  2020. void CarlaEngine::oscSend_bridge_pong() const noexcept
  2021. {
  2022. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2023. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2024. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2025. //carla_debug("CarlaEngine::oscSend_pong()");
  2026. char targetPath[std::strlen(pData->oscData->path)+13];
  2027. std::strcpy(targetPath, pData->oscData->path);
  2028. std::strcat(targetPath, "/bridge_pong");
  2029. try_lo_send(pData->oscData->target, targetPath, "");
  2030. }
  2031. #else
  2032. void CarlaEngine::oscSend_control_add_plugin_start(const uint pluginId, const char* const pluginName) const noexcept
  2033. {
  2034. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2035. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2036. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2037. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2038. CARLA_SAFE_ASSERT_RETURN(pluginName != nullptr && pluginName[0] != '\0',);
  2039. carla_debug("CarlaEngine::oscSend_control_add_plugin_start(%i, \"%s\")", pluginId, pluginName);
  2040. char targetPath[std::strlen(pData->oscData->path)+18];
  2041. std::strcpy(targetPath, pData->oscData->path);
  2042. std::strcat(targetPath, "/add_plugin_start");
  2043. try_lo_send(pData->oscData->target, targetPath, "is", static_cast<int32_t>(pluginId), pluginName);
  2044. }
  2045. void CarlaEngine::oscSend_control_add_plugin_end(const uint pluginId) const noexcept
  2046. {
  2047. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2048. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2049. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2050. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2051. carla_debug("CarlaEngine::oscSend_control_add_plugin_end(%i)", pluginId);
  2052. char targetPath[std::strlen(pData->oscData->path)+16];
  2053. std::strcpy(targetPath, pData->oscData->path);
  2054. std::strcat(targetPath, "/add_plugin_end");
  2055. try_lo_send(pData->oscData->target, targetPath, "i", static_cast<int32_t>(pluginId));
  2056. }
  2057. void CarlaEngine::oscSend_control_remove_plugin(const uint pluginId) const noexcept
  2058. {
  2059. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2060. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2061. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2062. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2063. carla_debug("CarlaEngine::oscSend_control_remove_plugin(%i)", pluginId);
  2064. char targetPath[std::strlen(pData->oscData->path)+15];
  2065. std::strcpy(targetPath, pData->oscData->path);
  2066. std::strcat(targetPath, "/remove_plugin");
  2067. try_lo_send(pData->oscData->target, targetPath, "i", static_cast<int32_t>(pluginId));
  2068. }
  2069. void CarlaEngine::oscSend_control_set_plugin_info1(const uint pluginId, const PluginType type, const PluginCategory category, const uint hints, const int64_t uniqueId) const noexcept
  2070. {
  2071. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2072. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2073. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2074. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2075. CARLA_SAFE_ASSERT_RETURN(type != PLUGIN_NONE,);
  2076. carla_debug("CarlaEngine::oscSend_control_set_plugin_data(%i, %i:%s, %i:%s, %X, " P_INT64 ")", pluginId, type, PluginType2Str(type), category, PluginCategory2Str(category), hints, uniqueId);
  2077. char targetPath[std::strlen(pData->oscData->path)+18];
  2078. std::strcpy(targetPath, pData->oscData->path);
  2079. std::strcat(targetPath, "/set_plugin_info1");
  2080. try_lo_send(pData->oscData->target, targetPath, "iiiih", static_cast<int32_t>(pluginId), static_cast<int32_t>(type), static_cast<int32_t>(category), static_cast<int32_t>(hints), static_cast<int64_t>(uniqueId));
  2081. }
  2082. void CarlaEngine::oscSend_control_set_plugin_info2(const uint pluginId, const char* const realName, const char* const label, const char* const maker, const char* const copyright) const noexcept
  2083. {
  2084. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2085. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2086. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2087. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2088. CARLA_SAFE_ASSERT_RETURN(realName != nullptr && realName[0] != '\0',);
  2089. CARLA_SAFE_ASSERT_RETURN(label != nullptr && label[0] != '\0',);
  2090. CARLA_SAFE_ASSERT_RETURN(maker != nullptr,);
  2091. CARLA_SAFE_ASSERT_RETURN(copyright != nullptr,);
  2092. carla_debug("CarlaEngine::oscSend_control_set_plugin_data(%i, \"%s\", \"%s\", \"%s\", \"%s\")", pluginId, realName, label, maker, copyright);
  2093. char targetPath[std::strlen(pData->oscData->path)+18];
  2094. std::strcpy(targetPath, pData->oscData->path);
  2095. std::strcat(targetPath, "/set_plugin_info2");
  2096. try_lo_send(pData->oscData->target, targetPath, "issss", static_cast<int32_t>(pluginId), realName, label, maker, copyright);
  2097. }
  2098. void CarlaEngine::oscSend_control_set_audio_count(const uint pluginId, const uint32_t ins, const uint32_t outs) const noexcept
  2099. {
  2100. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2101. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2102. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2103. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2104. carla_debug("CarlaEngine::oscSend_control_set_audio_count(%i, %i, %i)", pluginId, ins, outs);
  2105. char targetPath[std::strlen(pData->oscData->path)+18];
  2106. std::strcpy(targetPath, pData->oscData->path);
  2107. std::strcat(targetPath, "/set_audio_count");
  2108. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  2109. }
  2110. void CarlaEngine::oscSend_control_set_midi_count(const uint pluginId, const uint32_t ins, const uint32_t outs) const noexcept
  2111. {
  2112. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2113. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2114. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2115. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2116. carla_debug("CarlaEngine::oscSend_control_set_midi_count(%i, %i, %i)", pluginId, ins, outs);
  2117. char targetPath[std::strlen(pData->oscData->path)+18];
  2118. std::strcpy(targetPath, pData->oscData->path);
  2119. std::strcat(targetPath, "/set_midi_count");
  2120. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  2121. }
  2122. void CarlaEngine::oscSend_control_set_parameter_count(const uint pluginId, const uint32_t ins, const uint32_t outs) const noexcept
  2123. {
  2124. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2125. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2126. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2127. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2128. carla_debug("CarlaEngine::oscSend_control_set_parameter_count(%i, %i, %i)", pluginId, ins, outs);
  2129. char targetPath[std::strlen(pData->oscData->path)+18];
  2130. std::strcpy(targetPath, pData->oscData->path);
  2131. std::strcat(targetPath, "/set_parameter_count");
  2132. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  2133. }
  2134. void CarlaEngine::oscSend_control_set_program_count(const uint pluginId, const uint32_t count) const noexcept
  2135. {
  2136. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2137. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2138. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2139. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2140. carla_debug("CarlaEngine::oscSend_control_set_program_count(%i, %i)", pluginId, count);
  2141. char targetPath[std::strlen(pData->oscData->path)+19];
  2142. std::strcpy(targetPath, pData->oscData->path);
  2143. std::strcat(targetPath, "/set_program_count");
  2144. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), static_cast<int32_t>(count));
  2145. }
  2146. void CarlaEngine::oscSend_control_set_midi_program_count(const uint pluginId, const uint32_t count) const noexcept
  2147. {
  2148. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2149. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2150. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2151. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2152. carla_debug("CarlaEngine::oscSend_control_set_midi_program_count(%i, %i)", pluginId, count);
  2153. char targetPath[std::strlen(pData->oscData->path)+24];
  2154. std::strcpy(targetPath, pData->oscData->path);
  2155. std::strcat(targetPath, "/set_midi_program_count");
  2156. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), static_cast<int32_t>(count));
  2157. }
  2158. void CarlaEngine::oscSend_control_set_parameter_data(const uint pluginId, const uint32_t index, const ParameterType type, const uint hints, const char* const name, const char* const unit) const noexcept
  2159. {
  2160. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2161. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2162. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2163. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2164. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0',);
  2165. CARLA_SAFE_ASSERT_RETURN(unit != nullptr,);
  2166. carla_debug("CarlaEngine::oscSend_control_set_parameter_data(%i, %i, %i:%s, %X, \"%s\", \"%s\")", pluginId, index, type, ParameterType2Str(type), hints, name, unit);
  2167. char targetPath[std::strlen(pData->oscData->path)+20];
  2168. std::strcpy(targetPath, pData->oscData->path);
  2169. std::strcat(targetPath, "/set_parameter_data");
  2170. try_lo_send(pData->oscData->target, targetPath, "iiiiss", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(type), static_cast<int32_t>(hints), name, unit);
  2171. }
  2172. void CarlaEngine::oscSend_control_set_parameter_ranges1(const uint pluginId, const uint32_t index, const float def, const float min, const float max) const noexcept
  2173. {
  2174. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2175. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2176. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2177. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2178. CARLA_SAFE_ASSERT_RETURN(def <= min && def >= max,);
  2179. CARLA_SAFE_ASSERT_RETURN(min < max,);
  2180. carla_debug("CarlaEngine::oscSend_control_set_parameter_ranges1(%i, %i, %f, %f, %f)", pluginId, index, def, min, max, def);
  2181. char targetPath[std::strlen(pData->oscData->path)+23];
  2182. std::strcpy(targetPath, pData->oscData->path);
  2183. std::strcat(targetPath, "/set_parameter_ranges1");
  2184. try_lo_send(pData->oscData->target, targetPath, "iifff", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), def, min, max);
  2185. }
  2186. void CarlaEngine::oscSend_control_set_parameter_ranges2(const uint pluginId, const uint32_t index, const float step, const float stepSmall, const float stepLarge) const noexcept
  2187. {
  2188. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2189. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2190. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2191. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2192. CARLA_SAFE_ASSERT_RETURN(step <= stepSmall && step >= stepLarge,);
  2193. CARLA_SAFE_ASSERT_RETURN(stepSmall <= stepLarge,);
  2194. carla_debug("CarlaEngine::oscSend_control_set_parameter_ranges2(%i, %i, %f, %f, %f)", pluginId, index, step, stepSmall, stepLarge);
  2195. char targetPath[std::strlen(pData->oscData->path)+23];
  2196. std::strcpy(targetPath, pData->oscData->path);
  2197. std::strcat(targetPath, "/set_parameter_ranges");
  2198. try_lo_send(pData->oscData->target, targetPath, "iifff", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), step, stepSmall, stepLarge);
  2199. }
  2200. void CarlaEngine::oscSend_control_set_parameter_midi_cc(const uint pluginId, const uint32_t index, const int16_t cc) const noexcept
  2201. {
  2202. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2203. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2204. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2205. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2206. CARLA_SAFE_ASSERT_RETURN(cc <= 0x5F,);
  2207. carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_cc(%i, %i, %i)", pluginId, index, cc);
  2208. char targetPath[std::strlen(pData->oscData->path)+23];
  2209. std::strcpy(targetPath, pData->oscData->path);
  2210. std::strcat(targetPath, "/set_parameter_midi_cc");
  2211. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(cc));
  2212. }
  2213. void CarlaEngine::oscSend_control_set_parameter_midi_channel(const uint pluginId, const uint32_t index, const uint8_t channel) const noexcept
  2214. {
  2215. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2216. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2217. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2218. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2219. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  2220. carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_channel(%i, %i, %i)", pluginId, index, channel);
  2221. char targetPath[std::strlen(pData->oscData->path)+28];
  2222. std::strcpy(targetPath, pData->oscData->path);
  2223. std::strcat(targetPath, "/set_parameter_midi_channel");
  2224. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(channel));
  2225. }
  2226. void CarlaEngine::oscSend_control_set_parameter_value(const uint pluginId, const int32_t index, const float value) const noexcept
  2227. {
  2228. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2229. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2230. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2231. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2232. CARLA_SAFE_ASSERT_RETURN(index != PARAMETER_NULL,);
  2233. carla_debug("CarlaEngine::oscSend_control_set_parameter_value(%i, %i:%s, %f)", pluginId, index, (index < 0) ? InternalParameterIndex2Str(static_cast<InternalParameterIndex>(index)) : "(none)", value);
  2234. char targetPath[std::strlen(pData->oscData->path)+21];
  2235. std::strcpy(targetPath, pData->oscData->path);
  2236. std::strcat(targetPath, "/set_parameter_value");
  2237. try_lo_send(pData->oscData->target, targetPath, "iif", static_cast<int32_t>(pluginId), index, value);
  2238. }
  2239. void CarlaEngine::oscSend_control_set_default_value(const uint pluginId, const uint32_t index, const float value) const noexcept
  2240. {
  2241. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2242. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2243. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2244. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2245. carla_debug("CarlaEngine::oscSend_control_set_default_value(%i, %i, %f)", pluginId, index, value);
  2246. char targetPath[std::strlen(pData->oscData->path)+19];
  2247. std::strcpy(targetPath, pData->oscData->path);
  2248. std::strcat(targetPath, "/set_default_value");
  2249. try_lo_send(pData->oscData->target, targetPath, "iif", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), value);
  2250. }
  2251. void CarlaEngine::oscSend_control_set_current_program(const uint pluginId, const int32_t index) const noexcept
  2252. {
  2253. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2254. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2255. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2256. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2257. carla_debug("CarlaEngine::oscSend_control_set_current_program(%i, %i)", pluginId, index);
  2258. char targetPath[std::strlen(pData->oscData->path)+21];
  2259. std::strcpy(targetPath, pData->oscData->path);
  2260. std::strcat(targetPath, "/set_current_program");
  2261. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), index);
  2262. }
  2263. void CarlaEngine::oscSend_control_set_current_midi_program(const uint pluginId, const int32_t index) const noexcept
  2264. {
  2265. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2266. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2267. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2268. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2269. carla_debug("CarlaEngine::oscSend_control_set_current_midi_program(%i, %i)", pluginId, index);
  2270. char targetPath[std::strlen(pData->oscData->path)+26];
  2271. std::strcpy(targetPath, pData->oscData->path);
  2272. std::strcat(targetPath, "/set_current_midi_program");
  2273. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), index);
  2274. }
  2275. void CarlaEngine::oscSend_control_set_program_name(const uint pluginId, const uint32_t index, const char* const name) const noexcept
  2276. {
  2277. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2278. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2279. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2280. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2281. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  2282. carla_debug("CarlaEngine::oscSend_control_set_program_name(%i, %i, \"%s\")", pluginId, index, name);
  2283. char targetPath[std::strlen(pData->oscData->path)+18];
  2284. std::strcpy(targetPath, pData->oscData->path);
  2285. std::strcat(targetPath, "/set_program_name");
  2286. try_lo_send(pData->oscData->target, targetPath, "iis", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), name);
  2287. }
  2288. void CarlaEngine::oscSend_control_set_midi_program_data(const uint pluginId, const uint32_t index, const uint32_t bank, const uint32_t program, const char* const name) const noexcept
  2289. {
  2290. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2291. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2292. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2293. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2294. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  2295. carla_debug("CarlaEngine::oscSend_control_set_midi_program_data(%i, %i, %i, %i, \"%s\")", pluginId, index, bank, program, name);
  2296. char targetPath[std::strlen(pData->oscData->path)+23];
  2297. std::strcpy(targetPath, pData->oscData->path);
  2298. std::strcat(targetPath, "/set_midi_program_data");
  2299. try_lo_send(pData->oscData->target, targetPath, "iiiis", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(bank), static_cast<int32_t>(program), name);
  2300. }
  2301. void CarlaEngine::oscSend_control_note_on(const uint pluginId, const uint8_t channel, const uint8_t note, const uint8_t velo) const noexcept
  2302. {
  2303. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2304. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2305. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2306. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2307. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  2308. CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_NOTE,);
  2309. CARLA_SAFE_ASSERT_RETURN(velo < MAX_MIDI_VALUE,);
  2310. carla_debug("CarlaEngine::oscSend_control_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo);
  2311. char targetPath[std::strlen(pData->oscData->path)+9];
  2312. std::strcpy(targetPath, pData->oscData->path);
  2313. std::strcat(targetPath, "/note_on");
  2314. try_lo_send(pData->oscData->target, targetPath, "iiii", static_cast<int32_t>(pluginId), static_cast<int32_t>(channel), static_cast<int32_t>(note), static_cast<int32_t>(velo));
  2315. }
  2316. void CarlaEngine::oscSend_control_note_off(const uint pluginId, const uint8_t channel, const uint8_t note) const noexcept
  2317. {
  2318. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2319. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2320. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2321. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2322. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  2323. CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_NOTE,);
  2324. carla_debug("CarlaEngine::oscSend_control_note_off(%i, %i, %i)", pluginId, channel, note);
  2325. char targetPath[std::strlen(pData->oscData->path)+10];
  2326. std::strcpy(targetPath, pData->oscData->path);
  2327. std::strcat(targetPath, "/note_off");
  2328. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(channel), static_cast<int32_t>(note));
  2329. }
  2330. void CarlaEngine::oscSend_control_set_peaks(const uint pluginId) const noexcept
  2331. {
  2332. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2333. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2334. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2335. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  2336. // TODO - try and see if we can get peaks[4] ref
  2337. const EnginePluginData& epData(pData->plugins[pluginId]);
  2338. char targetPath[std::strlen(pData->oscData->path)+11];
  2339. std::strcpy(targetPath, pData->oscData->path);
  2340. std::strcat(targetPath, "/set_peaks");
  2341. try_lo_send(pData->oscData->target, targetPath, "iffff", static_cast<int32_t>(pluginId), epData.insPeak[0], epData.insPeak[1], epData.outsPeak[0], epData.outsPeak[1]);
  2342. }
  2343. void CarlaEngine::oscSend_control_exit() const noexcept
  2344. {
  2345. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  2346. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  2347. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  2348. carla_debug("CarlaEngine::oscSend_control_exit()");
  2349. char targetPath[std::strlen(pData->oscData->path)+6];
  2350. std::strcpy(targetPath, pData->oscData->path);
  2351. std::strcat(targetPath, "/exit");
  2352. try_lo_send(pData->oscData->target, targetPath, "");
  2353. }
  2354. #endif
  2355. // -----------------------------------------------------------------------
  2356. CARLA_BACKEND_END_NAMESPACE