Collection of tools useful for audio production
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.

1907 lines
57KB

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