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.

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