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.

703 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()); // FIXME
  35. //CARLA_ASSERT(fServerPathTCP.isEmpty()); // FIXME
  36. //CARLA_ASSERT(fServerPathUDP.isEmpty()); // FIXME
  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. std::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. std::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 (fControlData.path != nullptr)
  319. {
  320. qWarning("CarlaEngineOsc::handleMsgRegister() - OSC backend already registered to %s", fControlData.path);
  321. return 1;
  322. }
  323. const char* const url = &argv[0]->s;
  324. qDebug("CarlaEngineOsc::handleMsgRegister() - OSC backend registered to %s", url);
  325. {
  326. const char* host = lo_address_get_hostname(source);
  327. const char* port = lo_address_get_port(source);
  328. fControlData.source = lo_address_new_with_proto(LO_TCP, host, port);
  329. }
  330. {
  331. char* host = lo_url_get_hostname(url);
  332. char* port = lo_url_get_port(url);
  333. fControlData.path = carla_strdup_free(lo_url_get_path(url));
  334. fControlData.target = lo_address_new_with_proto(LO_TCP, host, port);
  335. std::free(host);
  336. std::free(port);
  337. }
  338. for (unsigned short i=0; i < kEngine->currentPluginCount(); i++)
  339. {
  340. CarlaPlugin* const plugin = kEngine->getPluginUnchecked(i);
  341. if (plugin && plugin->enabled())
  342. plugin->registerToOscClient();
  343. }
  344. return 0;
  345. }
  346. int CarlaEngineOsc::handleMsgUnregister()
  347. {
  348. qDebug("CarlaEngineOsc::handleMsgUnregister()");
  349. if (fControlData.path == nullptr)
  350. {
  351. qWarning("CarlaEngineOsc::handleMsgUnregister() - OSC backend is not registered yet");
  352. return 1;
  353. }
  354. fControlData.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. const uint8_t* const data = argv[0]->m;
  417. uint8_t status = data[1];
  418. uint8_t channel = status & 0x0F;
  419. // Fix bad note-off
  420. if (MIDI_IS_STATUS_NOTE_ON(status) && data[3] == 0)
  421. status -= 0x10;
  422. if (MIDI_IS_STATUS_NOTE_OFF(status))
  423. {
  424. uint8_t note = data[2];
  425. plugin->sendMidiSingleNote(channel, note, 0, false, true, true);
  426. }
  427. else if (MIDI_IS_STATUS_NOTE_ON(status))
  428. {
  429. uint8_t note = data[2];
  430. uint8_t velo = data[3];
  431. plugin->sendMidiSingleNote(channel, note, velo, false, true, true);
  432. }
  433. return 0;
  434. }
  435. qWarning("CarlaEngineOsc::handleMsgMidi() - recived midi when plugin has no midi inputs");
  436. return 1;
  437. }
  438. int CarlaEngineOsc::handleMsgExiting(CARLA_ENGINE_OSC_HANDLE_ARGS1)
  439. {
  440. qDebug("CarlaEngineOsc::handleMsgExiting()");
  441. // TODO - check for non-UIs (dssi-vst) and set to -1 instead
  442. kEngine->callback(CALLBACK_SHOW_GUI, plugin->id(), 0, 0, 0.0f, nullptr);
  443. plugin->freeOscData();
  444. return 0;
  445. }
  446. // -----------------------------------------------------------------------
  447. #ifndef BUILD_BRIDGE
  448. int CarlaEngineOsc::handleMsgSetActive(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  449. {
  450. qDebug("CarlaEngineOsc::handleMsgSetActive()");
  451. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "i");
  452. const bool active = (bool)argv[0]->i;
  453. plugin->setActive(active, false, true);
  454. return 0;
  455. }
  456. int CarlaEngineOsc::handleMsgSetDryWet(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  457. {
  458. qDebug("CarlaEngineOsc::handleMsgSetDryWet()");
  459. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  460. const float value = argv[0]->f;
  461. plugin->setDryWet(value, false, true);
  462. return 0;
  463. }
  464. int CarlaEngineOsc::handleMsgSetVolume(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  465. {
  466. qDebug("CarlaEngineOsc::handleMsgSetVolume()");
  467. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  468. const float value = argv[0]->f;
  469. plugin->setVolume(value, false, true);
  470. return 0;
  471. }
  472. int CarlaEngineOsc::handleMsgSetBalanceLeft(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  473. {
  474. qDebug("CarlaEngineOsc::handleMsgSetBalanceLeft()");
  475. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  476. const float value = argv[0]->f;
  477. plugin->setBalanceLeft(value, false, true);
  478. return 0;
  479. }
  480. int CarlaEngineOsc::handleMsgSetBalanceRight(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  481. {
  482. qDebug("CarlaEngineOsc::handleMsgSetBalanceRight()");
  483. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  484. const float value = argv[0]->f;
  485. plugin->setBalanceRight(value, false, true);
  486. return 0;
  487. }
  488. int CarlaEngineOsc::handleMsgSetParameterValue(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  489. {
  490. qDebug("CarlaEngineOsc::handleMsgSetParameterValue()");
  491. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "if");
  492. const int32_t index = argv[0]->i;
  493. const float value = argv[1]->f;
  494. plugin->setParameterValue(index, value, true, false, true);
  495. return 0;
  496. }
  497. int CarlaEngineOsc::handleMsgSetParameterMidiCC(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  498. {
  499. qDebug("CarlaEngineOsc::handleMsgSetParameterMidiCC()");
  500. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "ii");
  501. const int32_t index = argv[0]->i;
  502. const int32_t cc = argv[1]->i;
  503. plugin->setParameterMidiCC(index, cc, false, true);
  504. return 0;
  505. }
  506. int CarlaEngineOsc::handleMsgSetParameterMidiChannel(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  507. {
  508. qDebug("CarlaEngineOsc::handleMsgSetParameterMidiChannel()");
  509. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "ii");
  510. const int32_t index = argv[0]->i;
  511. const int32_t channel = argv[1]->i;
  512. plugin->setParameterMidiChannel(index, channel, false, true);
  513. return 0;
  514. }
  515. int CarlaEngineOsc::handleMsgSetProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  516. {
  517. qDebug("CarlaEngineOsc::handleMsgSetProgram()");
  518. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "i");
  519. const int32_t index = argv[0]->i;
  520. plugin->setProgram(index, true, false, true, true);
  521. return 0;
  522. }
  523. int CarlaEngineOsc::handleMsgSetMidiProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  524. {
  525. qDebug("CarlaEngineOsc::handleMsgSetMidiProgram()");
  526. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "i");
  527. const int32_t index = argv[0]->i;
  528. plugin->setMidiProgram(index, true, false, true, true);
  529. return 0;
  530. }
  531. int CarlaEngineOsc::handleMsgNoteOn(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  532. {
  533. qDebug("CarlaEngineOsc::handleMsgNoteOn()");
  534. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(3, "iii");
  535. const int32_t channel = argv[0]->i;
  536. const int32_t note = argv[1]->i;
  537. const int32_t velo = argv[2]->i;
  538. plugin->sendMidiSingleNote(channel, note, velo, true, false, true);
  539. return 0;
  540. }
  541. int CarlaEngineOsc::handleMsgNoteOff(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  542. {
  543. qDebug("CarlaEngineOsc::handleMsgNoteOff()");
  544. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "ii");
  545. const int32_t channel = argv[0]->i;
  546. const int32_t note = argv[1]->i;
  547. plugin->sendMidiSingleNote(channel, note, 0, true, false, true);
  548. return 0;
  549. }
  550. #if 0
  551. int CarlaEngineOsc::handleMsgBridgeSetInPeak(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  552. {
  553. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "id");
  554. const int32_t index = argv[0]->i;
  555. const double value = argv[1]->d;
  556. engine->setInputPeak(plugin->id(), index-1, value);
  557. return 0;
  558. }
  559. int CarlaEngineOsc::handleMsgBridgeSetOutPeak(CARLA_ENGINE_OSC_HANDLE_ARGS2)
  560. {
  561. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "id");
  562. const int32_t index = argv[0]->i;
  563. const double value = argv[1]->d;
  564. engine->setOutputPeak(plugin->id(), index-1, value);
  565. return 0;
  566. }
  567. #endif
  568. #endif
  569. CARLA_BACKEND_END_NAMESPACE