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.

2026 lines
61KB

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