Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1956 lines
60KB

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