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.

2010 lines
62KB

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