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.

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