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.

2063 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. void CarlaEngine::idle()
  467. {
  468. CARLA_ASSERT(fData->plugins != nullptr);
  469. CARLA_ASSERT(isRunning());
  470. for (unsigned int i=0; i < fData->curPluginCount; i++)
  471. {
  472. CarlaPlugin* const plugin = fData->plugins[i].plugin;
  473. if (plugin && plugin->enabled())
  474. plugin->idleGui();
  475. }
  476. }
  477. // -----------------------------------------------------------------------
  478. // Plugin management
  479. CarlaPlugin* CarlaEngine::getPlugin(const unsigned int id) const
  480. {
  481. qDebug("CarlaEngine::getPlugin(%i) [count:%i]", id, fData->curPluginCount);
  482. CARLA_ASSERT(fData->curPluginCount > 0);
  483. CARLA_ASSERT(id < fData->curPluginCount);
  484. CARLA_ASSERT(fData->plugins != nullptr);
  485. if (id < fData->curPluginCount && fData->plugins != nullptr)
  486. return fData->plugins[id].plugin;
  487. return nullptr;
  488. }
  489. CarlaPlugin* CarlaEngine::getPluginUnchecked(const unsigned int id) const
  490. {
  491. return fData->plugins[id].plugin;
  492. }
  493. const char* CarlaEngine::getNewUniquePluginName(const char* const name)
  494. {
  495. qDebug("CarlaEngine::getNewUniquePluginName(\"%s\")", name);
  496. CARLA_ASSERT(fData->maxPluginNumber > 0);
  497. CARLA_ASSERT(fData->plugins != nullptr);
  498. CARLA_ASSERT(name != nullptr);
  499. static CarlaString sname;
  500. sname = name;
  501. if (sname.isEmpty() || fData->plugins == nullptr)
  502. return strdup("(No name)");
  503. sname.truncate(maxClientNameSize()-5-1); // 5 = strlen(" (10)")
  504. sname.replace(':', '.'); // ':' is used in JACK1 to split client/port names
  505. for (unsigned short i=0; i < fData->curPluginCount; i++)
  506. {
  507. CARLA_ASSERT(fData->plugins[i].plugin);
  508. // Check if unique name doesn't exist
  509. if (const char* const pluginName = fData->plugins[i].plugin->name())
  510. {
  511. if (sname != pluginName)
  512. continue;
  513. }
  514. // Check if string has already been modified
  515. {
  516. const size_t len = sname.length();
  517. // 1 digit, ex: " (2)"
  518. if (sname[len-4] == ' ' && sname[len-3] == '(' && sname.isDigit(len-2) && sname[len-1] == ')')
  519. {
  520. int number = sname[len-2] - '0';
  521. if (number == 9)
  522. {
  523. // next number is 10, 2 digits
  524. sname.truncate(len-4);
  525. sname += " (10)";
  526. //sname.replace(" (9)", " (10)");
  527. }
  528. else
  529. sname[len-2] = char('0' + number + 1);
  530. continue;
  531. }
  532. // 2 digits, ex: " (11)"
  533. if (sname[len-5] == ' ' && sname[len-4] == '(' && sname.isDigit(len-3) && sname.isDigit(len-2) && sname[len-1] == ')')
  534. {
  535. char n2 = sname[len-2];
  536. char n3 = sname[len-3];
  537. if (n2 == '9')
  538. {
  539. n2 = '0';
  540. n3 = char(n3 + 1);
  541. }
  542. else
  543. n2 = char(n2 + 1);
  544. sname[len-2] = n2;
  545. sname[len-3] = n3;
  546. continue;
  547. }
  548. }
  549. // Modify string if not
  550. sname += " (2)";
  551. }
  552. return (const char*)sname;
  553. }
  554. 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)
  555. {
  556. qDebug("CarlaEngine::addPlugin(%s, %s, \"%s\", \"%s\", \"%s\", %p)", BinaryType2Str(btype), PluginType2Str(ptype), filename, name, label, extra);
  557. CARLA_ASSERT(btype != BINARY_NONE);
  558. CARLA_ASSERT(ptype != PLUGIN_NONE);
  559. CARLA_ASSERT(filename);
  560. CARLA_ASSERT(label);
  561. qWarning("CarlaEngine::addPlugin() started");
  562. if (fData->curPluginCount == fData->maxPluginNumber)
  563. {
  564. setLastError("Maximum number of plugins reached");
  565. return false;
  566. }
  567. const unsigned int id = fData->curPluginCount;
  568. CarlaPlugin::Initializer init = {
  569. this,
  570. id,
  571. filename,
  572. name,
  573. label
  574. };
  575. CarlaPlugin* plugin = nullptr;
  576. #ifndef BUILD_BRIDGE
  577. const char* bridgeBinary;
  578. switch (btype)
  579. {
  580. case BINARY_POSIX32:
  581. bridgeBinary = fOptions.bridge_posix32.isNotEmpty() ? (const char*)fOptions.bridge_posix32 : nullptr;
  582. break;
  583. case BINARY_POSIX64:
  584. bridgeBinary = fOptions.bridge_posix64.isNotEmpty() ? (const char*)fOptions.bridge_posix64 : nullptr;
  585. break;
  586. case BINARY_WIN32:
  587. bridgeBinary = fOptions.bridge_win32.isNotEmpty() ? (const char*)fOptions.bridge_win32 : nullptr;
  588. break;
  589. case BINARY_WIN64:
  590. bridgeBinary = fOptions.bridge_win64.isNotEmpty() ? (const char*)fOptions.bridge_win64 : nullptr;
  591. break;
  592. default:
  593. bridgeBinary = nullptr;
  594. break;
  595. }
  596. #ifndef Q_OS_WIN
  597. if (btype == BINARY_NATIVE && fOptions.bridge_native.isNotEmpty())
  598. bridgeBinary = (const char*)fOptions.bridge_native;
  599. #endif
  600. if (fOptions.preferPluginBridges && bridgeBinary != nullptr)
  601. {
  602. // TODO
  603. if (fOptions.processMode != PROCESS_MODE_MULTIPLE_CLIENTS)
  604. {
  605. setLastError("Can only use bridged plugins in JACK Multi-Client mode");
  606. return -1;
  607. }
  608. // TODO
  609. if (type() != kEngineTypeJack)
  610. {
  611. setLastError("Can only use bridged plugins with JACK backend");
  612. return -1;
  613. }
  614. #if 0
  615. plugin = CarlaPlugin::newBridge(init, btype, ptype, bridgeBinary);
  616. #endif
  617. }
  618. else
  619. #endif // BUILD_BRIDGE
  620. {
  621. switch (ptype)
  622. {
  623. case PLUGIN_NONE:
  624. break;
  625. #ifndef BUILD_BRIDGE
  626. case PLUGIN_INTERNAL:
  627. plugin = CarlaPlugin::newNative(init);
  628. break;
  629. #endif
  630. case PLUGIN_LADSPA:
  631. #ifdef WANT_LADSPA
  632. plugin = CarlaPlugin::newLADSPA(init, (const LADSPA_RDF_Descriptor*)extra);
  633. #endif
  634. break;
  635. #if 0
  636. case PLUGIN_DSSI:
  637. #ifdef WANT_DSSI
  638. plugin = CarlaPlugin::newDSSI(init, extra);
  639. #endif
  640. break;
  641. case PLUGIN_LV2:
  642. #ifdef WANT_LV2
  643. plugin = CarlaPlugin::newLV2(init);
  644. #endif
  645. break;
  646. case PLUGIN_VST:
  647. #ifdef WANT_VST
  648. plugin = CarlaPlugin::newVST(init);
  649. #endif
  650. break;
  651. case PLUGIN_GIG:
  652. #ifdef WANT_LINUXSAMPLER
  653. plugin = CarlaPlugin::newGIG(init);
  654. #endif
  655. break;
  656. case PLUGIN_SF2:
  657. #ifdef WANT_FLUIDSYNTH
  658. plugin = CarlaPlugin::newSF2(init);
  659. #endif
  660. break;
  661. case PLUGIN_SFZ:
  662. #ifdef WANT_LINUXSAMPLER
  663. plugin = CarlaPlugin::newSFZ(init);
  664. #endif
  665. break;
  666. #else
  667. default:
  668. break;
  669. #endif
  670. }
  671. }
  672. if (plugin == nullptr)
  673. return false;
  674. fData->plugins[id].plugin = plugin;
  675. fData->plugins[id].insPeak[0] = 0.0f;
  676. fData->plugins[id].insPeak[1] = 0.0f;
  677. fData->plugins[id].outsPeak[0] = 0.0f;
  678. fData->plugins[id].outsPeak[1] = 0.0f;
  679. fData->curPluginCount += 1;
  680. qWarning("CarlaEngine::addPlugin() finished");
  681. // FIXME
  682. callback(CALLBACK_PLUGIN_ADDED, id, 0, 0, 0.0f, nullptr);
  683. return true;
  684. }
  685. bool CarlaEngine::removePlugin(const unsigned int id)
  686. {
  687. qDebug("CarlaEngine::removePlugin(%i)", id);
  688. CARLA_ASSERT(fData->curPluginCount > 0);
  689. CARLA_ASSERT(id < fData->curPluginCount);
  690. CARLA_ASSERT(fData->plugins != nullptr);
  691. if (fData->plugins == nullptr)
  692. {
  693. setLastError("Critical error: no plugins are currently loaded!");
  694. return false;
  695. }
  696. CarlaPlugin* const plugin = fData->plugins[id].plugin;
  697. CARLA_ASSERT(plugin);
  698. if (plugin)
  699. {
  700. CARLA_ASSERT(plugin->id() == id);
  701. fData->thread.stopNow();
  702. fData->nextAction.pluginId = id;
  703. fData->nextAction.opcode = EnginePostActionRemovePlugin;
  704. fData->nextAction.mutex.lock();
  705. if (isRunning())
  706. {
  707. // block wait for unlock on proccessing side
  708. fData->nextAction.mutex.lock();
  709. }
  710. else
  711. {
  712. doPluginRemove(fData, false);
  713. }
  714. #ifndef BUILD_BRIDGE
  715. if (isOscControlRegistered())
  716. osc_send_control_remove_plugin(id);
  717. #endif
  718. delete plugin;
  719. fData->nextAction.mutex.unlock();
  720. if (isRunning() && ! fData->aboutToClose)
  721. fData->thread.startNow();
  722. return true;
  723. }
  724. qCritical("CarlaEngine::removePlugin(%i) - could not find plugin", id);
  725. setLastError("Could not find plugin to remove");
  726. return false;
  727. }
  728. void CarlaEngine::removeAllPlugins()
  729. {
  730. qDebug("CarlaEngine::removeAllPlugins()");
  731. fData->thread.stopNow();
  732. const unsigned int oldCount = fData->curPluginCount;
  733. // wait for processing
  734. // TODO
  735. fData->curPluginCount = 0;
  736. fData->maxPluginNumber = 0;
  737. for (unsigned short i=0; i < oldCount; i++)
  738. {
  739. CarlaPlugin* const plugin = fData->plugins[i].plugin;
  740. CARLA_ASSERT(plugin);
  741. if (plugin)
  742. delete plugin;
  743. // clear this plugin
  744. fData->plugins[i].plugin = nullptr;
  745. fData->plugins[i].insPeak[0] = 0.0;
  746. fData->plugins[i].insPeak[1] = 0.0;
  747. fData->plugins[i].outsPeak[0] = 0.0;
  748. fData->plugins[i].outsPeak[1] = 0.0;
  749. }
  750. if (isRunning() && ! fData->aboutToClose)
  751. fData->thread.startNow();
  752. }
  753. #if 0
  754. void CarlaEngine::__bridgePluginRegister(const unsigned short id, CarlaPlugin* const plugin)
  755. {
  756. data->carlaPlugins[id] = plugin;
  757. }
  758. #endif
  759. // -----------------------------------------------------------------------
  760. // Information (base)
  761. void CarlaEngine::setAboutToClose()
  762. {
  763. qDebug("CarlaEngine::setAboutToClose()");
  764. fData->aboutToClose = true;
  765. }
  766. #if 0
  767. // -----------------------------------------------------------------------
  768. // Information (audio peaks)
  769. double CarlaEngine::getInputPeak(const unsigned short pluginId, const unsigned short id) const
  770. {
  771. CARLA_ASSERT(pluginId < data->maxPluginNumber);
  772. CARLA_ASSERT(id < MAX_PEAKS);
  773. return data->insPeak[pluginId*MAX_PEAKS + id];
  774. }
  775. double CarlaEngine::getOutputPeak(const unsigned short pluginId, const unsigned short id) const
  776. {
  777. CARLA_ASSERT(pluginId < data->maxPluginNumber);
  778. CARLA_ASSERT(id < MAX_PEAKS);
  779. return data->outsPeak[pluginId*MAX_PEAKS + id];
  780. }
  781. void CarlaEngine::setInputPeak(const unsigned short pluginId, const unsigned short id, double value)
  782. {
  783. CARLA_ASSERT(pluginId < data->maxPluginNumber);
  784. CARLA_ASSERT(id < MAX_PEAKS);
  785. data->insPeak[pluginId*MAX_PEAKS + id] = value;
  786. }
  787. void CarlaEngine::setOutputPeak(const unsigned short pluginId, const unsigned short id, double value)
  788. {
  789. CARLA_ASSERT(pluginId < data->maxPluginNumber);
  790. CARLA_ASSERT(id < MAX_PEAKS);
  791. data->outsPeak[pluginId*MAX_PEAKS + id] = value;
  792. }
  793. #endif
  794. // -----------------------------------------------------------------------
  795. // Callback
  796. void CarlaEngine::callback(const CallbackType action, const unsigned short pluginId, const int value1, const int value2, const float value3, const char* const valueStr)
  797. {
  798. qDebug("CarlaEngine::callback(%s, %i, %i, %i, %f, \"%s\")", CallbackType2Str(action), pluginId, value1, value2, value3, valueStr);
  799. if (fData->callback)
  800. fData->callback(fData->callbackPtr, action, pluginId, value1, value2, value3, valueStr);
  801. }
  802. void CarlaEngine::setCallback(const CallbackFunc func, void* const ptr)
  803. {
  804. qDebug("CarlaEngine::setCallback(%p, %p)", func, ptr);
  805. CARLA_ASSERT(func);
  806. fData->callback = func;
  807. fData->callbackPtr = ptr;
  808. }
  809. // -----------------------------------------------------------------------
  810. // Error handling
  811. const char* CarlaEngine::getLastError() const
  812. {
  813. return (const char*)fData->lastError;
  814. }
  815. void CarlaEngine::setLastError(const char* const error)
  816. {
  817. fData->lastError = error;
  818. }
  819. // -----------------------------------------------------------------------
  820. // Global options
  821. #ifndef BUILD_BRIDGE
  822. const QProcessEnvironment& CarlaEngine::getOptionsAsProcessEnvironment() const
  823. {
  824. return fData->procEnv;
  825. }
  826. #define CARLA_ENGINE_SET_OPTION_RUNNING_CHECK \
  827. if (isRunning()) \
  828. return qCritical("CarlaEngine::setOption(%s, %i, \"%s\") - Cannot set this option while engine is running!", OptionsType2Str(option), value, valueStr);
  829. void CarlaEngine::setOption(const OptionsType option, const int value, const char* const valueStr)
  830. {
  831. qDebug("CarlaEngine::setOption(%s, %i, \"%s\")", OptionsType2Str(option), value, valueStr);
  832. switch (option)
  833. {
  834. case OPTION_PROCESS_NAME:
  835. carla_setprocname(valueStr);
  836. break;
  837. case OPTION_PROCESS_MODE:
  838. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  839. if (value < PROCESS_MODE_SINGLE_CLIENT || value > PROCESS_MODE_PATCHBAY)
  840. return qCritical("CarlaEngine::setOption(%s, %i, \"%s\") - invalid value", OptionsType2Str(option), value, valueStr);
  841. fOptions.processMode = static_cast<ProcessMode>(value);
  842. break;
  843. case OPTION_MAX_PARAMETERS:
  844. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  845. if (value < 0)
  846. return; // TODO error here
  847. fOptions.maxParameters = static_cast<uint>(value);
  848. break;
  849. case OPTION_PREFERRED_BUFFER_SIZE:
  850. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  851. fOptions.preferredBufferSize = static_cast<uint>(value);
  852. break;
  853. case OPTION_PREFERRED_SAMPLE_RATE:
  854. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  855. fOptions.preferredSampleRate = static_cast<uint>(value);
  856. break;
  857. case OPTION_FORCE_STEREO:
  858. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  859. fOptions.forceStereo = (value != 0);
  860. break;
  861. #ifdef WANT_DSSI
  862. case OPTION_USE_DSSI_VST_CHUNKS:
  863. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  864. fOptions.useDssiVstChunks = (value != 0);
  865. break;
  866. #endif
  867. case OPTION_PREFER_PLUGIN_BRIDGES:
  868. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  869. fOptions.preferPluginBridges = (value != 0);
  870. break;
  871. case OPTION_PREFER_UI_BRIDGES:
  872. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  873. fOptions.preferUiBridges = (value != 0);
  874. break;
  875. case OPTION_OSC_UI_TIMEOUT:
  876. CARLA_ENGINE_SET_OPTION_RUNNING_CHECK
  877. fOptions.oscUiTimeout = static_cast<uint>(value);
  878. break;
  879. case OPTION_PATH_BRIDGE_NATIVE:
  880. fOptions.bridge_native = valueStr;
  881. break;
  882. case OPTION_PATH_BRIDGE_POSIX32:
  883. fOptions.bridge_posix32 = valueStr;
  884. break;
  885. case OPTION_PATH_BRIDGE_POSIX64:
  886. fOptions.bridge_posix64 = valueStr;
  887. break;
  888. case OPTION_PATH_BRIDGE_WIN32:
  889. fOptions.bridge_win32 = valueStr;
  890. break;
  891. case OPTION_PATH_BRIDGE_WIN64:
  892. fOptions.bridge_win64 = valueStr;
  893. break;
  894. #ifdef WANT_LV2
  895. case OPTION_PATH_BRIDGE_LV2_GTK2:
  896. fOptions.bridge_lv2gtk2 = valueStr;
  897. break;
  898. case OPTION_PATH_BRIDGE_LV2_GTK3:
  899. fOptions.bridge_lv2gtk3 = valueStr;
  900. break;
  901. case OPTION_PATH_BRIDGE_LV2_QT4:
  902. fOptions.bridge_lv2qt4 = valueStr;
  903. break;
  904. case OPTION_PATH_BRIDGE_LV2_QT5:
  905. fOptions.bridge_lv2qt5 = valueStr;
  906. break;
  907. case OPTION_PATH_BRIDGE_LV2_COCOA:
  908. fOptions.bridge_lv2cocoa = valueStr;
  909. break;
  910. case OPTION_PATH_BRIDGE_LV2_WINDOWS:
  911. fOptions.bridge_lv2win = valueStr;
  912. break;
  913. case OPTION_PATH_BRIDGE_LV2_X11:
  914. fOptions.bridge_lv2x11 = valueStr;
  915. break;
  916. #endif
  917. #ifdef WANT_VST
  918. case OPTION_PATH_BRIDGE_VST_COCOA:
  919. fOptions.bridge_vstcocoa = valueStr;
  920. break;
  921. case OPTION_PATH_BRIDGE_VST_HWND:
  922. fOptions.bridge_vsthwnd = valueStr;
  923. break;
  924. case OPTION_PATH_BRIDGE_VST_X11:
  925. fOptions.bridge_vstx11 = valueStr;
  926. break;
  927. #endif
  928. }
  929. }
  930. #endif
  931. // -----------------------------------------------------------------------
  932. // OSC Stuff
  933. #ifdef BUILD_BRIDGE
  934. bool CarlaEngine::isOscBridgeRegistered() const
  935. {
  936. return (fData->oscData != nullptr);
  937. }
  938. #else
  939. bool CarlaEngine::isOscControlRegistered() const
  940. {
  941. return fData->osc.isControlRegistered();
  942. }
  943. #endif
  944. void CarlaEngine::idleOsc()
  945. {
  946. fData->osc.idle();
  947. }
  948. const char* CarlaEngine::getOscServerPathTCP() const
  949. {
  950. return fData->osc.getServerPathTCP();
  951. }
  952. const char* CarlaEngine::getOscServerPathUDP() const
  953. {
  954. return fData->osc.getServerPathUDP();
  955. }
  956. #ifdef BUILD_BRIDGE
  957. void CarlaEngine::setOscBridgeData(const CarlaOscData* const oscData)
  958. {
  959. fData->oscData = oscData;
  960. }
  961. #endif
  962. // -----------------------------------------------------------------------
  963. // protected calls
  964. void CarlaEngine::bufferSizeChanged(const uint32_t newBufferSize)
  965. {
  966. qDebug("CarlaEngine::bufferSizeChanged(%i)", newBufferSize);
  967. #if 0
  968. for (unsigned short i=0; i < data->maxPluginNumber; i++)
  969. {
  970. if (data->carlaPlugins[i] && data->carlaPlugins[i]->enabled() /*&& ! data->carlaPlugins[i]->data->processHighPrecision*/)
  971. data->carlaPlugins[i]->bufferSizeChanged(newBufferSize);
  972. }
  973. #endif
  974. }
  975. void CarlaEngine::sampleRateChanged(const double newSampleRate)
  976. {
  977. qDebug("CarlaEngine::sampleRateChanged(%g)", newSampleRate);
  978. // TODO
  979. }
  980. void CarlaEngine::proccessPendingEvents()
  981. {
  982. switch (fData->nextAction.opcode)
  983. {
  984. case EnginePostActionNull:
  985. break;
  986. case EnginePostActionRemovePlugin:
  987. doPluginRemove(fData, true);
  988. break;
  989. }
  990. // TODO - peak values
  991. }
  992. #ifndef BUILD_BRIDGE
  993. EngineEvent* CarlaEngine::getRackEventBuffer(const bool isInput)
  994. {
  995. // TODO
  996. return nullptr;
  997. }
  998. void CarlaEngine::processRack(float* inBuf[2], float* outBuf[2], const uint32_t frames)
  999. {
  1000. // initialize outputs (zero)
  1001. carla_zeroFloat(outBuf[0], frames);
  1002. carla_zeroFloat(outBuf[1], frames);
  1003. //std::memset(rackEventsOut, 0, sizeof(EngineEvent)*MAX_EVENTS);
  1004. bool processed = false;
  1005. // process plugins
  1006. for (unsigned int i=0; i < fData->curPluginCount; i++)
  1007. {
  1008. CarlaPlugin* const plugin = getPluginUnchecked(i);
  1009. if (plugin == nullptr || ! plugin->enabled())
  1010. continue;
  1011. #if 0
  1012. if (processed)
  1013. {
  1014. // initialize inputs (from previous outputs)
  1015. memcpy(inBuf[0], outBuf[0], sizeof(float)*frames);
  1016. memcpy(inBuf[1], outBuf[1], sizeof(float)*frames);
  1017. memcpy(rackMidiEventsIn, rackMidiEventsOut, sizeof(CarlaEngineMidiEvent)*MAX_MIDI_EVENTS);
  1018. // initialize outputs (zero)
  1019. carla_zeroFloat(outBuf[0], frames);
  1020. carla_zeroFloat(outBuf[1], frames);
  1021. memset(rackMidiEventsOut, 0, sizeof(CarlaEngineMidiEvent)*MAX_MIDI_EVENTS);
  1022. }
  1023. // process
  1024. processLock();
  1025. plugin->initBuffers();
  1026. if (false /*plugin->data->processHighPrecision*/)
  1027. {
  1028. float* inBuf2[2];
  1029. float* outBuf2[2];
  1030. for (uint32_t j=0; j < frames; j += 8)
  1031. {
  1032. inBuf2[0] = inBuf[0] + j;
  1033. inBuf2[1] = inBuf[1] + j;
  1034. outBuf2[0] = outBuf[0] + j;
  1035. outBuf2[1] = outBuf[1] + j;
  1036. plugin->process(inBuf2, outBuf2, 8, j);
  1037. }
  1038. }
  1039. else
  1040. plugin->process(inBuf, outBuf, frames);
  1041. processUnlock();
  1042. // if plugin has no audio inputs, add previous buffers
  1043. if (plugin->audioInCount() == 0)
  1044. {
  1045. for (uint32_t j=0; j < frames; j++)
  1046. {
  1047. outBuf[0][j] += inBuf[0][j];
  1048. outBuf[1][j] += inBuf[1][j];
  1049. }
  1050. }
  1051. // if plugin has no midi output, add previous midi input
  1052. if (plugin->midiOutCount() == 0)
  1053. {
  1054. memcpy(rackMidiEventsOut, rackMidiEventsIn, sizeof(CarlaEngineMidiEvent)*MAX_MIDI_EVENTS);
  1055. }
  1056. // set peaks
  1057. {
  1058. double inPeak1 = 0.0;
  1059. double inPeak2 = 0.0;
  1060. double outPeak1 = 0.0;
  1061. double outPeak2 = 0.0;
  1062. for (uint32_t k=0; k < frames; k++)
  1063. {
  1064. // TODO - optimize this
  1065. if (std::abs(inBuf[0][k]) > inPeak1)
  1066. inPeak1 = std::abs(inBuf[0][k]);
  1067. if (std::abs(inBuf[1][k]) > inPeak2)
  1068. inPeak2 = std::abs(inBuf[1][k]);
  1069. if (std::abs(outBuf[0][k]) > outPeak1)
  1070. outPeak1 = std::abs(outBuf[0][k]);
  1071. if (std::abs(outBuf[1][k]) > outPeak2)
  1072. outPeak2 = std::abs(outBuf[1][k]);
  1073. }
  1074. data->insPeak[i*MAX_PEAKS + 0] = inPeak1;
  1075. data->insPeak[i*MAX_PEAKS + 1] = inPeak2;
  1076. data->outsPeak[i*MAX_PEAKS + 0] = outPeak1;
  1077. data->outsPeak[i*MAX_PEAKS + 1] = outPeak2;
  1078. }
  1079. #endif
  1080. processed = true;
  1081. }
  1082. // if no plugins in the rack, copy inputs over outputs
  1083. if (! processed)
  1084. {
  1085. std::memcpy(outBuf[0], inBuf[0], sizeof(float)*frames);
  1086. std::memcpy(outBuf[1], inBuf[1], sizeof(float)*frames);
  1087. //std::memcpy(rackEventsOut, rackEventsIn, sizeof(EngineEvent)*MAX_EVENTS);
  1088. }
  1089. }
  1090. void CarlaEngine::processPatchbay(float** inBuf, float** outBuf, const uint32_t bufCount[2], const uint32_t frames)
  1091. {
  1092. // TODO
  1093. Q_UNUSED(inBuf);
  1094. Q_UNUSED(outBuf);
  1095. Q_UNUSED(bufCount);
  1096. Q_UNUSED(frames);
  1097. }
  1098. #endif
  1099. // -------------------------------------------------------------------------------------------------------------------
  1100. // Carla Engine OSC stuff
  1101. #ifdef BUILD_BRIDGE
  1102. void CarlaEngine::osc_send_peaks(CarlaPlugin* const /*plugin*/)
  1103. #else
  1104. void CarlaEngine::osc_send_peaks(CarlaPlugin* const plugin, const unsigned short& id)
  1105. #endif
  1106. {
  1107. #if 0
  1108. // Peak values
  1109. if (plugin->audioInCount() > 0)
  1110. {
  1111. #ifdef BUILD_BRIDGE
  1112. osc_send_bridge_set_inpeak(1);
  1113. osc_send_bridge_set_inpeak(2);
  1114. #else
  1115. osc_send_control_set_input_peak_value(id, 1);
  1116. osc_send_control_set_input_peak_value(id, 2);
  1117. #endif
  1118. }
  1119. if (plugin->audioOutCount() > 0)
  1120. {
  1121. #ifdef BUILD_BRIDGE
  1122. osc_send_bridge_set_outpeak(1);
  1123. osc_send_bridge_set_outpeak(2);
  1124. #else
  1125. osc_send_control_set_output_peak_value(id, 1);
  1126. osc_send_control_set_output_peak_value(id, 2);
  1127. #endif
  1128. }
  1129. #endif
  1130. }
  1131. #ifndef BUILD_BRIDGE
  1132. void CarlaEngine::osc_send_control_add_plugin_start(const int32_t pluginId, const char* const pluginName)
  1133. {
  1134. qDebug("CarlaEngine::osc_send_control_add_plugin_start(%i, \"%s\")", pluginId, pluginName);
  1135. CARLA_ASSERT(fData->oscData != nullptr);
  1136. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1137. CARLA_ASSERT(pluginName);
  1138. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1139. {
  1140. char target_path[strlen(fData->oscData->path)+18];
  1141. strcpy(target_path, fData->oscData->path);
  1142. strcat(target_path, "/add_plugin_start");
  1143. lo_send(fData->oscData->target, target_path, "is", pluginId, pluginName);
  1144. }
  1145. }
  1146. void CarlaEngine::osc_send_control_add_plugin_end(const int32_t pluginId)
  1147. {
  1148. qDebug("CarlaEngine::osc_send_control_add_plugin_end(%i)", pluginId);
  1149. CARLA_ASSERT(fData->oscData != nullptr);
  1150. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1151. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1152. {
  1153. char target_path[strlen(fData->oscData->path)+16];
  1154. strcpy(target_path, fData->oscData->path);
  1155. strcat(target_path, "/add_plugin_end");
  1156. lo_send(fData->oscData->target, target_path, "i", pluginId);
  1157. }
  1158. }
  1159. void CarlaEngine::osc_send_control_remove_plugin(const int32_t pluginId)
  1160. {
  1161. qDebug("CarlaEngine::osc_send_control_remove_plugin(%i)", pluginId);
  1162. CARLA_ASSERT(fData->oscData != nullptr);
  1163. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1164. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1165. {
  1166. char target_path[strlen(fData->oscData->path)+15];
  1167. strcpy(target_path, fData->oscData->path);
  1168. strcat(target_path, "/remove_plugin");
  1169. lo_send(fData->oscData->target, target_path, "i", pluginId);
  1170. }
  1171. }
  1172. 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)
  1173. {
  1174. 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);
  1175. CARLA_ASSERT(fData->oscData != nullptr);
  1176. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1177. CARLA_ASSERT(type != PLUGIN_NONE);
  1178. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1179. {
  1180. char target_path[strlen(fData->oscData->path)+17];
  1181. strcpy(target_path, fData->oscData->path);
  1182. strcat(target_path, "/set_plugin_data");
  1183. lo_send(fData->oscData->target, target_path, "iiiissssh", pluginId, type, category, hints, realName, label, maker, copyright, uniqueId);
  1184. }
  1185. }
  1186. 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)
  1187. {
  1188. qDebug("CarlaEngine::osc_send_control_set_plugin_ports(%i, %i, %i, %i, %i, %i, %i, %i)", pluginId, audioIns, audioOuts, midiIns, midiOuts, cIns, cOuts, cTotals);
  1189. CARLA_ASSERT(fData->oscData != nullptr);
  1190. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1191. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1192. {
  1193. char target_path[strlen(fData->oscData->path)+18];
  1194. strcpy(target_path, fData->oscData->path);
  1195. strcat(target_path, "/set_plugin_ports");
  1196. lo_send(fData->oscData->target, target_path, "iiiiiiii", pluginId, audioIns, audioOuts, midiIns, midiOuts, cIns, cOuts, cTotals);
  1197. }
  1198. }
  1199. 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)
  1200. {
  1201. qDebug("CarlaEngine::osc_send_control_set_parameter_data(%i, %i, %i, %i, \"%s\", \"%s\", %g)", pluginId, index, type, hints, name, label, current);
  1202. CARLA_ASSERT(fData->oscData != nullptr);
  1203. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1204. CARLA_ASSERT(index >= 0);
  1205. CARLA_ASSERT(type != PARAMETER_UNKNOWN);
  1206. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1207. {
  1208. char target_path[strlen(fData->oscData->path)+20];
  1209. strcpy(target_path, fData->oscData->path);
  1210. strcat(target_path, "/set_parameter_data");
  1211. lo_send(fData->oscData->target, target_path, "iiiissd", pluginId, index, type, hints, name, label, current);
  1212. }
  1213. }
  1214. 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)
  1215. {
  1216. qDebug("CarlaEngine::osc_send_control_set_parameter_ranges(%i, %i, %g, %g, %g, %g, %g, %g)", pluginId, index, min, max, def, step, stepSmall, stepLarge);
  1217. CARLA_ASSERT(fData->oscData != nullptr);
  1218. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1219. CARLA_ASSERT(index >= 0);
  1220. CARLA_ASSERT(min < max);
  1221. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1222. {
  1223. char target_path[strlen(fData->oscData->path)+22];
  1224. strcpy(target_path, fData->oscData->path);
  1225. strcat(target_path, "/set_parameter_ranges");
  1226. lo_send(fData->oscData->target, target_path, "iidddddd", pluginId, index, min, max, def, step, stepSmall, stepLarge);
  1227. }
  1228. }
  1229. void CarlaEngine::osc_send_control_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc)
  1230. {
  1231. qDebug("CarlaEngine::osc_send_control_set_parameter_midi_cc(%i, %i, %i)", pluginId, index, cc);
  1232. CARLA_ASSERT(fData->oscData != nullptr);
  1233. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1234. CARLA_ASSERT(index >= 0);
  1235. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1236. {
  1237. char target_path[strlen(fData->oscData->path)+23];
  1238. strcpy(target_path, fData->oscData->path);
  1239. strcat(target_path, "/set_parameter_midi_cc");
  1240. lo_send(fData->oscData->target, target_path, "iii", pluginId, index, cc);
  1241. }
  1242. }
  1243. void CarlaEngine::osc_send_control_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel)
  1244. {
  1245. qDebug("CarlaEngine::osc_send_control_set_parameter_midi_channel(%i, %i, %i)", pluginId, index, channel);
  1246. CARLA_ASSERT(fData->oscData != nullptr);
  1247. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1248. CARLA_ASSERT(index >= 0);
  1249. CARLA_ASSERT(channel >= 0 && channel < 16);
  1250. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1251. {
  1252. char target_path[strlen(fData->oscData->path)+28];
  1253. strcpy(target_path, fData->oscData->path);
  1254. strcat(target_path, "/set_parameter_midi_channel");
  1255. lo_send(fData->oscData->target, target_path, "iii", pluginId, index, channel);
  1256. }
  1257. }
  1258. void CarlaEngine::osc_send_control_set_parameter_value(const int32_t pluginId, const int32_t index, const double value)
  1259. {
  1260. #if DEBUG
  1261. if (index < 0)
  1262. qDebug("CarlaEngine::osc_send_control_set_parameter_value(%i, %s, %g)", pluginId, InternalParametersIndex2Str((InternalParametersIndex)index), value);
  1263. else
  1264. qDebug("CarlaEngine::osc_send_control_set_parameter_value(%i, %i, %g)", pluginId, index, value);
  1265. #endif
  1266. CARLA_ASSERT(fData->oscData != nullptr);
  1267. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->curPluginCount);
  1268. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1269. {
  1270. char target_path[strlen(fData->oscData->path)+21];
  1271. strcpy(target_path, fData->oscData->path);
  1272. strcat(target_path, "/set_parameter_value");
  1273. lo_send(fData->oscData->target, target_path, "iid", pluginId, index, value);
  1274. }
  1275. }
  1276. void CarlaEngine::osc_send_control_set_default_value(const int32_t pluginId, const int32_t index, const double value)
  1277. {
  1278. qDebug("CarlaEngine::osc_send_control_set_default_value(%i, %i, %g)", pluginId, index, value);
  1279. CARLA_ASSERT(fData->oscData != nullptr);
  1280. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1281. CARLA_ASSERT(index >= 0);
  1282. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1283. {
  1284. char target_path[strlen(fData->oscData->path)+19];
  1285. strcpy(target_path, fData->oscData->path);
  1286. strcat(target_path, "/set_default_value");
  1287. lo_send(fData->oscData->target, target_path, "iid", pluginId, index, value);
  1288. }
  1289. }
  1290. void CarlaEngine::osc_send_control_set_program(const int32_t pluginId, const int32_t index)
  1291. {
  1292. qDebug("CarlaEngine::osc_send_control_set_program(%i, %i)", pluginId, index);
  1293. CARLA_ASSERT(fData->oscData != nullptr);
  1294. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1295. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1296. {
  1297. char target_path[strlen(fData->oscData->path)+13];
  1298. strcpy(target_path, fData->oscData->path);
  1299. strcat(target_path, "/set_program");
  1300. lo_send(fData->oscData->target, target_path, "ii", pluginId, index);
  1301. }
  1302. }
  1303. void CarlaEngine::osc_send_control_set_program_count(const int32_t pluginId, const int32_t count)
  1304. {
  1305. qDebug("CarlaEngine::osc_send_control_set_program_count(%i, %i)", pluginId, count);
  1306. CARLA_ASSERT(fData->oscData != nullptr);
  1307. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1308. CARLA_ASSERT(count >= 0);
  1309. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1310. {
  1311. char target_path[strlen(fData->oscData->path)+19];
  1312. strcpy(target_path, fData->oscData->path);
  1313. strcat(target_path, "/set_program_count");
  1314. lo_send(fData->oscData->target, target_path, "ii", pluginId, count);
  1315. }
  1316. }
  1317. void CarlaEngine::osc_send_control_set_program_name(const int32_t pluginId, const int32_t index, const char* const name)
  1318. {
  1319. qDebug("CarlaEngine::osc_send_control_set_program_name(%i, %i, \"%s\")", pluginId, index, name);
  1320. CARLA_ASSERT(fData->oscData != nullptr);
  1321. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1322. CARLA_ASSERT(index >= 0);
  1323. CARLA_ASSERT(name);
  1324. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1325. {
  1326. char target_path[strlen(fData->oscData->path)+18];
  1327. strcpy(target_path, fData->oscData->path);
  1328. strcat(target_path, "/set_program_name");
  1329. lo_send(fData->oscData->target, target_path, "iis", pluginId, index, name);
  1330. }
  1331. }
  1332. void CarlaEngine::osc_send_control_set_midi_program(const int32_t pluginId, const int32_t index)
  1333. {
  1334. qDebug("CarlaEngine::osc_send_control_set_midi_program(%i, %i)", pluginId, index);
  1335. CARLA_ASSERT(fData->oscData != nullptr);
  1336. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1337. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1338. {
  1339. char target_path[strlen(fData->oscData->path)+18];
  1340. strcpy(target_path, fData->oscData->path);
  1341. strcat(target_path, "/set_midi_program");
  1342. lo_send(fData->oscData->target, target_path, "ii", pluginId, index);
  1343. }
  1344. }
  1345. void CarlaEngine::osc_send_control_set_midi_program_count(const int32_t pluginId, const int32_t count)
  1346. {
  1347. qDebug("CarlaEngine::osc_send_control_set_midi_program_count(%i, %i)", pluginId, count);
  1348. CARLA_ASSERT(fData->oscData != nullptr);
  1349. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1350. CARLA_ASSERT(count >= 0);
  1351. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1352. {
  1353. char target_path[strlen(fData->oscData->path)+24];
  1354. strcpy(target_path, fData->oscData->path);
  1355. strcat(target_path, "/set_midi_program_count");
  1356. lo_send(fData->oscData->target, target_path, "ii", pluginId, count);
  1357. }
  1358. }
  1359. 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)
  1360. {
  1361. qDebug("CarlaEngine::osc_send_control_set_midi_program_data(%i, %i, %i, %i, \"%s\")", pluginId, index, bank, program, name);
  1362. CARLA_ASSERT(fData->oscData != nullptr);
  1363. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1364. CARLA_ASSERT(index >= 0);
  1365. CARLA_ASSERT(bank >= 0);
  1366. CARLA_ASSERT(program >= 0);
  1367. CARLA_ASSERT(name);
  1368. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1369. {
  1370. char target_path[strlen(fData->oscData->path)+23];
  1371. strcpy(target_path, fData->oscData->path);
  1372. strcat(target_path, "/set_midi_program_data");
  1373. lo_send(fData->oscData->target, target_path, "iiiis", pluginId, index, bank, program, name);
  1374. }
  1375. }
  1376. void CarlaEngine::osc_send_control_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo)
  1377. {
  1378. qDebug("CarlaEngine::osc_send_control_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo);
  1379. CARLA_ASSERT(fData->oscData != nullptr);
  1380. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1381. CARLA_ASSERT(channel >= 0 && channel < 16);
  1382. CARLA_ASSERT(note >= 0 && note < 128);
  1383. CARLA_ASSERT(velo > 0 && velo < 128);
  1384. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1385. {
  1386. char target_path[strlen(fData->oscData->path)+9];
  1387. strcpy(target_path, fData->oscData->path);
  1388. strcat(target_path, "/note_on");
  1389. lo_send(fData->oscData->target, target_path, "iiii", pluginId, channel, note, velo);
  1390. }
  1391. }
  1392. void CarlaEngine::osc_send_control_note_off(const int32_t pluginId, const int32_t channel, const int32_t note)
  1393. {
  1394. qDebug("CarlaEngine::osc_send_control_note_off(%i, %i, %i)", pluginId, channel, note);
  1395. CARLA_ASSERT(fData->oscData != nullptr);
  1396. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1397. CARLA_ASSERT(channel >= 0 && channel < 16);
  1398. CARLA_ASSERT(note >= 0 && note < 128);
  1399. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1400. {
  1401. char target_path[strlen(fData->oscData->path)+10];
  1402. strcpy(target_path, fData->oscData->path);
  1403. strcat(target_path, "/note_off");
  1404. lo_send(fData->oscData->target, target_path, "iii", pluginId, channel, note);
  1405. }
  1406. }
  1407. #if 0
  1408. void CarlaEngine::osc_send_control_set_input_peak_value(const int32_t pluginId, const int32_t portId)
  1409. {
  1410. //qDebug("CarlaEngine::osc_send_control_set_input_peak_value(%i, %i)", pluginId, portId);
  1411. CARLA_ASSERT(fData->oscData != nullptr);
  1412. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1413. CARLA_ASSERT(portId == 1 || portId == 2);
  1414. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1415. {
  1416. char target_path[strlen(fData->oscData->path)+22];
  1417. strcpy(target_path, fData->oscData->path);
  1418. strcat(target_path, "/set_input_peak_value");
  1419. lo_send(fData->oscData->target, target_path, "iid", pluginId, portId, data->insPeak[pluginId*MAX_PEAKS + portId-1]);
  1420. }
  1421. }
  1422. void CarlaEngine::osc_send_control_set_output_peak_value(const int32_t pluginId, const int32_t portId)
  1423. {
  1424. //qDebug("CarlaEngine::osc_send_control_set_output_peak_value(%i, %i)", pluginId, portId);
  1425. CARLA_ASSERT(fData->oscData != nullptr);
  1426. CARLA_ASSERT(pluginId >= 0 && pluginId < (int32_t)fData->maxPluginNumber);
  1427. CARLA_ASSERT(portId == 1 || portId == 2);
  1428. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1429. {
  1430. char target_path[strlen(fData->oscData->path)+23];
  1431. strcpy(target_path, fData->oscData->path);
  1432. strcat(target_path, "/set_output_peak_value");
  1433. lo_send(fData->oscData->target, target_path, "iid", pluginId, portId, data->outsPeak[pluginId*MAX_PEAKS + portId-1]);
  1434. }
  1435. }
  1436. #endif
  1437. void CarlaEngine::osc_send_control_exit()
  1438. {
  1439. qDebug("CarlaEngine::osc_send_control_exit()");
  1440. CARLA_ASSERT(fData->oscData);
  1441. if (fData->oscData && fData->oscData->target)
  1442. {
  1443. char target_path[strlen(fData->oscData->path)+6];
  1444. strcpy(target_path, fData->oscData->path);
  1445. strcat(target_path, "/exit");
  1446. lo_send(fData->oscData->target, target_path, "");
  1447. }
  1448. }
  1449. #else
  1450. void CarlaEngine::osc_send_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total)
  1451. {
  1452. qDebug("CarlaEngine::osc_send_bridge_audio_count(%i, %i, %i)", ins, outs, total);
  1453. CARLA_ASSERT(fData->oscData != nullptr);
  1454. CARLA_ASSERT(total >= 0 && total >= ins + outs);
  1455. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1456. {
  1457. char target_path[strlen(fData->oscData->path)+20];
  1458. strcpy(target_path, fData->oscData->path);
  1459. strcat(target_path, "/bridge_audio_count");
  1460. lo_send(fData->oscData->target, target_path, "iii", ins, outs, total);
  1461. }
  1462. }
  1463. void CarlaEngine::osc_send_bridge_midi_count(const int32_t ins, const int32_t outs, const int32_t total)
  1464. {
  1465. qDebug("CarlaEngine::osc_send_bridge_midi_count(%i, %i, %i)", ins, outs, total);
  1466. CARLA_ASSERT(fData->oscData != nullptr);
  1467. CARLA_ASSERT(total >= 0 && total >= ins + outs);
  1468. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1469. {
  1470. char target_path[strlen(fData->oscData->path)+19];
  1471. strcpy(target_path, fData->oscData->path);
  1472. strcat(target_path, "/bridge_midi_count");
  1473. lo_send(fData->oscData->target, target_path, "iii", ins, outs, total);
  1474. }
  1475. }
  1476. void CarlaEngine::osc_send_bridge_parameter_count(const int32_t ins, const int32_t outs, const int32_t total)
  1477. {
  1478. qDebug("CarlaEngine::osc_send_bridge_parameter_count(%i, %i, %i)", ins, outs, total);
  1479. CARLA_ASSERT(fData->oscData != nullptr);
  1480. CARLA_ASSERT(total >= 0 && total >= ins + outs);
  1481. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1482. {
  1483. char target_path[strlen(fData->oscData->path)+24];
  1484. strcpy(target_path, fData->oscData->path);
  1485. strcat(target_path, "/bridge_parameter_count");
  1486. lo_send(fData->oscData->target, target_path, "iii", ins, outs, total);
  1487. }
  1488. }
  1489. void CarlaEngine::osc_send_bridge_program_count(const int32_t count)
  1490. {
  1491. qDebug("CarlaEngine::osc_send_bridge_program_count(%i)", count);
  1492. CARLA_ASSERT(fData->oscData != nullptr);
  1493. CARLA_ASSERT(count >= 0);
  1494. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1495. {
  1496. char target_path[strlen(fData->oscData->path)+22];
  1497. strcpy(target_path, fData->oscData->path);
  1498. strcat(target_path, "/bridge_program_count");
  1499. lo_send(fData->oscData->target, target_path, "i", count);
  1500. }
  1501. }
  1502. void CarlaEngine::osc_send_bridge_midi_program_count(const int32_t count)
  1503. {
  1504. qDebug("CarlaEngine::osc_send_bridge_midi_program_count(%i)", count);
  1505. CARLA_ASSERT(fData->oscData != nullptr);
  1506. CARLA_ASSERT(count >= 0);
  1507. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1508. {
  1509. char target_path[strlen(fData->oscData->path)+27];
  1510. strcpy(target_path, fData->oscData->path);
  1511. strcat(target_path, "/bridge_midi_program_count");
  1512. lo_send(fData->oscData->target, target_path, "i", count);
  1513. }
  1514. }
  1515. 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)
  1516. {
  1517. qDebug("CarlaEngine::osc_send_bridge_plugin_info(%i, %i, \"%s\", \"%s\", \"%s\", \"%s\", " P_INT64 ")", category, hints, name, label, maker, copyright, uniqueId);
  1518. CARLA_ASSERT(fData->oscData != nullptr);
  1519. CARLA_ASSERT(name);
  1520. CARLA_ASSERT(label);
  1521. CARLA_ASSERT(maker);
  1522. CARLA_ASSERT(copyright);
  1523. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1524. {
  1525. char target_path[strlen(fData->oscData->path)+20];
  1526. strcpy(target_path, fData->oscData->path);
  1527. strcat(target_path, "/bridge_plugin_info");
  1528. lo_send(fData->oscData->target, target_path, "iissssh", category, hints, name, label, maker, copyright, uniqueId);
  1529. }
  1530. }
  1531. void CarlaEngine::osc_send_bridge_parameter_info(const int32_t index, const char* const name, const char* const unit)
  1532. {
  1533. qDebug("CarlaEngine::osc_send_bridge_parameter_info(%i, \"%s\", \"%s\")", index, name, unit);
  1534. CARLA_ASSERT(fData->oscData != nullptr);
  1535. CARLA_ASSERT(name);
  1536. CARLA_ASSERT(unit);
  1537. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1538. {
  1539. char target_path[strlen(fData->oscData->path)+23];
  1540. strcpy(target_path, fData->oscData->path);
  1541. strcat(target_path, "/bridge_parameter_info");
  1542. lo_send(fData->oscData->target, target_path, "iss", index, name, unit);
  1543. }
  1544. }
  1545. 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)
  1546. {
  1547. qDebug("CarlaEngine::osc_send_bridge_parameter_data(%i, %i, %i, %i, %i, %i)", index, type, rindex, hints, midiChannel, midiCC);
  1548. CARLA_ASSERT(fData->oscData != nullptr);
  1549. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1550. {
  1551. char target_path[strlen(fData->oscData->path)+23];
  1552. strcpy(target_path, fData->oscData->path);
  1553. strcat(target_path, "/bridge_parameter_data");
  1554. lo_send(fData->oscData->target, target_path, "iiiiii", index, type, rindex, hints, midiChannel, midiCC);
  1555. }
  1556. }
  1557. 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)
  1558. {
  1559. qDebug("CarlaEngine::osc_send_bridge_parameter_ranges(%i, %g, %g, %g, %g, %g, %g)", index, def, min, max, step, stepSmall, stepLarge);
  1560. CARLA_ASSERT(fData->oscData != nullptr);
  1561. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1562. {
  1563. char target_path[strlen(fData->oscData->path)+25];
  1564. strcpy(target_path, fData->oscData->path);
  1565. strcat(target_path, "/bridge_parameter_ranges");
  1566. lo_send(fData->oscData->target, target_path, "idddddd", index, def, min, max, step, stepSmall, stepLarge);
  1567. }
  1568. }
  1569. void CarlaEngine::osc_send_bridge_program_info(const int32_t index, const char* const name)
  1570. {
  1571. qDebug("CarlaEngine::osc_send_bridge_program_info(%i, \"%s\")", index, name);
  1572. CARLA_ASSERT(fData->oscData != nullptr);
  1573. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1574. {
  1575. char target_path[strlen(fData->oscData->path)+21];
  1576. strcpy(target_path, fData->oscData->path);
  1577. strcat(target_path, "/bridge_program_info");
  1578. lo_send(fData->oscData->target, target_path, "is", index, name);
  1579. }
  1580. }
  1581. void CarlaEngine::osc_send_bridge_midi_program_info(const int32_t index, const int32_t bank, const int32_t program, const char* const label)
  1582. {
  1583. qDebug("CarlaEngine::osc_send_bridge_midi_program_info(%i, %i, %i, \"%s\")", index, bank, program, label);
  1584. CARLA_ASSERT(fData->oscData != nullptr);
  1585. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1586. {
  1587. char target_path[strlen(fData->oscData->path)+26];
  1588. strcpy(target_path, fData->oscData->path);
  1589. strcat(target_path, "/bridge_midi_program_info");
  1590. lo_send(fData->oscData->target, target_path, "iiis", index, bank, program, label);
  1591. }
  1592. }
  1593. void CarlaEngine::osc_send_bridge_configure(const char* const key, const char* const value)
  1594. {
  1595. qDebug("CarlaEngine::osc_send_bridge_configure(\"%s\", \"%s\")", key, value);
  1596. CARLA_ASSERT(fData->oscData != nullptr);
  1597. CARLA_ASSERT(key);
  1598. CARLA_ASSERT(value);
  1599. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1600. {
  1601. char target_path[strlen(fData->oscData->path)+18];
  1602. strcpy(target_path, fData->oscData->path);
  1603. strcat(target_path, "/bridge_configure");
  1604. lo_send(fData->oscData->target, target_path, "ss", key, value);
  1605. }
  1606. }
  1607. void CarlaEngine::osc_send_bridge_set_parameter_value(const int32_t index, const double value)
  1608. {
  1609. qDebug("CarlaEngine::osc_send_bridge_set_parameter_value(%i, %g)", index, value);
  1610. CARLA_ASSERT(fData->oscData != nullptr);
  1611. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1612. {
  1613. char target_path[strlen(fData->oscData->path)+28];
  1614. strcpy(target_path, fData->oscData->path);
  1615. strcat(target_path, "/bridge_set_parameter_value");
  1616. lo_send(fData->oscData->target, target_path, "id", index, value);
  1617. }
  1618. }
  1619. void CarlaEngine::osc_send_bridge_set_default_value(const int32_t index, const double value)
  1620. {
  1621. qDebug("CarlaEngine::osc_send_bridge_set_default_value(%i, %g)", index, value);
  1622. CARLA_ASSERT(fData->oscData != nullptr);
  1623. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1624. {
  1625. char target_path[strlen(fData->oscData->path)+26];
  1626. strcpy(target_path, fData->oscData->path);
  1627. strcat(target_path, "/bridge_set_default_value");
  1628. lo_send(fData->oscData->target, target_path, "id", index, value);
  1629. }
  1630. }
  1631. void CarlaEngine::osc_send_bridge_set_program(const int32_t index)
  1632. {
  1633. qDebug("CarlaEngine::osc_send_bridge_set_program(%i)", index);
  1634. CARLA_ASSERT(fData->oscData != nullptr);
  1635. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1636. {
  1637. char target_path[strlen(fData->oscData->path)+20];
  1638. strcpy(target_path, fData->oscData->path);
  1639. strcat(target_path, "/bridge_set_program");
  1640. lo_send(fData->oscData->target, target_path, "i", index);
  1641. }
  1642. }
  1643. void CarlaEngine::osc_send_bridge_set_midi_program(const int32_t index)
  1644. {
  1645. qDebug("CarlaEngine::osc_send_bridge_set_midi_program(%i)", index);
  1646. CARLA_ASSERT(fData->oscData != nullptr);
  1647. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1648. {
  1649. char target_path[strlen(fData->oscData->path)+25];
  1650. strcpy(target_path, fData->oscData->path);
  1651. strcat(target_path, "/bridge_set_midi_program");
  1652. lo_send(fData->oscData->target, target_path, "i", index);
  1653. }
  1654. }
  1655. void CarlaEngine::osc_send_bridge_set_custom_data(const char* const type, const char* const key, const char* const value)
  1656. {
  1657. qDebug("CarlaEngine::osc_send_bridge_set_custom_data(\"%s\", \"%s\", \"%s\")", type, key, value);
  1658. CARLA_ASSERT(fData->oscData);
  1659. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1660. {
  1661. char target_path[strlen(fData->oscData->path)+24];
  1662. strcpy(target_path, fData->oscData->path);
  1663. strcat(target_path, "/bridge_set_custom_data");
  1664. lo_send(fData->oscData->target, target_path, "sss", type, key, value);
  1665. }
  1666. }
  1667. void CarlaEngine::osc_send_bridge_set_chunk_data(const char* const chunkFile)
  1668. {
  1669. qDebug("CarlaEngine::osc_send_bridge_set_chunk_data(\"%s\")", chunkFile);
  1670. CARLA_ASSERT(fData->oscData != nullptr);
  1671. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1672. {
  1673. char target_path[strlen(fData->oscData->path)+23];
  1674. strcpy(target_path, fData->oscData->path);
  1675. strcat(target_path, "/bridge_set_chunk_data");
  1676. lo_send(fData->oscData->target, target_path, "s", chunkFile);
  1677. }
  1678. }
  1679. #if 0
  1680. void CarlaEngine::osc_send_bridge_set_inpeak(const int32_t portId)
  1681. {
  1682. CARLA_ASSERT(fData->oscData != nullptr);
  1683. CARLA_ASSERT(portId == 1 || portId == 2);
  1684. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1685. {
  1686. char target_path[strlen(fData->oscData->path)+28];
  1687. strcpy(target_path, fData->oscData->path);
  1688. strcat(target_path, "/bridge_set_inpeak");
  1689. lo_send(fData->oscData->target, target_path, "id", portId, data->insPeak[portId-1]);
  1690. }
  1691. }
  1692. void CarlaEngine::osc_send_bridge_set_outpeak(const int32_t portId)
  1693. {
  1694. CARLA_ASSERT(fData->oscData != nullptr);
  1695. CARLA_ASSERT(portId == 1 || portId == 2);
  1696. if (fData->oscData != nullptr && fData->oscData->target != nullptr)
  1697. {
  1698. char target_path[strlen(fData->oscData->path)+29];
  1699. strcpy(target_path, fData->oscData->path);
  1700. strcat(target_path, "/bridge_set_outpeak");
  1701. lo_send(fData->oscData->target, target_path, "id", portId, data->insPeak[portId-1]);
  1702. }
  1703. }
  1704. #endif
  1705. #endif
  1706. CARLA_BACKEND_END_NAMESPACE