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.

2013 lines
63KB

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