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.

CarlaEngineOsc.cpp 17KB

11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2014 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 doc/GPL.txt file.
  16. */
  17. #include "CarlaDefines.h"
  18. #ifdef HAVE_LIBLO
  19. #include "CarlaEngine.hpp"
  20. #include "CarlaEngineOsc.hpp"
  21. #include "CarlaPlugin.hpp"
  22. #include "CarlaMIDI.h"
  23. #include <cctype>
  24. CARLA_BACKEND_START_NAMESPACE
  25. // -----------------------------------------------------------------------
  26. CarlaEngineOsc::CarlaEngineOsc(CarlaEngine* const engine) noexcept
  27. : fEngine(engine),
  28. #ifndef BUILD_BRIDGE
  29. fControlData(),
  30. #endif
  31. fName(),
  32. fServerPathTCP(),
  33. fServerPathUDP(),
  34. fServerTCP(nullptr),
  35. fServerUDP(nullptr)
  36. {
  37. CARLA_SAFE_ASSERT(engine != nullptr);
  38. carla_debug("CarlaEngineOsc::CarlaEngineOsc(%p)", engine);
  39. }
  40. CarlaEngineOsc::~CarlaEngineOsc() noexcept
  41. {
  42. CARLA_SAFE_ASSERT(fName.isEmpty());
  43. CARLA_SAFE_ASSERT(fServerPathTCP.isEmpty());
  44. CARLA_SAFE_ASSERT(fServerPathUDP.isEmpty());
  45. CARLA_SAFE_ASSERT(fServerTCP == nullptr);
  46. CARLA_SAFE_ASSERT(fServerUDP == nullptr);
  47. carla_debug("CarlaEngineOsc::~CarlaEngineOsc()");
  48. }
  49. // -----------------------------------------------------------------------
  50. void CarlaEngineOsc::init(const char* const name) noexcept
  51. {
  52. CARLA_SAFE_ASSERT_RETURN(fName.isEmpty(),);
  53. CARLA_SAFE_ASSERT_RETURN(fServerPathTCP.isEmpty(),);
  54. CARLA_SAFE_ASSERT_RETURN(fServerPathUDP.isEmpty(),);
  55. CARLA_SAFE_ASSERT_RETURN(fServerTCP == nullptr,);
  56. CARLA_SAFE_ASSERT_RETURN(fServerUDP == nullptr,);
  57. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0',);
  58. carla_debug("CarlaEngineOsc::init(\"%s\")", name);
  59. fName = name;
  60. fName.toBasic();
  61. const char* tcpPort = nullptr;
  62. const char* udpPort = nullptr;
  63. #ifndef BUILD_BRIDGE
  64. if (fEngine->getType() != kEngineTypePlugin)
  65. {
  66. tcpPort = std::getenv("CARLA_OSC_TCP_PORT");
  67. udpPort = std::getenv("CARLA_OSC_UDP_PORT");
  68. }
  69. #endif
  70. fServerTCP = lo_server_new_with_proto(tcpPort, LO_TCP, osc_error_handler_TCP);
  71. if (fServerTCP != nullptr)
  72. {
  73. if (char* const tmpServerPathTCP = lo_server_get_url(fServerTCP))
  74. {
  75. fServerPathTCP = tmpServerPathTCP;
  76. fServerPathTCP += fName;
  77. std::free(tmpServerPathTCP);
  78. }
  79. lo_server_add_method(fServerTCP, nullptr, nullptr, osc_message_handler_TCP, this);
  80. }
  81. fServerUDP = lo_server_new_with_proto(udpPort, LO_UDP, osc_error_handler_UDP);
  82. if (fServerUDP != nullptr)
  83. {
  84. if (char* const tmpServerPathUDP = lo_server_get_url(fServerUDP))
  85. {
  86. fServerPathUDP = tmpServerPathUDP;
  87. fServerPathUDP += fName;
  88. std::free(tmpServerPathUDP);
  89. }
  90. lo_server_add_method(fServerUDP, nullptr, nullptr, osc_message_handler_UDP, this);
  91. }
  92. CARLA_SAFE_ASSERT(fName.isNotEmpty());
  93. CARLA_SAFE_ASSERT(fServerTCP != nullptr);
  94. CARLA_SAFE_ASSERT(fServerUDP != nullptr);
  95. }
  96. void CarlaEngineOsc::idle() const noexcept
  97. {
  98. if (fServerTCP != nullptr)
  99. {
  100. for (;;)
  101. {
  102. try {
  103. if (lo_server_recv_noblock(fServerTCP, 0) == 0)
  104. break;
  105. } CARLA_SAFE_EXCEPTION_CONTINUE("OSC idle TCP")
  106. }
  107. }
  108. if (fServerUDP != nullptr)
  109. {
  110. for (;;)
  111. {
  112. try {
  113. if (lo_server_recv_noblock(fServerUDP, 0) == 0)
  114. break;
  115. } CARLA_SAFE_EXCEPTION_CONTINUE("OSC idle UDP")
  116. }
  117. }
  118. }
  119. void CarlaEngineOsc::close() noexcept
  120. {
  121. CARLA_SAFE_ASSERT(fName.isNotEmpty());
  122. CARLA_SAFE_ASSERT(fServerPathTCP.isNotEmpty());
  123. CARLA_SAFE_ASSERT(fServerPathUDP.isNotEmpty());
  124. CARLA_SAFE_ASSERT(fServerTCP != nullptr);
  125. CARLA_SAFE_ASSERT(fServerUDP != nullptr);
  126. carla_debug("CarlaEngineOsc::close()");
  127. fName.clear();
  128. if (fServerTCP != nullptr)
  129. {
  130. lo_server_del_method(fServerTCP, nullptr, nullptr);
  131. lo_server_free(fServerTCP);
  132. fServerTCP = nullptr;
  133. }
  134. if (fServerUDP != nullptr)
  135. {
  136. lo_server_del_method(fServerUDP, nullptr, nullptr);
  137. lo_server_free(fServerUDP);
  138. fServerUDP = nullptr;
  139. }
  140. fServerPathTCP.clear();
  141. fServerPathUDP.clear();
  142. #ifndef BUILD_BRIDGE
  143. fControlData.clear();
  144. #endif
  145. }
  146. // -----------------------------------------------------------------------
  147. int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg)
  148. {
  149. CARLA_SAFE_ASSERT_RETURN(fName.isNotEmpty(), 1);
  150. CARLA_SAFE_ASSERT_RETURN(path != nullptr && path[0] != '\0', 1);
  151. #ifdef DEBUG
  152. if (std::strstr(path, "/bridge_pong") == nullptr) {
  153. carla_debug("CarlaEngineOsc::handleMessage(%s, \"%s\", %i, %p, \"%s\", %p)", bool2str(isTCP), path, argc, argv, types, msg);
  154. }
  155. #endif
  156. if (isTCP)
  157. {
  158. CARLA_SAFE_ASSERT_RETURN(fServerPathTCP.isNotEmpty(), 1);
  159. CARLA_SAFE_ASSERT_RETURN(fServerTCP != nullptr, 1);
  160. }
  161. else
  162. {
  163. CARLA_SAFE_ASSERT_RETURN(fServerPathUDP.isNotEmpty(), 1);
  164. CARLA_SAFE_ASSERT_RETURN(fServerUDP != nullptr, 1);
  165. }
  166. #ifndef BUILD_BRIDGE
  167. // Initial path check
  168. if (std::strcmp(path, "/register") == 0)
  169. return handleMsgRegister(isTCP, argc, argv, types);
  170. if (std::strcmp(path, "/unregister") == 0)
  171. return handleMsgUnregister();
  172. #endif
  173. const std::size_t nameSize(fName.length());
  174. // Check if message is for this client
  175. if (std::strlen(path) <= nameSize || std::strncmp(path+1, fName, nameSize) != 0)
  176. {
  177. carla_stderr("CarlaEngineOsc::handleMessage() - message not for this client -> '%s' != '/%s/'", path, fName.buffer());
  178. return 1;
  179. }
  180. // Get plugin id from path, "/carla/23/method" -> 23
  181. uint pluginId = 0;
  182. std::size_t offset;
  183. if (std::isdigit(path[nameSize+2]))
  184. {
  185. if (std::isdigit(path[nameSize+3]))
  186. {
  187. if (std::isdigit(path[nameSize+5]))
  188. {
  189. carla_stderr2("CarlaEngineOsc::handleMessage() - invalid plugin id, over 999? (value: \"%s\")", path+(nameSize+1));
  190. return 1;
  191. }
  192. else if (std::isdigit(path[nameSize+4]))
  193. {
  194. // 3 digits, /xyz/method
  195. offset = 6;
  196. pluginId += uint(path[nameSize+2]-'0')*100;
  197. pluginId += uint(path[nameSize+3]-'0')*10;
  198. pluginId += uint(path[nameSize+4]-'0');
  199. }
  200. else
  201. {
  202. // 2 digits, /xy/method
  203. offset = 5;
  204. pluginId += uint(path[nameSize+2]-'0')*10;
  205. pluginId += uint(path[nameSize+3]-'0');
  206. }
  207. }
  208. else
  209. {
  210. // single digit, /x/method
  211. offset = 4;
  212. pluginId += uint(path[nameSize+2]-'0');
  213. }
  214. }
  215. else
  216. {
  217. carla_stderr("CarlaEngineOsc::handleMessage() - invalid message '%s'", path);
  218. return 1;
  219. }
  220. if (pluginId > fEngine->getCurrentPluginCount())
  221. {
  222. carla_stderr("CarlaEngineOsc::handleMessage() - failed to get plugin, wrong id '%i'", pluginId);
  223. return 0;
  224. }
  225. // Get plugin
  226. CarlaPlugin* const plugin(fEngine->getPluginUnchecked(pluginId));
  227. if (plugin == nullptr || plugin->getId() != pluginId)
  228. {
  229. carla_stderr("CarlaEngineOsc::handleMessage() - invalid plugin id '%i', probably has been removed (path: '%s')", pluginId, path);
  230. return 0;
  231. }
  232. // Get method from path, "/Carla/i/method" -> "method"
  233. char method[32+1];
  234. method[32] = '\0';
  235. std::strncpy(method, path + (nameSize + offset), 32);
  236. if (method[0] == '\0')
  237. {
  238. carla_stderr("CarlaEngineOsc::handleMessage(%s, \"%s\", ...) - received message without method", bool2str(isTCP), path);
  239. return 0;
  240. }
  241. #ifndef BUILD_BRIDGE
  242. // Internal methods
  243. if (std::strcmp(method, "set_option") == 0)
  244. return 0; //handleMsgSetOption(plugin, argc, argv, types); // TODO
  245. if (std::strcmp(method, "set_active") == 0)
  246. return handleMsgSetActive(plugin, argc, argv, types);
  247. if (std::strcmp(method, "set_drywet") == 0)
  248. return handleMsgSetDryWet(plugin, argc, argv, types);
  249. if (std::strcmp(method, "set_volume") == 0)
  250. return handleMsgSetVolume(plugin, argc, argv, types);
  251. if (std::strcmp(method, "set_balance_left") == 0)
  252. return handleMsgSetBalanceLeft(plugin, argc, argv, types);
  253. if (std::strcmp(method, "set_balance_right") == 0)
  254. return handleMsgSetBalanceRight(plugin, argc, argv, types);
  255. if (std::strcmp(method, "set_panning") == 0)
  256. return handleMsgSetPanning(plugin, argc, argv, types);
  257. if (std::strcmp(method, "set_ctrl_channel") == 0)
  258. return 0; //handleMsgSetControlChannel(plugin, argc, argv, types); // TODO
  259. if (std::strcmp(method, "set_parameter_value") == 0)
  260. return handleMsgSetParameterValue(plugin, argc, argv, types);
  261. if (std::strcmp(method, "set_parameter_midi_cc") == 0)
  262. return handleMsgSetParameterMidiCC(plugin, argc, argv, types);
  263. if (std::strcmp(method, "set_parameter_midi_channel") == 0)
  264. return handleMsgSetParameterMidiChannel(plugin, argc, argv, types);
  265. if (std::strcmp(method, "set_program") == 0)
  266. return handleMsgSetProgram(plugin, argc, argv, types);
  267. if (std::strcmp(method, "set_midi_program") == 0)
  268. return handleMsgSetMidiProgram(plugin, argc, argv, types);
  269. if (std::strcmp(method, "set_custom_data") == 0)
  270. return 0; //handleMsgSetCustomData(plugin, argc, argv, types); // TODO
  271. if (std::strcmp(method, "set_chunk") == 0)
  272. return 0; //handleMsgSetChunk(plugin, argc, argv, types); // TODO
  273. if (std::strcmp(method, "note_on") == 0)
  274. return handleMsgNoteOn(plugin, argc, argv, types);
  275. if (std::strcmp(method, "note_off") == 0)
  276. return handleMsgNoteOff(plugin, argc, argv, types);
  277. #endif
  278. // Send all other methods to plugins, TODO
  279. plugin->handleOscMessage(method, argc, argv, types, msg);
  280. return 0;
  281. }
  282. // -----------------------------------------------------------------------
  283. #ifndef BUILD_BRIDGE
  284. int CarlaEngineOsc::handleMsgRegister(const bool isTCP, const int argc, const lo_arg* const* const argv, const char* const types)
  285. {
  286. carla_debug("CarlaEngineOsc::handleMsgRegister()");
  287. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "s");
  288. if (fControlData.path != nullptr)
  289. {
  290. carla_stderr("CarlaEngineOsc::handleMsgRegister() - OSC backend already registered to %s", fControlData.path);
  291. return 1;
  292. }
  293. const char* const url = &argv[0]->s;
  294. carla_debug("CarlaEngineOsc::handleMsgRegister() - OSC backend registered to %s", url);
  295. {
  296. const lo_address addr = lo_address_new_from_url(url);
  297. const char* const host = lo_address_get_hostname(addr);
  298. const char* const port = lo_address_get_port(addr);
  299. fControlData.source = lo_address_new_with_proto(isTCP ? LO_TCP : LO_UDP, host, port);
  300. fControlData.path = carla_strdup_free(lo_url_get_path(url));
  301. fControlData.target = lo_address_new_with_proto(isTCP ? LO_TCP : LO_UDP, host, port);
  302. }
  303. for (uint i=0, count=fEngine->getCurrentPluginCount(); i < count; ++i)
  304. {
  305. CarlaPlugin* const plugin(fEngine->getPluginUnchecked(i));
  306. if (plugin != nullptr && plugin->isEnabled())
  307. plugin->registerToOscClient();
  308. }
  309. return 0;
  310. }
  311. int CarlaEngineOsc::handleMsgUnregister()
  312. {
  313. carla_debug("CarlaEngineOsc::handleMsgUnregister()");
  314. if (fControlData.path == nullptr)
  315. {
  316. carla_stderr("CarlaEngineOsc::handleMsgUnregister() - OSC backend is not registered yet");
  317. return 1;
  318. }
  319. fControlData.clear();
  320. return 0;
  321. }
  322. // -----------------------------------------------------------------------
  323. int CarlaEngineOsc::handleMsgSetActive(CARLA_ENGINE_OSC_HANDLE_ARGS)
  324. {
  325. carla_debug("CarlaEngineOsc::handleMsgSetActive()");
  326. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "i");
  327. const bool active = (argv[0]->i != 0);
  328. plugin->setActive(active, false, true);
  329. return 0;
  330. }
  331. int CarlaEngineOsc::handleMsgSetDryWet(CARLA_ENGINE_OSC_HANDLE_ARGS)
  332. {
  333. carla_debug("CarlaEngineOsc::handleMsgSetDryWet()");
  334. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  335. const float value = argv[0]->f;
  336. plugin->setDryWet(value, false, true);
  337. return 0;
  338. }
  339. int CarlaEngineOsc::handleMsgSetVolume(CARLA_ENGINE_OSC_HANDLE_ARGS)
  340. {
  341. carla_debug("CarlaEngineOsc::handleMsgSetVolume()");
  342. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  343. const float value = argv[0]->f;
  344. plugin->setVolume(value, false, true);
  345. return 0;
  346. }
  347. int CarlaEngineOsc::handleMsgSetBalanceLeft(CARLA_ENGINE_OSC_HANDLE_ARGS)
  348. {
  349. carla_debug("CarlaEngineOsc::handleMsgSetBalanceLeft()");
  350. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  351. const float value = argv[0]->f;
  352. plugin->setBalanceLeft(value, false, true);
  353. return 0;
  354. }
  355. int CarlaEngineOsc::handleMsgSetBalanceRight(CARLA_ENGINE_OSC_HANDLE_ARGS)
  356. {
  357. carla_debug("CarlaEngineOsc::handleMsgSetBalanceRight()");
  358. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  359. const float value = argv[0]->f;
  360. plugin->setBalanceRight(value, false, true);
  361. return 0;
  362. }
  363. int CarlaEngineOsc::handleMsgSetPanning(CARLA_ENGINE_OSC_HANDLE_ARGS)
  364. {
  365. carla_debug("CarlaEngineOsc::handleMsgSetPanning()");
  366. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "f");
  367. const float value = argv[0]->f;
  368. plugin->setPanning(value, false, true);
  369. return 0;
  370. }
  371. int CarlaEngineOsc::handleMsgSetParameterValue(CARLA_ENGINE_OSC_HANDLE_ARGS)
  372. {
  373. carla_debug("CarlaEngineOsc::handleMsgSetParameterValue()");
  374. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "if");
  375. const int32_t index = argv[0]->i;
  376. const float value = argv[1]->f;
  377. CARLA_SAFE_ASSERT_RETURN(index >= 0, 0);
  378. plugin->setParameterValue(static_cast<uint32_t>(index), value, true, false, true);
  379. return 0;
  380. }
  381. int CarlaEngineOsc::handleMsgSetParameterMidiCC(CARLA_ENGINE_OSC_HANDLE_ARGS)
  382. {
  383. carla_debug("CarlaEngineOsc::handleMsgSetParameterMidiCC()");
  384. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "ii");
  385. const int32_t index = argv[0]->i;
  386. const int32_t cc = argv[1]->i;
  387. CARLA_SAFE_ASSERT_RETURN(index >= 0, 0);
  388. CARLA_SAFE_ASSERT_RETURN(cc >= -1 && cc < MAX_MIDI_CONTROL, 0);
  389. plugin->setParameterMidiCC(static_cast<uint32_t>(index), static_cast<int16_t>(cc), false, true);
  390. return 0;
  391. }
  392. int CarlaEngineOsc::handleMsgSetParameterMidiChannel(CARLA_ENGINE_OSC_HANDLE_ARGS)
  393. {
  394. carla_debug("CarlaEngineOsc::handleMsgSetParameterMidiChannel()");
  395. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "ii");
  396. const int32_t index = argv[0]->i;
  397. const int32_t channel = argv[1]->i;
  398. CARLA_SAFE_ASSERT_RETURN(index >= 0, 0);
  399. CARLA_SAFE_ASSERT_RETURN(channel >= 0 && channel < MAX_MIDI_CHANNELS, 0);
  400. plugin->setParameterMidiChannel(static_cast<uint32_t>(index), static_cast<uint8_t>(channel), false, true);
  401. return 0;
  402. }
  403. int CarlaEngineOsc::handleMsgSetProgram(CARLA_ENGINE_OSC_HANDLE_ARGS)
  404. {
  405. carla_debug("CarlaEngineOsc::handleMsgSetProgram()");
  406. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "i");
  407. const int32_t index = argv[0]->i;
  408. CARLA_SAFE_ASSERT_RETURN(index >= -1, 0);
  409. plugin->setProgram(index, true, false, true);
  410. return 0;
  411. }
  412. int CarlaEngineOsc::handleMsgSetMidiProgram(CARLA_ENGINE_OSC_HANDLE_ARGS)
  413. {
  414. carla_debug("CarlaEngineOsc::handleMsgSetMidiProgram()");
  415. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "i");
  416. const int32_t index = argv[0]->i;
  417. CARLA_SAFE_ASSERT_RETURN(index >= -1, 0);
  418. plugin->setMidiProgram(index, true, false, true);
  419. return 0;
  420. }
  421. int CarlaEngineOsc::handleMsgNoteOn(CARLA_ENGINE_OSC_HANDLE_ARGS)
  422. {
  423. carla_debug("CarlaEngineOsc::handleMsgNoteOn()");
  424. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(3, "iii");
  425. const int32_t channel = argv[0]->i;
  426. const int32_t note = argv[1]->i;
  427. const int32_t velo = argv[2]->i;
  428. CARLA_SAFE_ASSERT_RETURN(channel >= 0 && channel < MAX_MIDI_CHANNELS, 0);
  429. CARLA_SAFE_ASSERT_RETURN(note >= 0 && note < MAX_MIDI_NOTE, 0);
  430. CARLA_SAFE_ASSERT_RETURN(velo >= 0 && velo < MAX_MIDI_VALUE, 0);
  431. plugin->sendMidiSingleNote(static_cast<uint8_t>(channel), static_cast<uint8_t>(note), static_cast<uint8_t>(velo), true, false, true);
  432. return 0;
  433. }
  434. int CarlaEngineOsc::handleMsgNoteOff(CARLA_ENGINE_OSC_HANDLE_ARGS)
  435. {
  436. carla_debug("CarlaEngineOsc::handleMsgNoteOff()");
  437. CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "ii");
  438. const int32_t channel = argv[0]->i;
  439. const int32_t note = argv[1]->i;
  440. CARLA_SAFE_ASSERT_RETURN(channel >= 0 && channel < MAX_MIDI_CHANNELS, 0);
  441. CARLA_SAFE_ASSERT_RETURN(note >= 0 && note < MAX_MIDI_NOTE, 0);
  442. plugin->sendMidiSingleNote(static_cast<uint8_t>(channel), static_cast<uint8_t>(note), 0, true, false, true);
  443. return 0;
  444. }
  445. #endif // ! BUILD_BRIDGE
  446. // -----------------------------------------------------------------------
  447. CARLA_BACKEND_END_NAMESPACE
  448. #endif // HAVE_LIBLO