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.

743 lines
22KB

  1. /*
  2. * Carla Engine OSC
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or 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 GPL.txt file
  16. */
  17. #include "carla_engine.hpp"
  18. #include "carla_engine_osc.hpp"
  19. #include "carla_plugin.hpp"
  20. #include "carla_midi.h"
  21. CARLA_BACKEND_START_NAMESPACE
  22. // -----------------------------------------------------------------------
  23. CarlaEngineOsc::CarlaEngineOsc(CarlaEngine* const engine)
  24. : kEngine(engine),
  25. fServerTCP(nullptr),
  26. fServerUDP(nullptr)
  27. {
  28. qDebug("CarlaEngineOsc::CarlaEngineOsc(%p)", engine);
  29. CARLA_ASSERT(engine != nullptr);
  30. }
  31. CarlaEngineOsc::~CarlaEngineOsc()
  32. {
  33. qDebug("CarlaEngineOsc::~CarlaEngineOsc()");
  34. CARLA_ASSERT(fName.isEmpty());
  35. CARLA_ASSERT(fServerPathTCP.isEmpty());
  36. CARLA_ASSERT(fServerPathUDP.isEmpty());
  37. CARLA_ASSERT(fServerTCP == nullptr);
  38. CARLA_ASSERT(fServerUDP == nullptr);
  39. }
  40. // -----------------------------------------------------------------------
  41. void CarlaEngineOsc::init(const char* const name)
  42. {
  43. qDebug("CarlaEngineOsc::init(\"%s\")", name);
  44. CARLA_ASSERT(fName.isEmpty());
  45. CARLA_ASSERT(fServerPathTCP.isEmpty());
  46. CARLA_ASSERT(fServerPathUDP.isEmpty());
  47. CARLA_ASSERT(fServerTCP == nullptr);
  48. CARLA_ASSERT(fServerUDP == nullptr);
  49. CARLA_ASSERT(name);
  50. fName = name;
  51. fName.toBasic();
  52. fServerTCP = lo_server_new_with_proto(nullptr, LO_TCP, osc_error_handler_TCP);
  53. if (fServerTCP != nullptr)
  54. {
  55. if (char* const tmpServerPathTCP = lo_server_get_url(fServerTCP))
  56. {
  57. fServerPathTCP = tmpServerPathTCP;
  58. fServerPathTCP += fName;
  59. free(tmpServerPathTCP);
  60. }
  61. lo_server_add_method(fServerTCP, nullptr, nullptr, osc_message_handler, this);
  62. }
  63. fServerUDP = lo_server_new_with_proto(nullptr, LO_UDP, osc_error_handler_UDP);
  64. if (fServerUDP != nullptr)
  65. {
  66. if (char* const tmpServerPathUDP = lo_server_get_url(fServerUDP))
  67. {
  68. fServerPathUDP = tmpServerPathUDP;
  69. fServerPathUDP += fName;
  70. free(tmpServerPathUDP);
  71. }
  72. lo_server_add_method(fServerUDP, nullptr, nullptr, osc_message_handler, this);
  73. }
  74. }
  75. void CarlaEngineOsc::idle()
  76. {
  77. if (fServerTCP != nullptr)
  78. {
  79. while (lo_server_recv_noblock(fServerTCP, 0) != 0) {}
  80. }
  81. if (fServerUDP != nullptr)
  82. {
  83. while (lo_server_recv_noblock(fServerUDP, 0) != 0) {}
  84. }
  85. }
  86. void CarlaEngineOsc::close()
  87. {
  88. qDebug("CarlaEngineOsc::close()");
  89. CARLA_ASSERT(fName.isNotEmpty());
  90. CARLA_ASSERT(fServerPathTCP.isNotEmpty());
  91. CARLA_ASSERT(fServerPathUDP.isNotEmpty());
  92. CARLA_ASSERT(fServerTCP != nullptr);
  93. CARLA_ASSERT(fServerUDP != nullptr);
  94. fName.clear();
  95. if (fServerTCP != nullptr)
  96. {
  97. lo_server_del_method(fServerTCP, nullptr, nullptr);
  98. lo_server_free(fServerTCP);
  99. fServerTCP = nullptr;
  100. }
  101. if (fServerUDP != nullptr)
  102. {
  103. lo_server_del_method(fServerUDP, nullptr, nullptr);
  104. lo_server_free(fServerUDP);
  105. fServerUDP = nullptr;
  106. }
  107. fServerPathTCP.clear();
  108. fServerPathUDP.clear();
  109. #ifndef BUILD_BRIDGE
  110. fControlData.free();
  111. #endif
  112. }
  113. // -----------------------------------------------------------------------
  114. bool isDigit(const char c)
  115. {
  116. return (c >= '0' && c <= '9');
  117. }
  118. int CarlaEngineOsc::handleMessage(const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg)
  119. {
  120. #if DEBUG
  121. qDebug("CarlaEngineOsc::handleMessage(%s, %i, %p, %s, %p)", path, argc, argv, types, msg);
  122. #endif
  123. CARLA_ASSERT(fName.isNotEmpty());
  124. CARLA_ASSERT(fServerPathTCP.isNotEmpty() || fServerPathUDP.isNotEmpty());
  125. CARLA_ASSERT(fServerTCP != nullptr || fServerUDP != nullptr);
  126. CARLA_ASSERT(path != nullptr);
  127. if (path == nullptr)
  128. {
  129. qCritical("CarlaEngineOsc::handleMessage() - got invalid path");
  130. return 1;
  131. }
  132. if (fName.isEmpty())
  133. {
  134. qCritical("CarlaEngineOsc::handleMessage(\"%s\", ...) - received message but client is offline", path);
  135. return 1;
  136. }
  137. #ifndef BUILD_BRIDGE
  138. // Initial path check
  139. if (strcmp(path, "/register") == 0)
  140. {
  141. const lo_address source = lo_message_get_source(msg);
  142. return handleMsgRegister(argc, argv, types, source);
  143. }
  144. if (strcmp(path, "/unregister") == 0)
  145. {
  146. return handleMsgUnregister();
  147. }
  148. #endif
  149. const size_t nameSize = fName.length();
  150. // Check if message is for this client
  151. if (std::strlen(path) <= nameSize || std::strncmp(path+1, (const char*)fName, nameSize) != 0)
  152. {
  153. qWarning("CarlaEngineOsc::handleMessage() - message not for this client -> '%s' != '/%s/'", path, (const char*)fName);
  154. return 1;
  155. }
  156. // Get plugin id from message
  157. // eg, /carla/23/method
  158. unsigned int pluginId = 0;
  159. if (isDigit(path[nameSize+2]))
  160. {
  161. if (isDigit(path[nameSize+3]))
  162. {
  163. if (isDigit(path[nameSize+5]))
  164. {
  165. qCritical("CarlaEngineOsc::handleMessage() - invalid plugin id, over 999? (value: \"%s\")", path+nameSize);
  166. return 1;
  167. }
  168. else if (isDigit(path[nameSize+4]))
  169. {
  170. // 3 digits, /xyz/method
  171. pluginId += (path[nameSize+2]-'0')*100;
  172. pluginId += (path[nameSize+3]-'0')*10;
  173. pluginId += (path[nameSize+4]-'0');
  174. }
  175. else
  176. {
  177. // 2 digits, /xy/method
  178. pluginId += (path[nameSize+2]-'0')*10;
  179. pluginId += (path[nameSize+3]-'0');
  180. }
  181. }
  182. else
  183. {
  184. // single digit, /x/method
  185. pluginId += path[nameSize+2]-'0';
  186. }
  187. }
  188. if (pluginId > kEngine->currentPluginCount())
  189. {
  190. qCritical("CarlaEngineOsc::handleMessage() - failed to get plugin, wrong id '%i'", pluginId);
  191. return 1;
  192. }
  193. // Get plugin
  194. CarlaPlugin* const plugin = kEngine->getPluginUnchecked(pluginId);
  195. if (plugin == nullptr || plugin->id() != pluginId)
  196. {
  197. qWarning("CarlaEngineOsc::handleMessage() - invalid plugin id '%i', probably has been removed", pluginId);
  198. return 1;
  199. }
  200. // Get method from path, "/Carla/i/method" -> "method"
  201. const int offset = (pluginId >= 10) ? 5 : 4;
  202. char method[32] = { 0 };
  203. strncpy(method, path + (nameSize + offset), 31);
  204. if (method[0] == '\0')
  205. {
  206. qWarning("CarlaEngineOsc::handleMessage(\"%s\", ...) - received message without method", path);
  207. return 1;
  208. }
  209. // Common OSC methods (DSSI and internal UIs)
  210. if (strcmp(method, "update") == 0)
  211. {
  212. const lo_address source = lo_message_get_source(msg);
  213. return handleMsgUpdate(plugin, argc, argv, types, source);
  214. }
  215. if (strcmp(method, "configure") == 0)
  216. return handleMsgConfigure(plugin, argc, argv, types);
  217. if (strcmp(method, "control") == 0)
  218. return handleMsgControl(plugin, argc, argv, types);
  219. if (strcmp(method, "program") == 0)
  220. return handleMsgProgram(plugin, argc, argv, types);
  221. if (strcmp(method, "midi") == 0)
  222. return handleMsgMidi(plugin, argc, argv, types);
  223. if (strcmp(method, "exiting") == 0)
  224. return handleMsgExiting(plugin);
  225. #ifndef BUILD_BRIDGE
  226. // Internal methods
  227. if (strcmp(method, "set_active") == 0)
  228. return handleMsgSetActive(plugin, argc, argv, types);
  229. if (strcmp(method, "set_drywet") == 0)
  230. return handleMsgSetDryWet(plugin, argc, argv, types);
  231. if (strcmp(method, "set_volume") == 0)
  232. return handleMsgSetVolume(plugin, argc, argv, types);
  233. if (strcmp(method, "set_balance_left") == 0)
  234. return handleMsgSetBalanceLeft(plugin, argc, argv, types);
  235. if (strcmp(method, "set_balance_right") == 0)
  236. return handleMsgSetBalanceRight(plugin, argc, argv, types);
  237. if (strcmp(method, "set_parameter_value") == 0)
  238. return handleMsgSetParameterValue(plugin, argc, argv, types);
  239. if (strcmp(method, "set_parameter_midi_cc") == 0)
  240. return handleMsgSetParameterMidiCC(plugin, argc, argv, types);
  241. if (strcmp(method, "set_parameter_midi_channel") == 0)
  242. return handleMsgSetParameterMidiChannel(plugin, argc, argv, types);
  243. if (strcmp(method, "set_program") == 0)
  244. return handleMsgSetProgram(plugin, argc, argv, types);
  245. if (strcmp(method, "set_midi_program") == 0)
  246. return handleMsgSetMidiProgram(plugin, argc, argv, types);
  247. if (strcmp(method, "note_on") == 0)
  248. return handleMsgNoteOn(plugin, argc, argv, types);
  249. if (strcmp(method, "note_off") == 0)
  250. return handleMsgNoteOff(plugin, argc, argv, types);
  251. #if 0 // FIXME
  252. // Plugin Bridges
  253. if ((plugin->hints() & PLUGIN_IS_BRIDGE) > 0 && strlen(method) > 11 && strncmp(method, "bridge_", 7) == 0)
  254. {
  255. if (strcmp(method+7, "set_inpeak") == 0)
  256. return handleMsgBridgeSetInPeak(plugin, argc, argv, types);
  257. if (strcmp(method+7, "set_outpeak") == 0)
  258. return handleMsgBridgeSetOutPeak(plugin, argc, argv, types);
  259. if (strcmp(method+7, "audio_count") == 0)
  260. return plugin->setOscBridgeInfo(PluginBridgeAudioCount, argc, argv, types);
  261. if (strcmp(method+7, "midi_count") == 0)
  262. return plugin->setOscBridgeInfo(PluginBridgeMidiCount, argc, argv, types);
  263. if (strcmp(method+7, "parameter_count") == 0)
  264. return plugin->setOscBridgeInfo(PluginBridgeParameterCount, argc, argv, types);
  265. if (strcmp(method+7, "program_count") == 0)
  266. return plugin->setOscBridgeInfo(PluginBridgeProgramCount, argc, argv, types);
  267. if (strcmp(method+7, "midi_program_count") == 0)
  268. return plugin->setOscBridgeInfo(PluginBridgeMidiProgramCount, argc, argv, types);
  269. if (strcmp(method+7, "plugin_info") == 0)
  270. return plugin->setOscBridgeInfo(PluginBridgePluginInfo, argc, argv, types);
  271. if (strcmp(method+7, "parameter_info") == 0)
  272. return plugin->setOscBridgeInfo(PluginBridgeParameterInfo, argc, argv, types);
  273. if (strcmp(method+7, "parameter_data") == 0)
  274. return plugin->setOscBridgeInfo(PluginBridgeParameterData, argc, argv, types);
  275. if (strcmp(method+7, "parameter_ranges") == 0)
  276. return plugin->setOscBridgeInfo(PluginBridgeParameterRanges, argc, argv, types);
  277. if (strcmp(method+7, "program_info") == 0)
  278. return plugin->setOscBridgeInfo(PluginBridgeProgramInfo, argc, argv, types);
  279. if (strcmp(method+7, "midi_program_info") == 0)
  280. return plugin->setOscBridgeInfo(PluginBridgeMidiProgramInfo, argc, argv, types);
  281. if (strcmp(method+7, "configure") == 0)
  282. return plugin->setOscBridgeInfo(PluginBridgeConfigure, argc, argv, types);
  283. if (strcmp(method+7, "set_parameter_value") == 0)
  284. return plugin->setOscBridgeInfo(PluginBridgeSetParameterValue, argc, argv, types);
  285. if (strcmp(method+7, "set_default_value") == 0)
  286. return plugin->setOscBridgeInfo(PluginBridgeSetDefaultValue, argc, argv, types);
  287. if (strcmp(method+7, "set_program") == 0)
  288. return plugin->setOscBridgeInfo(PluginBridgeSetProgram, argc, argv, types);
  289. if (strcmp(method+7, "set_midi_program") == 0)
  290. return plugin->setOscBridgeInfo(PluginBridgeSetMidiProgram, argc, argv, types);
  291. if (strcmp(method+7, "set_custom_data") == 0)
  292. return plugin->setOscBridgeInfo(PluginBridgeSetCustomData, argc, argv, types);
  293. if (strcmp(method+7, "set_chunk_data") == 0)
  294. return plugin->setOscBridgeInfo(PluginBridgeSetChunkData, argc, argv, types);
  295. if (strcmp(method+7, "update") == 0)
  296. return plugin->setOscBridgeInfo(PluginBridgeUpdateNow, argc, argv, types);
  297. if (strcmp(method+7, "error") == 0)
  298. return plugin->setOscBridgeInfo(PluginBridgeError, argc, argv, types);
  299. }
  300. #endif
  301. #endif
  302. // Plugin-specific methods, FIXME
  303. #if 0 //def WANT_LV2
  304. if (strcmp(method, "lv2_atom_transfer") == 0)
  305. return handleMsgLv2AtomTransfer(plugin, argc, argv, types);
  306. if (strcmp(method, "lv2_event_transfer") == 0)
  307. return handleMsgLv2EventTransfer(plugin, argc, argv, types);
  308. #endif
  309. qWarning("CarlaEngineOsc::handleMessage() - unsupported OSC method '%s'", method);
  310. return 1;
  311. }
  312. // -----------------------------------------------------------------------
  313. #ifndef BUILD_BRIDGE
  314. int CarlaEngineOsc::handleMsgRegister(const int argc, const lo_arg* const* const argv, const char* const types, const lo_address source)
  315. {
  316. qDebug("CarlaEngineOsc::handleMsgRegister()");
  317. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "s");
  318. if (m_controlData.path)
  319. {
  320. qWarning("CarlaEngineOsc::handleMsgRegister() - OSC backend already registered to %s", m_controlData.path);
  321. return 1;
  322. }
  323. const char* const url = (const char*)&argv[0]->s;
  324. const char* host;
  325. const char* port;
  326. qDebug("CarlaEngineOsc::handleMsgRegister() - OSC backend registered to %s", url);
  327. host = lo_address_get_hostname(source);
  328. port = lo_address_get_port(source);
  329. m_controlData.source = lo_address_new_with_proto(LO_TCP, host, port);
  330. host = lo_url_get_hostname(url);
  331. port = lo_url_get_port(url);
  332. m_controlData.path = lo_url_get_path(url);
  333. m_controlData.target = lo_address_new_with_proto(LO_TCP, host, port);
  334. free((void*)host);
  335. free((void*)port);
  336. #if 0
  337. for (unsigned short i=0; i < engine->maxPluginNumber(); i++)
  338. {
  339. CarlaPlugin* const plugin = engine->getPluginUnchecked(i);
  340. if (plugin && plugin->enabled())
  341. plugin->registerToOscClient();
  342. }
  343. #endif
  344. return 0;
  345. }
  346. int CarlaEngineOsc::handleMsgUnregister()
  347. {
  348. qDebug("CarlaEngineOsc::handleMsgUnregister()");
  349. if (! m_controlData.path)
  350. {
  351. qWarning("CarlaEngineOsc::handleMsgUnregister() - OSC backend is not registered yet");
  352. return 1;
  353. }
  354. m_controlData.free();
  355. return 0;
  356. }
  357. #endif
  358. // -----------------------------------------------------------------------
  359. int CarlaEngineOsc::handleMsgUpdate(CARLA_ENGINE_OSC_HANDLE_ARGS2, const lo_address source)
  360. {
  361. qDebug("CarlaEngineOsc::handleMsgUpdate()");
  362. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "s");
  363. const char* const url = (const char*)&argv[0]->s;
  364. plugin->updateOscData(source, url);
  365. return 0;
  366. }
  367. int CarlaEngineOsc::handleMsgConfigure(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  368. {
  369. qDebug("CarlaEngineOsc::handleMsgConfigure()");
  370. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "ss");
  371. const char* const key = (const char*)&argv[0]->s;
  372. const char* const value = (const char*)&argv[1]->s;
  373. // FIXME
  374. plugin->setCustomData("CUSTOM_DATA_STRING", key, value, false);
  375. return 0;
  376. }
  377. int CarlaEngineOsc::handleMsgControl(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  378. {
  379. qDebug("CarlaEngineOsc::handleMsgControl()");
  380. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "if");
  381. const int32_t rindex = argv[0]->i;
  382. const float value = argv[1]->f;
  383. plugin->setParameterValueByRIndex(rindex, value, false, true, true);
  384. return 0;
  385. }
  386. int CarlaEngineOsc::handleMsgProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  387. {
  388. qDebug("CarlaEngineOsc::handleMsgProgram()");
  389. if (argc == 2)
  390. {
  391. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "ii");
  392. const uint32_t bank = argv[0]->i;
  393. const uint32_t program = argv[1]->i;
  394. plugin->setMidiProgramById(bank, program, false, true, true, true);
  395. return 0;
  396. }
  397. else
  398. {
  399. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "i");
  400. const uint32_t program = argv[0]->i;
  401. if (program < plugin->programCount())
  402. {
  403. plugin->setProgram(program, false, true, true, true);
  404. return 0;
  405. }
  406. qCritical("CarlaEngineOsc::handleMsgProgram() - program_id '%i' out of bounds", program);
  407. }
  408. return 1;
  409. }
  410. int CarlaEngineOsc::handleMsgMidi(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  411. {
  412. qDebug("CarlaEngineOsc::handleMsgMidi()");
  413. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "m");
  414. if (plugin->midiInCount() > 0)
  415. {
  416. #if 0
  417. const uint8_t* const data = argv[0]->m;
  418. uint8_t status = data[1];
  419. uint8_t channel = status & 0x0F;
  420. // Fix bad note-off
  421. if (MIDI_IS_STATUS_NOTE_ON(status) && data[3] == 0)
  422. status -= 0x10;
  423. if (MIDI_IS_STATUS_NOTE_OFF(status))
  424. {
  425. uint8_t note = data[2];
  426. plugin->sendMidiSingleNote(channel, note, 0, false, true, true);
  427. }
  428. else if (MIDI_IS_STATUS_NOTE_ON(status))
  429. {
  430. uint8_t note = data[2];
  431. uint8_t velo = data[3];
  432. plugin->sendMidiSingleNote(channel, note, velo, false, true, true);
  433. }
  434. #endif
  435. return 0;
  436. }
  437. qWarning("CarlaEngineOsc::handleMsgMidi() - recived midi when plugin has no midi inputs");
  438. return 1;
  439. }
  440. int CarlaEngineOsc::handleMsgExiting(CARLA_ENGINE_OSC_HANDLE_ARGS1)
  441. {
  442. qDebug("CarlaEngineOsc::handleMsgExiting()");
  443. // TODO - check for non-UIs (dssi-vst) and set to -1 instead
  444. kEngine->callback(CALLBACK_SHOW_GUI, plugin->id(), 0, 0, 0.0f, nullptr);
  445. plugin->freeOscData();
  446. return 0;
  447. }
  448. // -----------------------------------------------------------------------
  449. #ifndef BUILD_BRIDGE
  450. int CarlaEngineOsc::handleMsgSetActive(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  451. {
  452. qDebug("CarlaEngineOsc::handleMsgSetActive()");
  453. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "i");
  454. #if 0
  455. const bool active = (bool)argv[0]->i;
  456. plugin->setActive(active, false, true);
  457. #endif
  458. return 0;
  459. }
  460. int CarlaEngineOsc::handleMsgSetDryWet(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  461. {
  462. qDebug("CarlaEngineOsc::handleMsgSetDryWet()");
  463. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  464. #if 0
  465. const float value = argv[0]->f;
  466. plugin->setDryWet(value, false, true);
  467. #endif
  468. return 0;
  469. }
  470. int CarlaEngineOsc::handleMsgSetVolume(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  471. {
  472. qDebug("CarlaEngineOsc::handleMsgSetVolume()");
  473. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  474. #if 0
  475. const float value = argv[0]->f;
  476. plugin->setVolume(value, false, true);
  477. #endif
  478. return 0;
  479. }
  480. int CarlaEngineOsc::handleMsgSetBalanceLeft(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  481. {
  482. qDebug("CarlaEngineOsc::handleMsgSetBalanceLeft()");
  483. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  484. #if 0
  485. const float value = argv[0]->f;
  486. plugin->setBalanceLeft(value, false, true);
  487. #endif
  488. return 0;
  489. }
  490. int CarlaEngineOsc::handleMsgSetBalanceRight(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  491. {
  492. qDebug("CarlaEngineOsc::handleMsgSetBalanceRight()");
  493. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  494. #if 0
  495. const float value = argv[0]->f;
  496. plugin->setBalanceRight(value, false, true);
  497. #endif
  498. return 0;
  499. }
  500. int CarlaEngineOsc::handleMsgSetParameterValue(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  501. {
  502. qDebug("CarlaEngineOsc::handleMsgSetParameterValue()");
  503. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "if");
  504. #if 0
  505. const int32_t index = argv[0]->i;
  506. const float value = argv[1]->f;
  507. plugin->setParameterValue(index, value, true, false, true);
  508. #endif
  509. return 0;
  510. }
  511. int CarlaEngineOsc::handleMsgSetParameterMidiCC(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  512. {
  513. qDebug("CarlaEngineOsc::handleMsgSetParameterMidiCC()");
  514. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "ii");
  515. #if 0
  516. const int32_t index = argv[0]->i;
  517. const int32_t cc = argv[1]->i;
  518. plugin->setParameterMidiCC(index, cc, false, true);
  519. #endif
  520. return 0;
  521. }
  522. int CarlaEngineOsc::handleMsgSetParameterMidiChannel(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  523. {
  524. qDebug("CarlaEngineOsc::handleMsgSetParameterMidiChannel()");
  525. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "ii");
  526. #if 0
  527. const int32_t index = argv[0]->i;
  528. const int32_t channel = argv[1]->i;
  529. plugin->setParameterMidiChannel(index, channel, false, true);
  530. #endif
  531. return 0;
  532. }
  533. int CarlaEngineOsc::handleMsgSetProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  534. {
  535. qDebug("CarlaEngineOsc::handleMsgSetProgram()");
  536. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "i");
  537. #if 0
  538. const int32_t index = argv[0]->i;
  539. plugin->setProgram(index, true, false, true, true);
  540. // parameters might have changed, send all param values back
  541. if (m_controlData.target && index >= 0)
  542. {
  543. for (uint32_t i=0; i < plugin->parameterCount(); i++)
  544. engine->osc_send_control_set_parameter_value(plugin->id(), i, plugin->getParameterValue(i));
  545. }
  546. #endif
  547. return 0;
  548. }
  549. int CarlaEngineOsc::handleMsgSetMidiProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  550. {
  551. qDebug("CarlaEngineOsc::handleMsgSetMidiProgram()");
  552. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "i");
  553. #if 0
  554. const int32_t index = argv[0]->i;
  555. plugin->setMidiProgram(index, true, false, true, true);
  556. // parameters might have changed, send all param values back
  557. if (m_controlData.target && index >= 0)
  558. {
  559. for (uint32_t i=0; i < plugin->parameterCount(); i++)
  560. engine->osc_send_control_set_parameter_value(plugin->id(), i, plugin->getParameterValue(i));
  561. }
  562. #endif
  563. return 0;
  564. }
  565. int CarlaEngineOsc::handleMsgNoteOn(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  566. {
  567. qDebug("CarlaEngineOsc::handleMsgNoteOn()");
  568. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(3, "iii");
  569. #if 0
  570. const int32_t channel = argv[0]->i;
  571. const int32_t note = argv[1]->i;
  572. const int32_t velo = argv[2]->i;
  573. plugin->sendMidiSingleNote(channel, note, velo, true, false, true);
  574. #endif
  575. return 0;
  576. }
  577. int CarlaEngineOsc::handleMsgNoteOff(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  578. {
  579. qDebug("CarlaEngineOsc::handleMsgNoteOff()");
  580. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "ii");
  581. #if 0
  582. const int32_t channel = argv[0]->i;
  583. const int32_t note = argv[1]->i;
  584. plugin->sendMidiSingleNote(channel, note, 0, true, false, true);
  585. #endif
  586. return 0;
  587. }
  588. #if 0
  589. int CarlaEngineOsc::handleMsgBridgeSetInPeak(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  590. {
  591. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "id");
  592. const int32_t index = argv[0]->i;
  593. const double value = argv[1]->d;
  594. engine->setInputPeak(plugin->id(), index-1, value);
  595. return 0;
  596. }
  597. int CarlaEngineOsc::handleMsgBridgeSetOutPeak(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  598. {
  599. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "id");
  600. const int32_t index = argv[0]->i;
  601. const double value = argv[1]->d;
  602. engine->setOutputPeak(plugin->id(), index-1, value);
  603. return 0;
  604. }
  605. #endif
  606. #endif
  607. CARLA_BACKEND_END_NAMESPACE