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.

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