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.

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