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.

2059 lines
64KB

  1. /*
  2. * Carla Engine
  3. * Copyright (C) 2012-2013 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 GPL.txt file
  16. */
  17. #include "carla_engine_internal.hpp"
  18. #include "carla_backend_utils.hpp"
  19. #include "carla_midi.h"
  20. CARLA_BACKEND_START_NAMESPACE
  21. // -------------------------------------------------------------------------------------------------------------------
  22. // Carla Engine port (Abstract)
  23. CarlaEnginePort::CarlaEnginePort(const bool isInput, const ProcessMode processMode)
  24. : kIsInput(isInput),
  25. kProcessMode(processMode)
  26. {
  27. qDebug("CarlaEnginePort::CarlaEnginePort(%s, %s)", bool2str(isInput), ProcessMode2Str(processMode));
  28. }
  29. CarlaEnginePort::~CarlaEnginePort()
  30. {
  31. qDebug("CarlaEnginePort::~CarlaEnginePort()");
  32. }
  33. // -------------------------------------------------------------------------------------------------------------------
  34. // Carla Engine Audio port
  35. CarlaEngineAudioPort::CarlaEngineAudioPort(const bool isInput, const ProcessMode processMode)
  36. : CarlaEnginePort(isInput, processMode),
  37. fBuffer(nullptr)
  38. {
  39. qDebug("CarlaEngineAudioPort::CarlaEngineAudioPort(%s, %s)", bool2str(isInput), ProcessMode2Str(processMode));
  40. #ifndef BUILD_BRIDGE
  41. if (kProcessMode == PROCESS_MODE_PATCHBAY)
  42. fBuffer = new float[PATCHBAY_BUFFER_SIZE];
  43. #endif
  44. }
  45. CarlaEngineAudioPort::~CarlaEngineAudioPort()
  46. {
  47. qDebug("CarlaEngineAudioPort::~CarlaEngineAudioPort()");
  48. #ifndef BUILD_BRIDGE
  49. if (kProcessMode == PROCESS_MODE_PATCHBAY)
  50. {
  51. CARLA_ASSERT(fBuffer);
  52. if (fBuffer)
  53. delete[] fBuffer;
  54. }
  55. #endif
  56. }
  57. void CarlaEngineAudioPort::initBuffer(CarlaEngine* const)
  58. {
  59. #ifndef BUILD_BRIDGE
  60. if (kProcessMode == PROCESS_MODE_PATCHBAY && ! kIsInput)
  61. carla_zeroFloat(fBuffer, PATCHBAY_BUFFER_SIZE);
  62. #endif
  63. }
  64. // -------------------------------------------------------------------------------------------------------------------
  65. // Carla Engine Event port
  66. CarlaEngineEventPort::CarlaEngineEventPort(const bool isInput, const ProcessMode processMode)
  67. : CarlaEnginePort(isInput, processMode),
  68. kMaxEventCount(processMode == PROCESS_MODE_CONTINUOUS_RACK ? RACK_EVENT_COUNT : PATCHBAY_EVENT_COUNT),
  69. fBuffer(nullptr)
  70. {
  71. qDebug("CarlaEngineEventPort::CarlaEngineEventPort(%s, %s)", bool2str(isInput), ProcessMode2Str(processMode));
  72. #ifndef BUILD_BRIDGE
  73. if (kProcessMode == PROCESS_MODE_PATCHBAY)
  74. fBuffer = new EngineEvent[PATCHBAY_EVENT_COUNT];
  75. #endif
  76. }
  77. CarlaEngineEventPort::~CarlaEngineEventPort()
  78. {
  79. qDebug("CarlaEngineEventPort::~CarlaEngineEventPort()");
  80. #ifndef BUILD_BRIDGE
  81. if (kProcessMode == PROCESS_MODE_PATCHBAY)
  82. {
  83. CARLA_ASSERT(fBuffer);
  84. if (fBuffer)
  85. delete[] fBuffer;
  86. }
  87. #endif
  88. }
  89. void CarlaEngineEventPort::initBuffer(CarlaEngine* const engine)
  90. {
  91. CARLA_ASSERT(engine != nullptr);
  92. if (engine == nullptr)
  93. return;
  94. #ifndef BUILD_BRIDGE
  95. if (kProcessMode == PROCESS_MODE_CONTINUOUS_RACK)
  96. fBuffer = engine->getRackEventBuffer(kIsInput);
  97. else if (kProcessMode == PROCESS_MODE_PATCHBAY && ! kIsInput)
  98. carla_zeroMem(fBuffer, sizeof(EngineEvent)*PATCHBAY_EVENT_COUNT);
  99. #endif
  100. }
  101. uint32_t CarlaEngineEventPort::getEventCount()
  102. {
  103. if (! kIsInput)
  104. return 0;
  105. CARLA_ASSERT(fBuffer != nullptr);
  106. if (fBuffer == nullptr)
  107. return 0;
  108. #ifndef BUILD_BRIDGE
  109. if (kProcessMode == PROCESS_MODE_CONTINUOUS_RACK || kProcessMode == PROCESS_MODE_PATCHBAY)
  110. {
  111. uint32_t count = 0;
  112. const EngineEvent* const events = fBuffer;
  113. for (unsigned short i=0; i < kMaxEventCount; i++, count++)
  114. {
  115. if (events[i].type == kEngineEventTypeNull)
  116. break;
  117. }
  118. return count;
  119. }
  120. #endif
  121. return 0;
  122. }
  123. const EngineEvent* CarlaEngineEventPort::getEvent(const uint32_t index)
  124. {
  125. if (! kIsInput)
  126. return nullptr;
  127. CARLA_ASSERT(fBuffer != nullptr);
  128. CARLA_ASSERT(index < kMaxEventCount);
  129. if (fBuffer == nullptr)
  130. return nullptr;
  131. if (index >= kMaxEventCount)
  132. return nullptr;
  133. #ifndef BUILD_BRIDGE
  134. if (kProcessMode == PROCESS_MODE_CONTINUOUS_RACK || kProcessMode == PROCESS_MODE_PATCHBAY)
  135. {
  136. const EngineEvent* const events = fBuffer;
  137. return &events[index];
  138. }
  139. #endif
  140. return nullptr;
  141. }
  142. void CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEventType type, const uint16_t parameter, const double value)
  143. {
  144. if (kIsInput)
  145. return;
  146. CARLA_ASSERT(fBuffer != nullptr);
  147. CARLA_ASSERT(type != kEngineControlEventTypeNull);
  148. CARLA_ASSERT(channel < MAX_MIDI_CHANNELS);
  149. CARLA_ASSERT(value >= 0.0 && value <= 1.0);
  150. if (fBuffer == nullptr)
  151. return;
  152. if (type == kEngineControlEventTypeNull)
  153. return;
  154. if (channel >= MAX_MIDI_CHANNELS)
  155. return;
  156. if (type == kEngineControlEventTypeParameter)
  157. {
  158. CARLA_ASSERT(! MIDI_IS_CONTROL_BANK_SELECT(parameter));
  159. }
  160. #ifndef BUILD_BRIDGE
  161. if (kProcessMode == PROCESS_MODE_CONTINUOUS_RACK || kProcessMode == PROCESS_MODE_PATCHBAY)
  162. {
  163. EngineEvent* const events = fBuffer;
  164. for (unsigned short i=0; i < kMaxEventCount; i++)
  165. {
  166. if (events[i].type != kEngineEventTypeNull)
  167. continue;
  168. events[i].type = kEngineEventTypeControl;
  169. events[i].time = time;
  170. events[i].channel = channel;
  171. events[i].ctrl.type = type;
  172. events[i].ctrl.parameter = parameter;
  173. events[i].ctrl.value = value;
  174. return;
  175. }
  176. qWarning("CarlaEngineEventPort::writeControlEvent() - buffer full");
  177. }
  178. #else
  179. Q_UNUSED(time);
  180. Q_UNUSED(parameter);
  181. Q_UNUSED(value);
  182. #endif
  183. }
  184. void CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t channel, const uint8_t* const data, const uint8_t size)
  185. {
  186. if (kIsInput)
  187. return;
  188. CARLA_ASSERT(fBuffer != nullptr);
  189. CARLA_ASSERT(channel < MAX_MIDI_CHANNELS);
  190. CARLA_ASSERT(data != nullptr);
  191. CARLA_ASSERT(size > 0);
  192. if (fBuffer == nullptr)
  193. return;
  194. if (channel >= MAX_MIDI_CHANNELS)
  195. return;
  196. if (data == nullptr)
  197. return;
  198. if (size == 0)
  199. return;
  200. #ifndef BUILD_BRIDGE
  201. if (kProcessMode == PROCESS_MODE_CONTINUOUS_RACK || kProcessMode == PROCESS_MODE_PATCHBAY)
  202. {
  203. if (size > 3)
  204. return;
  205. EngineEvent* const events = fBuffer;
  206. for (unsigned short i=0; i < kMaxEventCount; i++)
  207. {
  208. if (events[i].type != kEngineEventTypeNull)
  209. continue;
  210. events[i].type = kEngineEventTypeMidi;
  211. events[i].time = time;
  212. events[i].channel = channel;
  213. events[i].midi.data[0] = data[0];
  214. events[i].midi.data[1] = data[1];
  215. events[i].midi.data[2] = data[2];
  216. events[i].midi.size = size;
  217. return;
  218. }
  219. qWarning("CarlaEngineEventPort::writeMidiEvent() - buffer full");
  220. }
  221. #else
  222. Q_UNUSED(time);
  223. #endif
  224. }
  225. // -------------------------------------------------------------------------------------------------------------------
  226. // Carla Engine client (Abstract)
  227. CarlaEngineClient::CarlaEngineClient(const EngineType engineType, const ProcessMode processMode)
  228. : kEngineType(engineType),
  229. kProcessMode(processMode),
  230. fActive(false),
  231. fLatency(0)
  232. {
  233. qDebug("CarlaEngineClient::CarlaEngineClient(%s, %s)", EngineType2Str(engineType), ProcessMode2Str(processMode));
  234. CARLA_ASSERT(engineType != kEngineTypeNull);
  235. }
  236. CarlaEngineClient::~CarlaEngineClient()
  237. {
  238. qDebug("CarlaEngineClient::~CarlaEngineClient()");
  239. CARLA_ASSERT(! fActive);
  240. }
  241. void CarlaEngineClient::activate()
  242. {
  243. qDebug("CarlaEngineClient::activate()");
  244. CARLA_ASSERT(! fActive);
  245. fActive = true;
  246. }
  247. void CarlaEngineClient::deactivate()
  248. {
  249. qDebug("CarlaEngineClient::deactivate()");
  250. CARLA_ASSERT(fActive);
  251. fActive = false;
  252. }
  253. bool CarlaEngineClient::isActive() const
  254. {
  255. qDebug("CarlaEngineClient::isActive()");
  256. return fActive;
  257. }
  258. bool CarlaEngineClient::isOk() const
  259. {
  260. qDebug("CarlaEngineClient::isOk()");
  261. return true;
  262. }
  263. uint32_t CarlaEngineClient::getLatency() const
  264. {
  265. return fLatency;
  266. }
  267. void CarlaEngineClient::setLatency(const uint32_t samples)
  268. {
  269. fLatency = samples;
  270. }
  271. // -------------------------------------------------------------------------------------------------------------------
  272. // Carla Engine
  273. CarlaEngine::CarlaEngine()
  274. : fBufferSize(0),
  275. fSampleRate(0.0),
  276. fData(new CarlaEngineProtectedData(this))
  277. {
  278. qDebug("CarlaEngine::CarlaEngine()");
  279. }
  280. CarlaEngine::~CarlaEngine()
  281. {
  282. qDebug("CarlaEngine::~CarlaEngine()");
  283. //data = nullptr;
  284. }
  285. // -----------------------------------------------------------------------
  286. // Helpers
  287. void doPluginRemove(CarlaEngineProtectedData* const fData, const bool unlock)
  288. {
  289. CARLA_ASSERT(fData->curPluginCount > 0);
  290. fData->curPluginCount--;
  291. const unsigned int id = fData->nextAction.pluginId;
  292. // reset current plugin
  293. fData->plugins[id].plugin = nullptr;
  294. CarlaPlugin* plugin;
  295. // move all plugins 1 spot backwards
  296. for (unsigned int i=id; i < fData->curPluginCount; i++)
  297. {
  298. plugin = fData->plugins[i+1].plugin;
  299. CARLA_ASSERT(plugin);
  300. if (plugin == nullptr)
  301. break;
  302. plugin->setId(i);
  303. fData->plugins[i].plugin = plugin;
  304. fData->plugins[i].insPeak[0] = 0.0f;
  305. fData->plugins[i].insPeak[1] = 0.0f;
  306. fData->plugins[i].outsPeak[0] = 0.0f;
  307. fData->plugins[i].outsPeak[1] = 0.0f;
  308. }
  309. fData->nextAction.opcode = EnginePostActionNull;
  310. if (unlock)
  311. fData->nextAction.mutex.unlock();
  312. }
  313. // -----------------------------------------------------------------------
  314. // Static values and calls
  315. unsigned int CarlaEngine::getDriverCount()
  316. {
  317. qDebug("CarlaEngine::getDriverCount()");
  318. unsigned int count = 0;
  319. #ifdef WANT_JACK
  320. count += 1;
  321. #endif
  322. #ifdef WANT_RTAUDIO
  323. count += getRtAudioApiCount();
  324. #endif
  325. return count;
  326. }
  327. const char* CarlaEngine::getDriverName(unsigned int index)
  328. {
  329. qDebug("CarlaEngine::getDriverName(%i)", index);
  330. #ifdef WANT_JACK
  331. if (index == 0)
  332. return "JACK";
  333. else
  334. index -= 1;
  335. #endif
  336. #ifdef WANT_RTAUDIO
  337. if (index < getRtAudioApiCount())
  338. return getRtAudioApiName(index);
  339. #endif
  340. qWarning("CarlaEngine::getDriverName(%i) - invalid index", index);
  341. return nullptr;
  342. }
  343. CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName)
  344. {
  345. qDebug("CarlaEngine::newDriverByName(\"%s\")", driverName);
  346. #ifdef WANT_JACK
  347. if (strcmp(driverName, "JACK") == 0)
  348. return newJack();
  349. #else
  350. if (false)
  351. pass();
  352. #endif
  353. #ifdef WANT_RTAUDIO
  354. # ifdef __LINUX_ALSA__
  355. else if (strcmp(driverName, "ALSA") == 0)
  356. return newRtAudio(RTAUDIO_LINUX_ALSA);
  357. # endif
  358. # ifdef __LINUX_PULSE__
  359. else if (strcmp(driverName, "PulseAudio") == 0)
  360. return newRtAudio(RTAUDIO_LINUX_PULSE);
  361. # endif
  362. # ifdef __LINUX_OSS__
  363. else if (strcmp(driverName, "OSS") == 0)
  364. return newRtAudio(RTAUDIO_LINUX_OSS);
  365. # endif
  366. # ifdef __UNIX_JACK__
  367. else if (strcmp(driverName, "JACK (RtAudio)") == 0)
  368. return newRtAudio(RTAUDIO_UNIX_JACK);
  369. # endif
  370. # ifdef __MACOSX_CORE__
  371. else if (strcmp(driverName, "CoreAudio") == 0)
  372. return newRtAudio(RTAUDIO_MACOSX_CORE);
  373. # endif
  374. # ifdef __WINDOWS_ASIO__
  375. else if (strcmp(driverName, "ASIO") == 0)
  376. return newRtAudio(RTAUDIO_WINDOWS_ASIO);
  377. # endif
  378. # ifdef __WINDOWS_DS__
  379. else if (strcmp(driverName, "DirectSound") == 0)
  380. return newRtAudio(RTAUDIO_WINDOWS_DS);
  381. # endif
  382. #endif
  383. return nullptr;
  384. }
  385. // -----------------------------------------------------------------------
  386. // Maximum values
  387. unsigned int CarlaEngine::maxClientNameSize() const
  388. {
  389. return STR_MAX/2;
  390. }
  391. unsigned int CarlaEngine::maxPortNameSize() const
  392. {
  393. return STR_MAX;
  394. }
  395. unsigned int CarlaEngine::currentPluginCount() const
  396. {
  397. return fData->curPluginCount;
  398. }
  399. unsigned int CarlaEngine::maxPluginNumber() const
  400. {
  401. return fData->maxPluginNumber;
  402. }
  403. // -----------------------------------------------------------------------
  404. // Virtual, per-engine type calls
  405. bool CarlaEngine::init(const char* const clientName)
  406. {
  407. qDebug("CarlaEngine::init(\"%s\")", clientName);
  408. CARLA_ASSERT(fData->plugins == nullptr);
  409. fName = clientName;
  410. fName.toBasic();
  411. fTimeInfo.clear();
  412. fData->aboutToClose = false;
  413. fData->curPluginCount = 0;
  414. switch (fOptions.processMode)
  415. {
  416. case PROCESS_MODE_CONTINUOUS_RACK:
  417. fData->maxPluginNumber = MAX_RACK_PLUGINS;
  418. break;
  419. case PROCESS_MODE_PATCHBAY:
  420. fData->maxPluginNumber = MAX_PATCHBAY_PLUGINS;
  421. break;
  422. case PROCESS_MODE_BRIDGE:
  423. fData->maxPluginNumber = 1;
  424. break;
  425. default:
  426. fData->maxPluginNumber = MAX_DEFAULT_PLUGINS;
  427. break;
  428. }
  429. fData->plugins = new EnginePluginData[fData->maxPluginNumber];
  430. fData->osc.init(clientName);
  431. #ifndef BUILD_BRIDGE
  432. fData->oscData = fData->osc.getControlData();
  433. #else
  434. fData->oscData = nullptr; // set later in setOscBridgeData()
  435. #endif
  436. #ifndef BUILD_BRIDGE
  437. //if (strcmp(clientName, "Carla") != 0)
  438. carla_setprocname(clientName);
  439. #endif
  440. fData->nextAction.ready();
  441. fData->thread.startNow();
  442. return true;
  443. }
  444. bool CarlaEngine::close()
  445. {
  446. qDebug("CarlaEngine::close()");
  447. CARLA_ASSERT(fData->plugins != nullptr);
  448. fData->nextAction.ready();
  449. fData->thread.stopNow();
  450. #ifndef BUILD_BRIDGE
  451. osc_send_control_exit();
  452. #endif
  453. fData->osc.close();
  454. fData->oscData = nullptr;
  455. fData->aboutToClose = true;
  456. fData->curPluginCount = 0;
  457. fData->maxPluginNumber = 0;
  458. if (fData->plugins != nullptr)
  459. {
  460. delete[] fData->plugins;
  461. fData->plugins = nullptr;
  462. }
  463. fName.clear();
  464. return true;
  465. }
  466. // -----------------------------------------------------------------------
  467. // Plugin management
  468. CarlaPlugin* CarlaEngine::getPlugin(const unsigned int id) const
  469. {
  470. qDebug("CarlaEngine::getPlugin(%i) [count:%i]", id, fData->curPluginCount);
  471. CARLA_ASSERT(fData->curPluginCount > 0);
  472. CARLA_ASSERT(id < fData->curPluginCount);
  473. CARLA_ASSERT(fData->plugins != nullptr);
  474. if (id < fData->curPluginCount && fData->plugins != nullptr)
  475. return fData->plugins[id].plugin;
  476. return nullptr;
  477. }
  478. CarlaPlugin* CarlaEngine::getPluginUnchecked(const unsigned int id) const
  479. {
  480. return fData->plugins[id].plugin;
  481. }
  482. const char* CarlaEngine::getNewUniquePluginName(const char* const name)
  483. {
  484. qDebug("CarlaEngine::getNewUniquePluginName(\"%s\")", name);
  485. CARLA_ASSERT(fData->maxPluginNumber > 0);
  486. CARLA_ASSERT(fData->plugins != nullptr);
  487. CARLA_ASSERT(name != nullptr);
  488. static CarlaString sname;
  489. sname = name;
  490. if (sname.isEmpty() || fData->plugins == nullptr)
  491. return strdup("(No name)");
  492. sname.truncate(maxClientNameSize()-5-1); // 5 = strlen(" (10)")
  493. sname.replace(':', '.'); // ':' is used in JACK1 to split client/port names
  494. for (unsigned short i=0; i < fData->curPluginCount; i++)
  495. {
  496. CARLA_ASSERT(fData->plugins[i].plugin);
  497. // Check if unique name doesn't exist
  498. if (const char* const pluginName = fData->plugins[i].plugin->name())
  499. {
  500. if (sname != pluginName)
  501. continue;
  502. }
  503. // Check if string has already been modified
  504. {
  505. const size_t len = sname.length();
  506. // 1 digit, ex: " (2)"
  507. if (sname[len-4] == ' ' && sname[len-3] == '(' && sname.isDigit(len-2) && sname[len-1] == ')')
  508. {
  509. int number = sname[len-2] - '0';
  510. if (number == 9)
  511. {
  512. // next number is 10, 2 digits
  513. sname.truncate(len-4);
  514. sname += " (10)";
  515. //sname.replace(" (9)", " (10)");
  516. }
  517. else
  518. sname[len-2] = char('0' + number + 1);
  519. continue;
  520. }
  521. // 2 digits, ex: " (11)"
  522. if (sname[len-5] == ' ' && sname[len-4] == '(' && sname.isDigit(len-3) && sname.isDigit(len-2) && sname[len-1] == ')')
  523. {
  524. char n2 = sname[len-2];
  525. char n3 = sname[len-3];
  526. if (n2 == '9')
  527. {
  528. n2 = '0';
  529. n3 = char(n3 + 1);
  530. }
  531. else
  532. n2 = char(n2 + 1);
  533. sname[len-2] = n2;
  534. sname[len-3] = n3;
  535. continue;
  536. }
  537. }
  538. // Modify string if not
  539. sname += " (2)";
  540. }
  541. return (const char*)sname;
  542. }
  543. bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, const void* const extra)
  544. {
  545. qDebug("CarlaEngine::addPlugin(%s, %s, \"%s\", \"%s\", \"%s\", %p)", BinaryType2Str(btype), PluginType2Str(ptype), filename, name, label, extra);
  546. CARLA_ASSERT(btype != BINARY_NONE);
  547. CARLA_ASSERT(ptype != PLUGIN_NONE);
  548. CARLA_ASSERT(filename);
  549. CARLA_ASSERT(label);
  550. if (fData->curPluginCount == fData->maxPluginNumber)
  551. {
  552. setLastError("Maximum number of plugins reached");
  553. return false;
  554. }
  555. const unsigned int id = fData->curPluginCount;
  556. CarlaPlugin::Initializer init = {
  557. this,
  558. id,
  559. filename,
  560. name,
  561. label
  562. };
  563. CarlaPlugin* plugin = nullptr;
  564. #ifndef BUILD_BRIDGE
  565. const char* bridgeBinary;
  566. switch (btype)
  567. {
  568. case BINARY_POSIX32:
  569. bridgeBinary = fOptions.bridge_posix32.isNotEmpty() ? (const char*)fOptions.bridge_posix32 : nullptr;
  570. break;
  571. case BINARY_POSIX64:
  572. bridgeBinary = fOptions.bridge_posix64.isNotEmpty() ? (const char*)fOptions.bridge_posix64 : nullptr;
  573. break;
  574. case BINARY_WIN32:
  575. bridgeBinary = fOptions.bridge_win32.isNotEmpty() ? (const char*)fOptions.bridge_win32 : nullptr;
  576. break;
  577. case BINARY_WIN64:
  578. bridgeBinary = fOptions.bridge_win64.isNotEmpty() ? (const char*)fOptions.bridge_win64 : nullptr;
  579. break;
  580. default:
  581. bridgeBinary = nullptr;
  582. break;
  583. }
  584. #ifndef Q_OS_WIN
  585. if (btype == BINARY_NATIVE && fOptions.bridge_native.isNotEmpty())
  586. bridgeBinary = (const char*)fOptions.bridge_native;
  587. #endif
  588. if (fOptions.preferPluginBridges && bridgeBinary != nullptr)
  589. {
  590. // TODO
  591. if (fOptions.processMode != PROCESS_MODE_MULTIPLE_CLIENTS)
  592. {
  593. setLastError("Can only use bridged plugins in JACK Multi-Client mode");
  594. return -1;
  595. }
  596. // TODO
  597. if (type() != kEngineTypeJack)
  598. {
  599. setLastError("Can only use bridged plugins with JACK backend");
  600. return -1;
  601. }
  602. #if 0
  603. plugin = CarlaPlugin::newBridge(init, btype, ptype, bridgeBinary);
  604. #endif
  605. }
  606. else
  607. #endif // BUILD_BRIDGE
  608. {
  609. switch (ptype)
  610. {
  611. case PLUGIN_NONE:
  612. break;
  613. #ifndef BUILD_BRIDGE
  614. case PLUGIN_INTERNAL:
  615. plugin = CarlaPlugin::newNative(init);
  616. break;
  617. #endif
  618. case PLUGIN_LADSPA:
  619. #ifdef WANT_LADSPA
  620. plugin = CarlaPlugin::newLADSPA(init, (const LADSPA_RDF_Descriptor*)extra);
  621. #endif
  622. break;
  623. #if 0
  624. case PLUGIN_DSSI:
  625. #ifdef WANT_DSSI
  626. plugin = CarlaPlugin::newDSSI(init, extra);
  627. #endif
  628. break;
  629. case PLUGIN_LV2:
  630. #ifdef WANT_LV2
  631. plugin = CarlaPlugin::newLV2(init);
  632. #endif
  633. break;
  634. case PLUGIN_VST:
  635. #ifdef WANT_VST
  636. plugin = CarlaPlugin::newVST(init);
  637. #endif
  638. break;
  639. case PLUGIN_GIG:
  640. #ifdef WANT_LINUXSAMPLER
  641. plugin = CarlaPlugin::newGIG(init);
  642. #endif
  643. break;
  644. case PLUGIN_SF2:
  645. #ifdef WANT_FLUIDSYNTH
  646. plugin = CarlaPlugin::newSF2(init);
  647. #endif
  648. break;
  649. case PLUGIN_SFZ:
  650. #ifdef WANT_LINUXSAMPLER
  651. plugin = CarlaPlugin::newSFZ(init);
  652. #endif
  653. break;
  654. #else
  655. default:
  656. break;
  657. #endif
  658. }
  659. }
  660. if (plugin == nullptr)
  661. return false;
  662. fData->plugins[id].plugin = plugin;
  663. fData->plugins[id].insPeak[0] = 0.0f;
  664. fData->plugins[id].insPeak[1] = 0.0f;
  665. fData->plugins[id].outsPeak[0] = 0.0f;
  666. fData->plugins[id].outsPeak[1] = 0.0f;
  667. fData->curPluginCount++;
  668. // FIXME
  669. //callback(CALLBACK_PLUGIN_ADDED, id, 0, 0, 0.0f, nullptr);
  670. return true;
  671. }
  672. bool CarlaEngine::removePlugin(const unsigned int id)
  673. {
  674. qDebug("CarlaEngine::removePlugin(%i)", id);
  675. CARLA_ASSERT(fData->curPluginCount > 0);
  676. CARLA_ASSERT(id < fData->curPluginCount);
  677. CARLA_ASSERT(fData->plugins != nullptr);
  678. if (fData->plugins == nullptr)
  679. {
  680. setLastError("Critical error: no plugins are currently loaded!");
  681. return false;
  682. }
  683. CarlaPlugin* const plugin = fData->plugins[id].plugin;
  684. CARLA_ASSERT(plugin);
  685. if (plugin)
  686. {
  687. CARLA_ASSERT(plugin->id() == id);
  688. fData->thread.stopNow();
  689. fData->nextAction.pluginId = id;
  690. fData->nextAction.opcode = EnginePostActionRemovePlugin;
  691. fData->nextAction.mutex.lock();
  692. if (isRunning())
  693. {
  694. // block wait for unlock on proccessing side
  695. fData->nextAction.mutex.lock();
  696. }
  697. else
  698. {
  699. doPluginRemove(fData, false);
  700. }
  701. #ifndef BUILD_BRIDGE
  702. if (isOscControlRegistered())
  703. osc_send_control_remove_plugin(id);
  704. #endif
  705. delete plugin;
  706. fData->nextAction.mutex.unlock();
  707. if (isRunning() && ! fData->aboutToClose)
  708. fData->thread.startNow();
  709. return true;
  710. }
  711. qCritical("CarlaEngine::removePlugin(%i) - could not find plugin", id);
  712. setLastError("Could not find plugin to remove");
  713. return false;
  714. }
  715. void CarlaEngine::removeAllPlugins()
  716. {
  717. qDebug("CarlaEngine::removeAllPlugins()");
  718. fData->thread.stopNow();
  719. const unsigned int oldCount = fData->curPluginCount;
  720. // wait for processing
  721. // TODO
  722. fData->curPluginCount = 0;
  723. fData->maxPluginNumber = 0;
  724. for (unsigned short i=0; i < oldCount; i++)
  725. {
  726. CarlaPlugin* const plugin = fData->plugins[i].plugin;
  727. CARLA_ASSERT(plugin);
  728. if (plugin)
  729. delete plugin;
  730. // clear this plugin
  731. fData->plugins[i].plugin = nullptr;
  732. fData->plugins[i].insPeak[0] = 0.0;
  733. fData->plugins[i].insPeak[1] = 0.0;
  734. fData->plugins[i].outsPeak[0] = 0.0;
  735. fData->plugins[i].outsPeak[1] = 0.0;
  736. }
  737. if (isRunning() && ! fData->aboutToClose)
  738. fData->thread.startNow();
  739. }
  740. #if 0
  741. void CarlaEngine::idlePluginGuis()
  742. {
  743. CARLA_ASSERT(data->maxPluginNumber > 0);
  744. for (unsigned short i=0; i < data->maxPluginNumber; i++)
  745. {
  746. CarlaPlugin* const plugin = data->carlaPlugins[i];
  747. if (plugin && plugin->enabled())
  748. plugin->idleGui();
  749. }
  750. }
  751. void CarlaEngine::__bridgePluginRegister(const unsigned short id, CarlaPlugin* const plugin)
  752. {
  753. data->carlaPlugins[id] = plugin;
  754. }
  755. #endif
  756. // -----------------------------------------------------------------------
  757. // Information (base)
  758. void CarlaEngine::setAboutToClose()
  759. {
  760. qDebug("CarlaEngine::setAboutToClose()");
  761. fData->aboutToClose = true;
  762. }
  763. #if 0
  764. // -----------------------------------------------------------------------
  765. // Information (audio peaks)
  766. double CarlaEngine::getInputPeak(const unsigned short pluginId, const unsigned short id) const
  767. {
  768. CARLA_ASSERT(pluginId < data->maxPluginNumber);
  769. CARLA_ASSERT(id < MAX_PEAKS);
  770. return data->insPeak[pluginId*MAX_PEAKS + id];
  771. }
  772. double CarlaEngine::getOutputPeak(const unsigned short pluginId, const unsigned short id) const
  773. {
  774. CARLA_ASSERT(pluginId < data->maxPluginNumber);
  775. CARLA_ASSERT(id < MAX_PEAKS);
  776. return data->outsPeak[pluginId*MAX_PEAKS + id];
  777. }
  778. void CarlaEngine::setInputPeak(const unsigned short pluginId, const unsigned short id, double value)
  779. {
  780. CARLA_ASSERT(pluginId < data->maxPluginNumber);
  781. CARLA_ASSERT(id < MAX_PEAKS);
  782. data->insPeak[pluginId*MAX_PEAKS + id] = value;
  783. }
  784. void CarlaEngine::setOutputPeak(const unsigned short pluginId, const unsigned short id, double value)
  785. {
  786. CARLA_ASSERT(pluginId < data->maxPluginNumber);
  787. CARLA_ASSERT(id < MAX_PEAKS);
  788. data->outsPeak[pluginId*MAX_PEAKS + id] = value;
  789. }
  790. #endif
  791. // -----------------------------------------------------------------------
  792. // Callback
  793. void CarlaEngine::callback(const CallbackType action, const unsigned short pluginId, const int value1, const int value2, const float value3, const char* const valueStr)
  794. {
  795. qDebug("CarlaEngine::callback(%s, %i, %i, %i, %f, \"%s\")", CallbackType2Str(action), pluginId, value1, value2, value3, valueStr);
  796. if (fData->callback)
  797. fData->callback(fData->callbackPtr, action, pluginId, value1, value2, value3, valueStr);
  798. }
  799. void CarlaEngine::setCallback(const CallbackFunc func, void* const ptr)
  800. {
  801. qDebug("CarlaEngine::setCallback(%p, %p)", func, ptr);
  802. CARLA_ASSERT(func);
  803. fData->callback = func;
  804. fData->callbackPtr = ptr;
  805. }
  806. // -----------------------------------------------------------------------
  807. // Error handling
  808. const char* CarlaEngine::getLastError() const
  809. {
  810. return (const char*)fData->lastError;
  811. }
  812. void CarlaEngine::setLastError(const char* const error)
  813. {
  814. fData->lastError = error;
  815. }
  816. // -----------------------------------------------------------------------
  817. // Global options
  818. #ifndef BUILD_BRIDGE
  819. const QProcessEnvironment& CarlaEngine::getOptionsAsProcessEnvironment() const
  820. {
  821. return fData->procEnv;
  822. }
  823. #define CARLA_ENGINE_SET_OPTION_RUNNING_CHECK \
  824. if (isRunning()) \
  825. return qCritical("CarlaEngine::setOption(%s, %i, \"%s\") - Cannot set this option while engine is running!", OptionsType2Str(option), value, valueStr);
  826. void CarlaEngine::setOption(const OptionsType option, const int value, const char* const valueStr)
  827. {
  828. qDebug("CarlaEngine::setOption(%s, %i, \"%s\")", OptionsType2Str(option), value, valueStr);
  829. switch (option)
  830. {
  831. case OPTION_PROCESS_NAME:
  832. carla_setprocname(valueStr);
  833. break;
  834. case OPTION_PROCESS_MODE:
  835. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  836. if (value < PROCESS_MODE_SINGLE_CLIENT || value > PROCESS_MODE_PATCHBAY)
  837. return qCritical("CarlaEngine::setOption(%s, %i, \"%s\") - invalid value", OptionsType2Str(option), value, valueStr);
  838. fOptions.processMode = static_cast<ProcessMode>(value);
  839. break;
  840. case OPTION_MAX_PARAMETERS:
  841. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  842. if (value < 0)
  843. return; // TODO error here
  844. fOptions.maxParameters = static_cast<uint>(value);
  845. break;
  846. case OPTION_PREFERRED_BUFFER_SIZE:
  847. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  848. fOptions.preferredBufferSize = static_cast<uint>(value);
  849. break;
  850. case OPTION_PREFERRED_SAMPLE_RATE:
  851. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  852. fOptions.preferredSampleRate = static_cast<uint>(value);
  853. break;
  854. case OPTION_FORCE_STEREO:
  855. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  856. fOptions.forceStereo = (value != 0);
  857. break;
  858. #ifdef WANT_DSSI
  859. case OPTION_USE_DSSI_VST_CHUNKS:
  860. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  861. fOptions.useDssiVstChunks = (value != 0);
  862. break;
  863. #endif
  864. case OPTION_PREFER_PLUGIN_BRIDGES:
  865. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  866. fOptions.preferPluginBridges = (value != 0);
  867. break;
  868. case OPTION_PREFER_UI_BRIDGES:
  869. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  870. fOptions.preferUiBridges = (value != 0);
  871. break;
  872. case OPTION_OSC_UI_TIMEOUT:
  873. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  874. fOptions.oscUiTimeout = static_cast<uint>(value);
  875. break;
  876. case OPTION_PATH_BRIDGE_NATIVE:
  877. fOptions.bridge_native = valueStr;
  878. break;
  879. case OPTION_PATH_BRIDGE_POSIX32:
  880. fOptions.bridge_posix32 = valueStr;
  881. break;
  882. case OPTION_PATH_BRIDGE_POSIX64:
  883. fOptions.bridge_posix64 = valueStr;
  884. break;
  885. case OPTION_PATH_BRIDGE_WIN32:
  886. fOptions.bridge_win32 = valueStr;
  887. break;
  888. case OPTION_PATH_BRIDGE_WIN64:
  889. fOptions.bridge_win64 = valueStr;
  890. break;
  891. #ifdef WANT_LV2
  892. case OPTION_PATH_BRIDGE_LV2_GTK2:
  893. fOptions.bridge_lv2gtk2 = valueStr;
  894. break;
  895. case OPTION_PATH_BRIDGE_LV2_GTK3:
  896. fOptions.bridge_lv2gtk3 = valueStr;
  897. break;
  898. case OPTION_PATH_BRIDGE_LV2_QT4:
  899. fOptions.bridge_lv2qt4 = valueStr;
  900. break;
  901. case OPTION_PATH_BRIDGE_LV2_QT5:
  902. fOptions.bridge_lv2qt5 = valueStr;
  903. break;
  904. case OPTION_PATH_BRIDGE_LV2_COCOA:
  905. fOptions.bridge_lv2cocoa = valueStr;
  906. break;
  907. case OPTION_PATH_BRIDGE_LV2_WINDOWS:
  908. fOptions.bridge_lv2win = valueStr;
  909. break;
  910. case OPTION_PATH_BRIDGE_LV2_X11:
  911. fOptions.bridge_lv2x11 = valueStr;
  912. break;
  913. #endif
  914. #ifdef WANT_VST
  915. case OPTION_PATH_BRIDGE_VST_COCOA:
  916. fOptions.bridge_vstcocoa = valueStr;
  917. break;
  918. case OPTION_PATH_BRIDGE_VST_HWND:
  919. fOptions.bridge_vsthwnd = valueStr;
  920. break;
  921. case OPTION_PATH_BRIDGE_VST_X11:
  922. fOptions.bridge_vstx11 = valueStr;
  923. break;
  924. #endif
  925. }
  926. }
  927. #endif
  928. // -----------------------------------------------------------------------
  929. // OSC Stuff
  930. #ifdef BUILD_BRIDGE
  931. bool CarlaEngine::isOscBridgeRegistered() const
  932. {
  933. return (fData->oscData != nullptr);
  934. }
  935. #else
  936. bool CarlaEngine::isOscControlRegistered() const
  937. {
  938. return fData->osc.isControlRegistered();
  939. }
  940. #endif
  941. void CarlaEngine::idleOsc()
  942. {
  943. fData->osc.idle();
  944. }
  945. const char* CarlaEngine::getOscServerPathTCP() const
  946. {
  947. return fData->osc.getServerPathTCP();
  948. }
  949. const char* CarlaEngine::getOscServerPathUDP() const
  950. {
  951. return fData->osc.getServerPathUDP();
  952. }
  953. #ifdef BUILD_BRIDGE
  954. void CarlaEngine::setOscBridgeData(const CarlaOscData* const oscData)
  955. {
  956. fData->oscData = oscData;
  957. }
  958. #endif
  959. // -----------------------------------------------------------------------
  960. // protected calls
  961. void CarlaEngine::bufferSizeChanged(const uint32_t newBufferSize)
  962. {
  963. qDebug("CarlaEngine::bufferSizeChanged(%i)", newBufferSize);
  964. #if 0
  965. for (unsigned short i=0; i < data->maxPluginNumber; i++)
  966. {
  967. if (data->carlaPlugins[i] && data->carlaPlugins[i]->enabled() /*&& ! data->carlaPlugins[i]->data->processHighPrecision*/)
  968. data->carlaPlugins[i]->bufferSizeChanged(newBufferSize);
  969. }
  970. #endif
  971. }
  972. void CarlaEngine::sampleRateChanged(const double newSampleRate)
  973. {
  974. qDebug("CarlaEngine::sampleRateChanged(%g)", newSampleRate);
  975. // TODO
  976. }
  977. void CarlaEngine::proccessPendingEvents()
  978. {
  979. switch (fData->nextAction.opcode)
  980. {
  981. case EnginePostActionNull:
  982. break;
  983. case EnginePostActionRemovePlugin:
  984. doPluginRemove(fData, true);
  985. break;
  986. }
  987. // TODO - peak values
  988. }
  989. #ifndef BUILD_BRIDGE
  990. EngineEvent* CarlaEngine::getRackEventBuffer(const bool isInput)
  991. {
  992. // TODO
  993. return nullptr;
  994. }
  995. void CarlaEngine::processRack(float* inBuf[2], float* outBuf[2], const uint32_t frames)
  996. {
  997. // initialize outputs (zero)
  998. carla_zeroFloat(outBuf[0], frames);
  999. carla_zeroFloat(outBuf[1], frames);
  1000. //std::memset(rackEventsOut, 0, sizeof(EngineEvent)*MAX_EVENTS);
  1001. bool processed = false;
  1002. // process plugins
  1003. for (unsigned int i=0; i < fData->curPluginCount; i++)
  1004. {
  1005. CarlaPlugin* const plugin = getPluginUnchecked(i);
  1006. if (plugin == nullptr || ! plugin->enabled())
  1007. continue;
  1008. #if 0
  1009. if (processed)
  1010. {
  1011. // initialize inputs (from previous outputs)
  1012. memcpy(inBuf[0], outBuf[0], sizeof(float)*frames);
  1013. memcpy(inBuf[1], outBuf[1], sizeof(float)*frames);
  1014. memcpy(rackMidiEventsIn, rackMidiEventsOut, sizeof(CarlaEngineMidiEvent)*MAX_MIDI_EVENTS);
  1015. // initialize outputs (zero)
  1016. carla_zeroFloat(outBuf[0], frames);
  1017. carla_zeroFloat(outBuf[1], frames);
  1018. memset(rackMidiEventsOut, 0, sizeof(CarlaEngineMidiEvent)*MAX_MIDI_EVENTS);
  1019. }
  1020. // process
  1021. processLock();
  1022. plugin->initBuffers();
  1023. if (false /*plugin->data->processHighPrecision*/)
  1024. {
  1025. float* inBuf2[2];
  1026. float* outBuf2[2];
  1027. for (uint32_t j=0; j < frames; j += 8)
  1028. {
  1029. inBuf2[0] = inBuf[0] + j;
  1030. inBuf2[1] = inBuf[1] + j;
  1031. outBuf2[0] = outBuf[0] + j;
  1032. outBuf2[1] = outBuf[1] + j;
  1033. plugin->process(inBuf2, outBuf2, 8, j);
  1034. }
  1035. }
  1036. else
  1037. plugin->process(inBuf, outBuf, frames);
  1038. processUnlock();
  1039. // if plugin has no audio inputs, add previous buffers
  1040. if (plugin->audioInCount() == 0)
  1041. {
  1042. for (uint32_t j=0; j < frames; j++)
  1043. {
  1044. outBuf[0][j] += inBuf[0][j];
  1045. outBuf[1][j] += inBuf[1][j];
  1046. }
  1047. }
  1048. // if plugin has no midi output, add previous midi input
  1049. if (plugin->midiOutCount() == 0)
  1050. {
  1051. memcpy(rackMidiEventsOut, rackMidiEventsIn, sizeof(CarlaEngineMidiEvent)*MAX_MIDI_EVENTS);
  1052. }
  1053. // set peaks
  1054. {
  1055. double inPeak1 = 0.0;
  1056. double inPeak2 = 0.0;
  1057. double outPeak1 = 0.0;
  1058. double outPeak2 = 0.0;
  1059. for (uint32_t k=0; k < frames; k++)
  1060. {
  1061. // TODO - optimize this
  1062. if (std::abs(inBuf[0][k]) > inPeak1)
  1063. inPeak1 = std::abs(inBuf[0][k]);
  1064. if (std::abs(inBuf[1][k]) > inPeak2)
  1065. inPeak2 = std::abs(inBuf[1][k]);
  1066. if (std::abs(outBuf[0][k]) > outPeak1)
  1067. outPeak1 = std::abs(outBuf[0][k]);
  1068. if (std::abs(outBuf[1][k]) > outPeak2)
  1069. outPeak2 = std::abs(outBuf[1][k]);
  1070. }
  1071. data->insPeak[i*MAX_PEAKS + 0] = inPeak1;
  1072. data->insPeak[i*MAX_PEAKS + 1] = inPeak2;
  1073. data->outsPeak[i*MAX_PEAKS + 0] = outPeak1;
  1074. data->outsPeak[i*MAX_PEAKS + 1] = outPeak2;
  1075. }
  1076. #endif
  1077. processed = true;
  1078. }
  1079. // if no plugins in the rack, copy inputs over outputs
  1080. if (! processed)
  1081. {
  1082. std::memcpy(outBuf[0], inBuf[0], sizeof(float)*frames);
  1083. std::memcpy(outBuf[1], inBuf[1], sizeof(float)*frames);
  1084. //std::memcpy(rackEventsOut, rackEventsIn, sizeof(EngineEvent)*MAX_EVENTS);
  1085. }
  1086. }
  1087. void CarlaEngine::processPatchbay(float** inBuf, float** outBuf, const uint32_t bufCount[2], const uint32_t frames)
  1088. {
  1089. // TODO
  1090. Q_UNUSED(inBuf);
  1091. Q_UNUSED(outBuf);
  1092. Q_UNUSED(bufCount);
  1093. Q_UNUSED(frames);
  1094. }
  1095. #endif
  1096. // -------------------------------------------------------------------------------------------------------------------
  1097. // Carla Engine OSC stuff
  1098. #ifdef BUILD_BRIDGE
  1099. void CarlaEngine::osc_send_peaks(CarlaPlugin* const /*plugin*/)
  1100. #else
  1101. void CarlaEngine::osc_send_peaks(CarlaPlugin* const plugin, const unsigned short& id)
  1102. #endif
  1103. {
  1104. #if 0
  1105. // Peak values
  1106. if (plugin->audioInCount() > 0)
  1107. {
  1108. #ifdef BUILD_BRIDGE
  1109. osc_send_bridge_set_inpeak(1);
  1110. osc_send_bridge_set_inpeak(2);
  1111. #else
  1112. osc_send_control_set_input_peak_value(id, 1);
  1113. osc_send_control_set_input_peak_value(id, 2);
  1114. #endif
  1115. }
  1116. if (plugin->audioOutCount() > 0)
  1117. {
  1118. #ifdef BUILD_BRIDGE
  1119. osc_send_bridge_set_outpeak(1);
  1120. osc_send_bridge_set_outpeak(2);
  1121. #else
  1122. osc_send_control_set_output_peak_value(id, 1);
  1123. osc_send_control_set_output_peak_value(id, 2);
  1124. #endif
  1125. }
  1126. #endif
  1127. }
  1128. #ifndef BUILD_BRIDGE
  1129. void CarlaEngine::osc_send_control_add_plugin_start(const int32_t pluginId, const char* const pluginName)
  1130. {
  1131. qDebug("CarlaEngine::osc_send_control_add_plugin_start(%i, \"%s\")", pluginId, pluginName);
  1132. CARLA_ASSERT(fData->oscData != nullptr);
  1133. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1134. CARLA_ASSERT(pluginName);
  1135. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1136. {
  1137. char target_path[strlen(fData->oscData->path)+18];
  1138. strcpy(target_path, fData->oscData->path);
  1139. strcat(target_path, "/add_plugin_start");
  1140. lo_send(fData->oscData->target, target_path, "is", pluginId, pluginName);
  1141. }
  1142. }
  1143. void CarlaEngine::osc_send_control_add_plugin_end(const int32_t pluginId)
  1144. {
  1145. qDebug("CarlaEngine::osc_send_control_add_plugin_end(%i)", pluginId);
  1146. CARLA_ASSERT(fData->oscData != nullptr);
  1147. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1148. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1149. {
  1150. char target_path[strlen(fData->oscData->path)+16];
  1151. strcpy(target_path, fData->oscData->path);
  1152. strcat(target_path, "/add_plugin_end");
  1153. lo_send(fData->oscData->target, target_path, "i", pluginId);
  1154. }
  1155. }
  1156. void CarlaEngine::osc_send_control_remove_plugin(const int32_t pluginId)
  1157. {
  1158. qDebug("CarlaEngine::osc_send_control_remove_plugin(%i)", pluginId);
  1159. CARLA_ASSERT(fData->oscData != nullptr);
  1160. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1161. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1162. {
  1163. char target_path[strlen(fData->oscData->path)+15];
  1164. strcpy(target_path, fData->oscData->path);
  1165. strcat(target_path, "/remove_plugin");
  1166. lo_send(fData->oscData->target, target_path, "i", pluginId);
  1167. }
  1168. }
  1169. void CarlaEngine::osc_send_control_set_plugin_data(const int32_t pluginId, const int32_t type, const int32_t category, const int32_t hints, const char* const realName, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId)
  1170. {
  1171. qDebug("CarlaEngine::osc_send_control_set_plugin_data(%i, %i, %i, %i, \"%s\", \"%s\", \"%s\", \"%s\", " P_INT64 ")", pluginId, type, category, hints, realName, label, maker, copyright, uniqueId);
  1172. CARLA_ASSERT(fData->oscData != nullptr);
  1173. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1174. CARLA_ASSERT(type != PLUGIN_NONE);
  1175. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1176. {
  1177. char target_path[strlen(fData->oscData->path)+17];
  1178. strcpy(target_path, fData->oscData->path);
  1179. strcat(target_path, "/set_plugin_data");
  1180. lo_send(fData->oscData->target, target_path, "iiiissssh", pluginId, type, category, hints, realName, label, maker, copyright, uniqueId);
  1181. }
  1182. }
  1183. void CarlaEngine::osc_send_control_set_plugin_ports(const int32_t pluginId, const int32_t audioIns, const int32_t audioOuts, const int32_t midiIns, const int32_t midiOuts, const int32_t cIns, const int32_t cOuts, const int32_t cTotals)
  1184. {
  1185. qDebug("CarlaEngine::osc_send_control_set_plugin_ports(%i, %i, %i, %i, %i, %i, %i, %i)", pluginId, audioIns, audioOuts, midiIns, midiOuts, cIns, cOuts, cTotals);
  1186. CARLA_ASSERT(fData->oscData != nullptr);
  1187. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1188. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1189. {
  1190. char target_path[strlen(fData->oscData->path)+18];
  1191. strcpy(target_path, fData->oscData->path);
  1192. strcat(target_path, "/set_plugin_ports");
  1193. lo_send(fData->oscData->target, target_path, "iiiiiiii", pluginId, audioIns, audioOuts, midiIns, midiOuts, cIns, cOuts, cTotals);
  1194. }
  1195. }
  1196. void CarlaEngine::osc_send_control_set_parameter_data(const int32_t pluginId, const int32_t index, const int32_t type, const int32_t hints, const char* const name, const char* const label, const double current)
  1197. {
  1198. qDebug("CarlaEngine::osc_send_control_set_parameter_data(%i, %i, %i, %i, \"%s\", \"%s\", %g)", pluginId, index, type, hints, name, label, current);
  1199. CARLA_ASSERT(fData->oscData != nullptr);
  1200. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1201. CARLA_ASSERT(index >= 0);
  1202. CARLA_ASSERT(type != PARAMETER_UNKNOWN);
  1203. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1204. {
  1205. char target_path[strlen(fData->oscData->path)+20];
  1206. strcpy(target_path, fData->oscData->path);
  1207. strcat(target_path, "/set_parameter_data");
  1208. lo_send(fData->oscData->target, target_path, "iiiissd", pluginId, index, type, hints, name, label, current);
  1209. }
  1210. }
  1211. void CarlaEngine::osc_send_control_set_parameter_ranges(const int32_t pluginId, const int32_t index, const double min, const double max, const double def, const double step, const double stepSmall, const double stepLarge)
  1212. {
  1213. qDebug("CarlaEngine::osc_send_control_set_parameter_ranges(%i, %i, %g, %g, %g, %g, %g, %g)", pluginId, index, min, max, def, step, stepSmall, stepLarge);
  1214. CARLA_ASSERT(fData->oscData != nullptr);
  1215. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1216. CARLA_ASSERT(index >= 0);
  1217. CARLA_ASSERT(min < max);
  1218. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1219. {
  1220. char target_path[strlen(fData->oscData->path)+22];
  1221. strcpy(target_path, fData->oscData->path);
  1222. strcat(target_path, "/set_parameter_ranges");
  1223. lo_send(fData->oscData->target, target_path, "iidddddd", pluginId, index, min, max, def, step, stepSmall, stepLarge);
  1224. }
  1225. }
  1226. void CarlaEngine::osc_send_control_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc)
  1227. {
  1228. qDebug("CarlaEngine::osc_send_control_set_parameter_midi_cc(%i, %i, %i)", pluginId, index, cc);
  1229. CARLA_ASSERT(fData->oscData != nullptr);
  1230. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1231. CARLA_ASSERT(index >= 0);
  1232. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1233. {
  1234. char target_path[strlen(fData->oscData->path)+23];
  1235. strcpy(target_path, fData->oscData->path);
  1236. strcat(target_path, "/set_parameter_midi_cc");
  1237. lo_send(fData->oscData->target, target_path, "iii", pluginId, index, cc);
  1238. }
  1239. }
  1240. void CarlaEngine::osc_send_control_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel)
  1241. {
  1242. qDebug("CarlaEngine::osc_send_control_set_parameter_midi_channel(%i, %i, %i)", pluginId, index, channel);
  1243. CARLA_ASSERT(fData->oscData != nullptr);
  1244. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1245. CARLA_ASSERT(index >= 0);
  1246. CARLA_ASSERT(channel >= 0 && channel < 16);
  1247. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1248. {
  1249. char target_path[strlen(fData->oscData->path)+28];
  1250. strcpy(target_path, fData->oscData->path);
  1251. strcat(target_path, "/set_parameter_midi_channel");
  1252. lo_send(fData->oscData->target, target_path, "iii", pluginId, index, channel);
  1253. }
  1254. }
  1255. void CarlaEngine::osc_send_control_set_parameter_value(const int32_t pluginId, const int32_t index, const double value)
  1256. {
  1257. #if DEBUG
  1258. if (index < 0)
  1259. qDebug("CarlaEngine::osc_send_control_set_parameter_value(%i, %s, %g)", pluginId, InternalParametersIndex2Str((InternalParametersIndex)index), value);
  1260. else
  1261. qDebug("CarlaEngine::osc_send_control_set_parameter_value(%i, %i, %g)", pluginId, index, value);
  1262. #endif
  1263. CARLA_ASSERT(fData->oscData != nullptr);
  1264. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1265. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1266. {
  1267. char target_path[strlen(fData->oscData->path)+21];
  1268. strcpy(target_path, fData->oscData->path);
  1269. strcat(target_path, "/set_parameter_value");
  1270. lo_send(fData->oscData->target, target_path, "iid", pluginId, index, value);
  1271. }
  1272. }
  1273. void CarlaEngine::osc_send_control_set_default_value(const int32_t pluginId, const int32_t index, const double value)
  1274. {
  1275. qDebug("CarlaEngine::osc_send_control_set_default_value(%i, %i, %g)", pluginId, index, value);
  1276. CARLA_ASSERT(fData->oscData != nullptr);
  1277. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1278. CARLA_ASSERT(index >= 0);
  1279. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1280. {
  1281. char target_path[strlen(fData->oscData->path)+19];
  1282. strcpy(target_path, fData->oscData->path);
  1283. strcat(target_path, "/set_default_value");
  1284. lo_send(fData->oscData->target, target_path, "iid", pluginId, index, value);
  1285. }
  1286. }
  1287. void CarlaEngine::osc_send_control_set_program(const int32_t pluginId, const int32_t index)
  1288. {
  1289. qDebug("CarlaEngine::osc_send_control_set_program(%i, %i)", pluginId, index);
  1290. CARLA_ASSERT(fData->oscData != nullptr);
  1291. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1292. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1293. {
  1294. char target_path[strlen(fData->oscData->path)+13];
  1295. strcpy(target_path, fData->oscData->path);
  1296. strcat(target_path, "/set_program");
  1297. lo_send(fData->oscData->target, target_path, "ii", pluginId, index);
  1298. }
  1299. }
  1300. void CarlaEngine::osc_send_control_set_program_count(const int32_t pluginId, const int32_t count)
  1301. {
  1302. qDebug("CarlaEngine::osc_send_control_set_program_count(%i, %i)", pluginId, count);
  1303. CARLA_ASSERT(fData->oscData != nullptr);
  1304. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1305. CARLA_ASSERT(count >= 0);
  1306. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1307. {
  1308. char target_path[strlen(fData->oscData->path)+19];
  1309. strcpy(target_path, fData->oscData->path);
  1310. strcat(target_path, "/set_program_count");
  1311. lo_send(fData->oscData->target, target_path, "ii", pluginId, count);
  1312. }
  1313. }
  1314. void CarlaEngine::osc_send_control_set_program_name(const int32_t pluginId, const int32_t index, const char* const name)
  1315. {
  1316. qDebug("CarlaEngine::osc_send_control_set_program_name(%i, %i, \"%s\")", pluginId, index, name);
  1317. CARLA_ASSERT(fData->oscData != nullptr);
  1318. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1319. CARLA_ASSERT(index >= 0);
  1320. CARLA_ASSERT(name);
  1321. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1322. {
  1323. char target_path[strlen(fData->oscData->path)+18];
  1324. strcpy(target_path, fData->oscData->path);
  1325. strcat(target_path, "/set_program_name");
  1326. lo_send(fData->oscData->target, target_path, "iis", pluginId, index, name);
  1327. }
  1328. }
  1329. void CarlaEngine::osc_send_control_set_midi_program(const int32_t pluginId, const int32_t index)
  1330. {
  1331. qDebug("CarlaEngine::osc_send_control_set_midi_program(%i, %i)", pluginId, index);
  1332. CARLA_ASSERT(fData->oscData != nullptr);
  1333. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1334. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1335. {
  1336. char target_path[strlen(fData->oscData->path)+18];
  1337. strcpy(target_path, fData->oscData->path);
  1338. strcat(target_path, "/set_midi_program");
  1339. lo_send(fData->oscData->target, target_path, "ii", pluginId, index);
  1340. }
  1341. }
  1342. void CarlaEngine::osc_send_control_set_midi_program_count(const int32_t pluginId, const int32_t count)
  1343. {
  1344. qDebug("CarlaEngine::osc_send_control_set_midi_program_count(%i, %i)", pluginId, count);
  1345. CARLA_ASSERT(fData->oscData != nullptr);
  1346. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1347. CARLA_ASSERT(count >= 0);
  1348. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1349. {
  1350. char target_path[strlen(fData->oscData->path)+24];
  1351. strcpy(target_path, fData->oscData->path);
  1352. strcat(target_path, "/set_midi_program_count");
  1353. lo_send(fData->oscData->target, target_path, "ii", pluginId, count);
  1354. }
  1355. }
  1356. void CarlaEngine::osc_send_control_set_midi_program_data(const int32_t pluginId, const int32_t index, const int32_t bank, const int32_t program, const char* const name)
  1357. {
  1358. qDebug("CarlaEngine::osc_send_control_set_midi_program_data(%i, %i, %i, %i, \"%s\")", pluginId, index, bank, program, name);
  1359. CARLA_ASSERT(fData->oscData != nullptr);
  1360. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1361. CARLA_ASSERT(index >= 0);
  1362. CARLA_ASSERT(bank >= 0);
  1363. CARLA_ASSERT(program >= 0);
  1364. CARLA_ASSERT(name);
  1365. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1366. {
  1367. char target_path[strlen(fData->oscData->path)+23];
  1368. strcpy(target_path, fData->oscData->path);
  1369. strcat(target_path, "/set_midi_program_data");
  1370. lo_send(fData->oscData->target, target_path, "iiiis", pluginId, index, bank, program, name);
  1371. }
  1372. }
  1373. void CarlaEngine::osc_send_control_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo)
  1374. {
  1375. qDebug("CarlaEngine::osc_send_control_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo);
  1376. CARLA_ASSERT(fData->oscData != nullptr);
  1377. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1378. CARLA_ASSERT(channel >= 0 && channel < 16);
  1379. CARLA_ASSERT(note >= 0 && note < 128);
  1380. CARLA_ASSERT(velo > 0 && velo < 128);
  1381. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1382. {
  1383. char target_path[strlen(fData->oscData->path)+9];
  1384. strcpy(target_path, fData->oscData->path);
  1385. strcat(target_path, "/note_on");
  1386. lo_send(fData->oscData->target, target_path, "iiii", pluginId, channel, note, velo);
  1387. }
  1388. }
  1389. void CarlaEngine::osc_send_control_note_off(const int32_t pluginId, const int32_t channel, const int32_t note)
  1390. {
  1391. qDebug("CarlaEngine::osc_send_control_note_off(%i, %i, %i)", pluginId, channel, note);
  1392. CARLA_ASSERT(fData->oscData != nullptr);
  1393. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1394. CARLA_ASSERT(channel >= 0 && channel < 16);
  1395. CARLA_ASSERT(note >= 0 && note < 128);
  1396. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1397. {
  1398. char target_path[strlen(fData->oscData->path)+10];
  1399. strcpy(target_path, fData->oscData->path);
  1400. strcat(target_path, "/note_off");
  1401. lo_send(fData->oscData->target, target_path, "iii", pluginId, channel, note);
  1402. }
  1403. }
  1404. #if 0
  1405. void CarlaEngine::osc_send_control_set_input_peak_value(const int32_t pluginId, const int32_t portId)
  1406. {
  1407. //qDebug("CarlaEngine::osc_send_control_set_input_peak_value(%i, %i)", pluginId, portId);
  1408. CARLA_ASSERT(fData->oscData != nullptr);
  1409. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1410. CARLA_ASSERT(portId == 1 || portId == 2);
  1411. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1412. {
  1413. char target_path[strlen(fData->oscData->path)+22];
  1414. strcpy(target_path, fData->oscData->path);
  1415. strcat(target_path, "/set_input_peak_value");
  1416. lo_send(fData->oscData->target, target_path, "iid", pluginId, portId, data->insPeak[pluginId*MAX_PEAKS + portId-1]);
  1417. }
  1418. }
  1419. void CarlaEngine::osc_send_control_set_output_peak_value(const int32_t pluginId, const int32_t portId)
  1420. {
  1421. //qDebug("CarlaEngine::osc_send_control_set_output_peak_value(%i, %i)", pluginId, portId);
  1422. CARLA_ASSERT(fData->oscData != nullptr);
  1423. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1424. CARLA_ASSERT(portId == 1 || portId == 2);
  1425. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1426. {
  1427. char target_path[strlen(fData->oscData->path)+23];
  1428. strcpy(target_path, fData->oscData->path);
  1429. strcat(target_path, "/set_output_peak_value");
  1430. lo_send(fData->oscData->target, target_path, "iid", pluginId, portId, data->outsPeak[pluginId*MAX_PEAKS + portId-1]);
  1431. }
  1432. }
  1433. #endif
  1434. void CarlaEngine::osc_send_control_exit()
  1435. {
  1436. qDebug("CarlaEngine::osc_send_control_exit()");
  1437. CARLA_ASSERT(fData->oscData);
  1438. if (fData->oscData && fData->oscData->target)
  1439. {
  1440. char target_path[strlen(fData->oscData->path)+6];
  1441. strcpy(target_path, fData->oscData->path);
  1442. strcat(target_path, "/exit");
  1443. lo_send(fData->oscData->target, target_path, "");
  1444. }
  1445. }
  1446. #else
  1447. void CarlaEngine::osc_send_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total)
  1448. {
  1449. qDebug("CarlaEngine::osc_send_bridge_audio_count(%i, %i, %i)", ins, outs, total);
  1450. CARLA_ASSERT(fData->oscData != nullptr);
  1451. CARLA_ASSERT(total >= 0 && total >= ins + outs);
  1452. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1453. {
  1454. char target_path[strlen(fData->oscData->path)+20];
  1455. strcpy(target_path, fData->oscData->path);
  1456. strcat(target_path, "/bridge_audio_count");
  1457. lo_send(fData->oscData->target, target_path, "iii", ins, outs, total);
  1458. }
  1459. }
  1460. void CarlaEngine::osc_send_bridge_midi_count(const int32_t ins, const int32_t outs, const int32_t total)
  1461. {
  1462. qDebug("CarlaEngine::osc_send_bridge_midi_count(%i, %i, %i)", ins, outs, total);
  1463. CARLA_ASSERT(fData->oscData != nullptr);
  1464. CARLA_ASSERT(total >= 0 && total >= ins + outs);
  1465. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1466. {
  1467. char target_path[strlen(fData->oscData->path)+19];
  1468. strcpy(target_path, fData->oscData->path);
  1469. strcat(target_path, "/bridge_midi_count");
  1470. lo_send(fData->oscData->target, target_path, "iii", ins, outs, total);
  1471. }
  1472. }
  1473. void CarlaEngine::osc_send_bridge_parameter_count(const int32_t ins, const int32_t outs, const int32_t total)
  1474. {
  1475. qDebug("CarlaEngine::osc_send_bridge_parameter_count(%i, %i, %i)", ins, outs, total);
  1476. CARLA_ASSERT(fData->oscData != nullptr);
  1477. CARLA_ASSERT(total >= 0 && total >= ins + outs);
  1478. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1479. {
  1480. char target_path[strlen(fData->oscData->path)+24];
  1481. strcpy(target_path, fData->oscData->path);
  1482. strcat(target_path, "/bridge_parameter_count");
  1483. lo_send(fData->oscData->target, target_path, "iii", ins, outs, total);
  1484. }
  1485. }
  1486. void CarlaEngine::osc_send_bridge_program_count(const int32_t count)
  1487. {
  1488. qDebug("CarlaEngine::osc_send_bridge_program_count(%i)", count);
  1489. CARLA_ASSERT(fData->oscData != nullptr);
  1490. CARLA_ASSERT(count >= 0);
  1491. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1492. {
  1493. char target_path[strlen(fData->oscData->path)+22];
  1494. strcpy(target_path, fData->oscData->path);
  1495. strcat(target_path, "/bridge_program_count");
  1496. lo_send(fData->oscData->target, target_path, "i", count);
  1497. }
  1498. }
  1499. void CarlaEngine::osc_send_bridge_midi_program_count(const int32_t count)
  1500. {
  1501. qDebug("CarlaEngine::osc_send_bridge_midi_program_count(%i)", count);
  1502. CARLA_ASSERT(fData->oscData != nullptr);
  1503. CARLA_ASSERT(count >= 0);
  1504. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1505. {
  1506. char target_path[strlen(fData->oscData->path)+27];
  1507. strcpy(target_path, fData->oscData->path);
  1508. strcat(target_path, "/bridge_midi_program_count");
  1509. lo_send(fData->oscData->target, target_path, "i", count);
  1510. }
  1511. }
  1512. void CarlaEngine::osc_send_bridge_plugin_info(const int32_t category, const int32_t hints, const char* const name, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId)
  1513. {
  1514. qDebug("CarlaEngine::osc_send_bridge_plugin_info(%i, %i, \"%s\", \"%s\", \"%s\", \"%s\", " P_INT64 ")", category, hints, name, label, maker, copyright, uniqueId);
  1515. CARLA_ASSERT(fData->oscData != nullptr);
  1516. CARLA_ASSERT(name);
  1517. CARLA_ASSERT(label);
  1518. CARLA_ASSERT(maker);
  1519. CARLA_ASSERT(copyright);
  1520. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1521. {
  1522. char target_path[strlen(fData->oscData->path)+20];
  1523. strcpy(target_path, fData->oscData->path);
  1524. strcat(target_path, "/bridge_plugin_info");
  1525. lo_send(fData->oscData->target, target_path, "iissssh", category, hints, name, label, maker, copyright, uniqueId);
  1526. }
  1527. }
  1528. void CarlaEngine::osc_send_bridge_parameter_info(const int32_t index, const char* const name, const char* const unit)
  1529. {
  1530. qDebug("CarlaEngine::osc_send_bridge_parameter_info(%i, \"%s\", \"%s\")", index, name, unit);
  1531. CARLA_ASSERT(fData->oscData != nullptr);
  1532. CARLA_ASSERT(name);
  1533. CARLA_ASSERT(unit);
  1534. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1535. {
  1536. char target_path[strlen(fData->oscData->path)+23];
  1537. strcpy(target_path, fData->oscData->path);
  1538. strcat(target_path, "/bridge_parameter_info");
  1539. lo_send(fData->oscData->target, target_path, "iss", index, name, unit);
  1540. }
  1541. }
  1542. void CarlaEngine::osc_send_bridge_parameter_data(const int32_t index, const int32_t type, const int32_t rindex, const int32_t hints, const int32_t midiChannel, const int32_t midiCC)
  1543. {
  1544. qDebug("CarlaEngine::osc_send_bridge_parameter_data(%i, %i, %i, %i, %i, %i)", index, type, rindex, hints, midiChannel, midiCC);
  1545. CARLA_ASSERT(fData->oscData != nullptr);
  1546. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1547. {
  1548. char target_path[strlen(fData->oscData->path)+23];
  1549. strcpy(target_path, fData->oscData->path);
  1550. strcat(target_path, "/bridge_parameter_data");
  1551. lo_send(fData->oscData->target, target_path, "iiiiii", index, type, rindex, hints, midiChannel, midiCC);
  1552. }
  1553. }
  1554. void CarlaEngine::osc_send_bridge_parameter_ranges(const int32_t index, const double def, const double min, const double max, const double step, const double stepSmall, const double stepLarge)
  1555. {
  1556. qDebug("CarlaEngine::osc_send_bridge_parameter_ranges(%i, %g, %g, %g, %g, %g, %g)", index, def, min, max, step, stepSmall, stepLarge);
  1557. CARLA_ASSERT(fData->oscData != nullptr);
  1558. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1559. {
  1560. char target_path[strlen(fData->oscData->path)+25];
  1561. strcpy(target_path, fData->oscData->path);
  1562. strcat(target_path, "/bridge_parameter_ranges");
  1563. lo_send(fData->oscData->target, target_path, "idddddd", index, def, min, max, step, stepSmall, stepLarge);
  1564. }
  1565. }
  1566. void CarlaEngine::osc_send_bridge_program_info(const int32_t index, const char* const name)
  1567. {
  1568. qDebug("CarlaEngine::osc_send_bridge_program_info(%i, \"%s\")", index, name);
  1569. CARLA_ASSERT(fData->oscData != nullptr);
  1570. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1571. {
  1572. char target_path[strlen(fData->oscData->path)+21];
  1573. strcpy(target_path, fData->oscData->path);
  1574. strcat(target_path, "/bridge_program_info");
  1575. lo_send(fData->oscData->target, target_path, "is", index, name);
  1576. }
  1577. }
  1578. void CarlaEngine::osc_send_bridge_midi_program_info(const int32_t index, const int32_t bank, const int32_t program, const char* const label)
  1579. {
  1580. qDebug("CarlaEngine::osc_send_bridge_midi_program_info(%i, %i, %i, \"%s\")", index, bank, program, label);
  1581. CARLA_ASSERT(fData->oscData != nullptr);
  1582. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1583. {
  1584. char target_path[strlen(fData->oscData->path)+26];
  1585. strcpy(target_path, fData->oscData->path);
  1586. strcat(target_path, "/bridge_midi_program_info");
  1587. lo_send(fData->oscData->target, target_path, "iiis", index, bank, program, label);
  1588. }
  1589. }
  1590. void CarlaEngine::osc_send_bridge_configure(const char* const key, const char* const value)
  1591. {
  1592. qDebug("CarlaEngine::osc_send_bridge_configure(\"%s\", \"%s\")", key, value);
  1593. CARLA_ASSERT(fData->oscData != nullptr);
  1594. CARLA_ASSERT(key);
  1595. CARLA_ASSERT(value);
  1596. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1597. {
  1598. char target_path[strlen(fData->oscData->path)+18];
  1599. strcpy(target_path, fData->oscData->path);
  1600. strcat(target_path, "/bridge_configure");
  1601. lo_send(fData->oscData->target, target_path, "ss", key, value);
  1602. }
  1603. }
  1604. void CarlaEngine::osc_send_bridge_set_parameter_value(const int32_t index, const double value)
  1605. {
  1606. qDebug("CarlaEngine::osc_send_bridge_set_parameter_value(%i, %g)", index, value);
  1607. CARLA_ASSERT(fData->oscData != nullptr);
  1608. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1609. {
  1610. char target_path[strlen(fData->oscData->path)+28];
  1611. strcpy(target_path, fData->oscData->path);
  1612. strcat(target_path, "/bridge_set_parameter_value");
  1613. lo_send(fData->oscData->target, target_path, "id", index, value);
  1614. }
  1615. }
  1616. void CarlaEngine::osc_send_bridge_set_default_value(const int32_t index, const double value)
  1617. {
  1618. qDebug("CarlaEngine::osc_send_bridge_set_default_value(%i, %g)", index, value);
  1619. CARLA_ASSERT(fData->oscData != nullptr);
  1620. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1621. {
  1622. char target_path[strlen(fData->oscData->path)+26];
  1623. strcpy(target_path, fData->oscData->path);
  1624. strcat(target_path, "/bridge_set_default_value");
  1625. lo_send(fData->oscData->target, target_path, "id", index, value);
  1626. }
  1627. }
  1628. void CarlaEngine::osc_send_bridge_set_program(const int32_t index)
  1629. {
  1630. qDebug("CarlaEngine::osc_send_bridge_set_program(%i)", index);
  1631. CARLA_ASSERT(fData->oscData != nullptr);
  1632. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1633. {
  1634. char target_path[strlen(fData->oscData->path)+20];
  1635. strcpy(target_path, fData->oscData->path);
  1636. strcat(target_path, "/bridge_set_program");
  1637. lo_send(fData->oscData->target, target_path, "i", index);
  1638. }
  1639. }
  1640. void CarlaEngine::osc_send_bridge_set_midi_program(const int32_t index)
  1641. {
  1642. qDebug("CarlaEngine::osc_send_bridge_set_midi_program(%i)", index);
  1643. CARLA_ASSERT(fData->oscData != nullptr);
  1644. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1645. {
  1646. char target_path[strlen(fData->oscData->path)+25];
  1647. strcpy(target_path, fData->oscData->path);
  1648. strcat(target_path, "/bridge_set_midi_program");
  1649. lo_send(fData->oscData->target, target_path, "i", index);
  1650. }
  1651. }
  1652. void CarlaEngine::osc_send_bridge_set_custom_data(const char* const type, const char* const key, const char* const value)
  1653. {
  1654. qDebug("CarlaEngine::osc_send_bridge_set_custom_data(\"%s\", \"%s\", \"%s\")", type, key, value);
  1655. CARLA_ASSERT(fData->oscData);
  1656. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1657. {
  1658. char target_path[strlen(fData->oscData->path)+24];
  1659. strcpy(target_path, fData->oscData->path);
  1660. strcat(target_path, "/bridge_set_custom_data");
  1661. lo_send(fData->oscData->target, target_path, "sss", type, key, value);
  1662. }
  1663. }
  1664. void CarlaEngine::osc_send_bridge_set_chunk_data(const char* const chunkFile)
  1665. {
  1666. qDebug("CarlaEngine::osc_send_bridge_set_chunk_data(\"%s\")", chunkFile);
  1667. CARLA_ASSERT(fData->oscData != nullptr);
  1668. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1669. {
  1670. char target_path[strlen(fData->oscData->path)+23];
  1671. strcpy(target_path, fData->oscData->path);
  1672. strcat(target_path, "/bridge_set_chunk_data");
  1673. lo_send(fData->oscData->target, target_path, "s", chunkFile);
  1674. }
  1675. }
  1676. #if 0
  1677. void CarlaEngine::osc_send_bridge_set_inpeak(const int32_t portId)
  1678. {
  1679. CARLA_ASSERT(fData->oscData != nullptr);
  1680. CARLA_ASSERT(portId == 1 || portId == 2);
  1681. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1682. {
  1683. char target_path[strlen(fData->oscData->path)+28];
  1684. strcpy(target_path, fData->oscData->path);
  1685. strcat(target_path, "/bridge_set_inpeak");
  1686. lo_send(fData->oscData->target, target_path, "id", portId, data->insPeak[portId-1]);
  1687. }
  1688. }
  1689. void CarlaEngine::osc_send_bridge_set_outpeak(const int32_t portId)
  1690. {
  1691. CARLA_ASSERT(fData->oscData != nullptr);
  1692. CARLA_ASSERT(portId == 1 || portId == 2);
  1693. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1694. {
  1695. char target_path[strlen(fData->oscData->path)+29];
  1696. strcpy(target_path, fData->oscData->path);
  1697. strcat(target_path, "/bridge_set_outpeak");
  1698. lo_send(fData->oscData->target, target_path, "id", portId, data->insPeak[portId-1]);
  1699. }
  1700. }
  1701. #endif
  1702. #endif
  1703. CARLA_BACKEND_END_NAMESPACE