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.

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