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.

CarlaEngineOscSend.cpp 23KB

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
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
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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 "CarlaBackendUtils.hpp"
  20. #include "CarlaEngineInternal.hpp"
  21. #include "CarlaMIDI.h"
  22. CARLA_BACKEND_START_NAMESPACE
  23. // -----------------------------------------------------------------------
  24. #ifndef BUILD_BRIDGE
  25. void CarlaEngine::oscSend_control_add_plugin_start(const uint pluginId, const char* const pluginName) const noexcept
  26. {
  27. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  28. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  29. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  30. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  31. CARLA_SAFE_ASSERT_RETURN(pluginName != nullptr && pluginName[0] != '\0',);
  32. carla_debug("CarlaEngine::oscSend_control_add_plugin_start(%i, \"%s\")", pluginId, pluginName);
  33. char targetPath[std::strlen(pData->oscData->path)+18];
  34. std::strcpy(targetPath, pData->oscData->path);
  35. std::strcat(targetPath, "/add_plugin_start");
  36. try_lo_send(pData->oscData->target, targetPath, "is", static_cast<int32_t>(pluginId), pluginName);
  37. }
  38. void CarlaEngine::oscSend_control_add_plugin_end(const uint pluginId) const noexcept
  39. {
  40. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  41. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  42. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  43. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  44. carla_debug("CarlaEngine::oscSend_control_add_plugin_end(%i)", pluginId);
  45. char targetPath[std::strlen(pData->oscData->path)+16];
  46. std::strcpy(targetPath, pData->oscData->path);
  47. std::strcat(targetPath, "/add_plugin_end");
  48. try_lo_send(pData->oscData->target, targetPath, "i", static_cast<int32_t>(pluginId));
  49. }
  50. void CarlaEngine::oscSend_control_remove_plugin(const uint pluginId) const noexcept
  51. {
  52. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  53. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  54. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  55. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  56. carla_debug("CarlaEngine::oscSend_control_remove_plugin(%i)", pluginId);
  57. char targetPath[std::strlen(pData->oscData->path)+15];
  58. std::strcpy(targetPath, pData->oscData->path);
  59. std::strcat(targetPath, "/remove_plugin");
  60. try_lo_send(pData->oscData->target, targetPath, "i", static_cast<int32_t>(pluginId));
  61. }
  62. void CarlaEngine::oscSend_control_set_plugin_info1(const uint pluginId, const PluginType type, const PluginCategory category, const uint hints, const int64_t uniqueId) const noexcept
  63. {
  64. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  65. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  66. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  67. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  68. CARLA_SAFE_ASSERT_RETURN(type != PLUGIN_NONE,);
  69. carla_debug("CarlaEngine::oscSend_control_set_plugin_data(%i, %i:%s, %i:%s, %X, " P_INT64 ")", pluginId, type, PluginType2Str(type), category, PluginCategory2Str(category), hints, uniqueId);
  70. char targetPath[std::strlen(pData->oscData->path)+18];
  71. std::strcpy(targetPath, pData->oscData->path);
  72. std::strcat(targetPath, "/set_plugin_info1");
  73. try_lo_send(pData->oscData->target, targetPath, "iiiih", static_cast<int32_t>(pluginId), static_cast<int32_t>(type), static_cast<int32_t>(category), static_cast<int32_t>(hints), static_cast<int64_t>(uniqueId));
  74. }
  75. void CarlaEngine::oscSend_control_set_plugin_info2(const uint pluginId, const char* const realName, const char* const label, const char* const maker, const char* const copyright) const noexcept
  76. {
  77. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  78. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  79. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  80. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  81. CARLA_SAFE_ASSERT_RETURN(realName != nullptr && realName[0] != '\0',);
  82. CARLA_SAFE_ASSERT_RETURN(label != nullptr && label[0] != '\0',);
  83. CARLA_SAFE_ASSERT_RETURN(maker != nullptr,);
  84. CARLA_SAFE_ASSERT_RETURN(copyright != nullptr,);
  85. carla_debug("CarlaEngine::oscSend_control_set_plugin_data(%i, \"%s\", \"%s\", \"%s\", \"%s\")", pluginId, realName, label, maker, copyright);
  86. char targetPath[std::strlen(pData->oscData->path)+18];
  87. std::strcpy(targetPath, pData->oscData->path);
  88. std::strcat(targetPath, "/set_plugin_info2");
  89. try_lo_send(pData->oscData->target, targetPath, "issss", static_cast<int32_t>(pluginId), realName, label, maker, copyright);
  90. }
  91. void CarlaEngine::oscSend_control_set_audio_count(const uint pluginId, const uint32_t ins, const uint32_t outs) const noexcept
  92. {
  93. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  94. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  95. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  96. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  97. carla_debug("CarlaEngine::oscSend_control_set_audio_count(%i, %i, %i)", pluginId, ins, outs);
  98. char targetPath[std::strlen(pData->oscData->path)+18];
  99. std::strcpy(targetPath, pData->oscData->path);
  100. std::strcat(targetPath, "/set_audio_count");
  101. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  102. }
  103. void CarlaEngine::oscSend_control_set_midi_count(const uint pluginId, const uint32_t ins, const uint32_t outs) const noexcept
  104. {
  105. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  106. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  107. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  108. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  109. carla_debug("CarlaEngine::oscSend_control_set_midi_count(%i, %i, %i)", pluginId, ins, outs);
  110. char targetPath[std::strlen(pData->oscData->path)+18];
  111. std::strcpy(targetPath, pData->oscData->path);
  112. std::strcat(targetPath, "/set_midi_count");
  113. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  114. }
  115. void CarlaEngine::oscSend_control_set_parameter_count(const uint pluginId, const uint32_t ins, const uint32_t outs) const noexcept
  116. {
  117. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  118. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  119. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  120. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  121. carla_debug("CarlaEngine::oscSend_control_set_parameter_count(%i, %i, %i)", pluginId, ins, outs);
  122. char targetPath[std::strlen(pData->oscData->path)+18];
  123. std::strcpy(targetPath, pData->oscData->path);
  124. std::strcat(targetPath, "/set_parameter_count");
  125. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  126. }
  127. void CarlaEngine::oscSend_control_set_program_count(const uint pluginId, const uint32_t count) const noexcept
  128. {
  129. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  130. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  131. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  132. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  133. carla_debug("CarlaEngine::oscSend_control_set_program_count(%i, %i)", pluginId, count);
  134. char targetPath[std::strlen(pData->oscData->path)+19];
  135. std::strcpy(targetPath, pData->oscData->path);
  136. std::strcat(targetPath, "/set_program_count");
  137. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), static_cast<int32_t>(count));
  138. }
  139. void CarlaEngine::oscSend_control_set_midi_program_count(const uint pluginId, const uint32_t count) const noexcept
  140. {
  141. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  142. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  143. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  144. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  145. carla_debug("CarlaEngine::oscSend_control_set_midi_program_count(%i, %i)", pluginId, count);
  146. char targetPath[std::strlen(pData->oscData->path)+24];
  147. std::strcpy(targetPath, pData->oscData->path);
  148. std::strcat(targetPath, "/set_midi_program_count");
  149. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), static_cast<int32_t>(count));
  150. }
  151. void CarlaEngine::oscSend_control_set_parameter_data(const uint pluginId, const uint32_t index, const ParameterType type, const uint hints, const char* const name, const char* const unit) const noexcept
  152. {
  153. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  154. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  155. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  156. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  157. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0',);
  158. CARLA_SAFE_ASSERT_RETURN(unit != nullptr,);
  159. carla_debug("CarlaEngine::oscSend_control_set_parameter_data(%i, %i, %i:%s, %X, \"%s\", \"%s\")", pluginId, index, type, ParameterType2Str(type), hints, name, unit);
  160. char targetPath[std::strlen(pData->oscData->path)+20];
  161. std::strcpy(targetPath, pData->oscData->path);
  162. std::strcat(targetPath, "/set_parameter_data");
  163. try_lo_send(pData->oscData->target, targetPath, "iiiiss", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(type), static_cast<int32_t>(hints), name, unit);
  164. }
  165. void CarlaEngine::oscSend_control_set_parameter_ranges1(const uint pluginId, const uint32_t index, const float def, const float min, const float max) const noexcept
  166. {
  167. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  168. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  169. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  170. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  171. CARLA_SAFE_ASSERT(def >= min && def <= max);
  172. CARLA_SAFE_ASSERT(min < max);
  173. carla_debug("CarlaEngine::oscSend_control_set_parameter_ranges1(%i, %i, %f, %f, %f)", pluginId, index, def, min, max, def);
  174. char targetPath[std::strlen(pData->oscData->path)+24];
  175. std::strcpy(targetPath, pData->oscData->path);
  176. std::strcat(targetPath, "/set_parameter_ranges1");
  177. try_lo_send(pData->oscData->target, targetPath, "iifff", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), def, min, max);
  178. }
  179. void CarlaEngine::oscSend_control_set_parameter_ranges2(const uint pluginId, const uint32_t index, const float step, const float stepSmall, const float stepLarge) const noexcept
  180. {
  181. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  182. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  183. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  184. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  185. CARLA_SAFE_ASSERT(step >= stepSmall && step <= stepLarge);
  186. CARLA_SAFE_ASSERT(stepSmall <= stepLarge);
  187. carla_debug("CarlaEngine::oscSend_control_set_parameter_ranges2(%i, %i, %f, %f, %f)", pluginId, index, step, stepSmall, stepLarge);
  188. char targetPath[std::strlen(pData->oscData->path)+24];
  189. std::strcpy(targetPath, pData->oscData->path);
  190. std::strcat(targetPath, "/set_parameter_ranges2");
  191. try_lo_send(pData->oscData->target, targetPath, "iifff", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), step, stepSmall, stepLarge);
  192. }
  193. void CarlaEngine::oscSend_control_set_parameter_midi_cc(const uint pluginId, const uint32_t index, const int16_t cc) const noexcept
  194. {
  195. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  196. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  197. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  198. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  199. CARLA_SAFE_ASSERT_RETURN(cc >= -1 && cc < MAX_MIDI_CONTROL,);
  200. carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_cc(%i, %i, %i)", pluginId, index, cc);
  201. char targetPath[std::strlen(pData->oscData->path)+23];
  202. std::strcpy(targetPath, pData->oscData->path);
  203. std::strcat(targetPath, "/set_parameter_midi_cc");
  204. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(cc));
  205. }
  206. void CarlaEngine::oscSend_control_set_parameter_midi_channel(const uint pluginId, const uint32_t index, const uint8_t channel) const noexcept
  207. {
  208. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  209. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  210. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  211. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  212. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  213. carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_channel(%i, %i, %i)", pluginId, index, channel);
  214. char targetPath[std::strlen(pData->oscData->path)+28];
  215. std::strcpy(targetPath, pData->oscData->path);
  216. std::strcat(targetPath, "/set_parameter_midi_channel");
  217. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(channel));
  218. }
  219. void CarlaEngine::oscSend_control_set_parameter_value(const uint pluginId, const int32_t index, const float value) const noexcept
  220. {
  221. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  222. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  223. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  224. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  225. CARLA_SAFE_ASSERT_RETURN(index != PARAMETER_NULL,);
  226. carla_debug("CarlaEngine::oscSend_control_set_parameter_value(%i, %i:%s, %f)", pluginId, index, (index < 0) ? InternalParameterIndex2Str(static_cast<InternalParameterIndex>(index)) : "(none)", value);
  227. char targetPath[std::strlen(pData->oscData->path)+21];
  228. std::strcpy(targetPath, pData->oscData->path);
  229. std::strcat(targetPath, "/set_parameter_value");
  230. try_lo_send(pData->oscData->target, targetPath, "iif", static_cast<int32_t>(pluginId), index, value);
  231. }
  232. void CarlaEngine::oscSend_control_set_default_value(const uint pluginId, const uint32_t index, const float value) const noexcept
  233. {
  234. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  235. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  236. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  237. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  238. carla_debug("CarlaEngine::oscSend_control_set_default_value(%i, %i, %f)", pluginId, index, value);
  239. char targetPath[std::strlen(pData->oscData->path)+19];
  240. std::strcpy(targetPath, pData->oscData->path);
  241. std::strcat(targetPath, "/set_default_value");
  242. try_lo_send(pData->oscData->target, targetPath, "iif", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), value);
  243. }
  244. void CarlaEngine::oscSend_control_set_current_program(const uint pluginId, const int32_t index) const noexcept
  245. {
  246. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  247. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  248. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  249. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  250. carla_debug("CarlaEngine::oscSend_control_set_current_program(%i, %i)", pluginId, index);
  251. char targetPath[std::strlen(pData->oscData->path)+21];
  252. std::strcpy(targetPath, pData->oscData->path);
  253. std::strcat(targetPath, "/set_current_program");
  254. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), index);
  255. }
  256. void CarlaEngine::oscSend_control_set_current_midi_program(const uint pluginId, const int32_t index) const noexcept
  257. {
  258. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  259. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  260. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  261. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  262. carla_debug("CarlaEngine::oscSend_control_set_current_midi_program(%i, %i)", pluginId, index);
  263. char targetPath[std::strlen(pData->oscData->path)+26];
  264. std::strcpy(targetPath, pData->oscData->path);
  265. std::strcat(targetPath, "/set_current_midi_program");
  266. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), index);
  267. }
  268. void CarlaEngine::oscSend_control_set_program_name(const uint pluginId, const uint32_t index, const char* const name) const noexcept
  269. {
  270. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  271. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  272. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  273. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  274. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  275. carla_debug("CarlaEngine::oscSend_control_set_program_name(%i, %i, \"%s\")", pluginId, index, name);
  276. char targetPath[std::strlen(pData->oscData->path)+18];
  277. std::strcpy(targetPath, pData->oscData->path);
  278. std::strcat(targetPath, "/set_program_name");
  279. try_lo_send(pData->oscData->target, targetPath, "iis", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), name);
  280. }
  281. void CarlaEngine::oscSend_control_set_midi_program_data(const uint pluginId, const uint32_t index, const uint32_t bank, const uint32_t program, const char* const name) const noexcept
  282. {
  283. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  284. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  285. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  286. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  287. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  288. carla_debug("CarlaEngine::oscSend_control_set_midi_program_data(%i, %i, %i, %i, \"%s\")", pluginId, index, bank, program, name);
  289. char targetPath[std::strlen(pData->oscData->path)+23];
  290. std::strcpy(targetPath, pData->oscData->path);
  291. std::strcat(targetPath, "/set_midi_program_data");
  292. try_lo_send(pData->oscData->target, targetPath, "iiiis", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(bank), static_cast<int32_t>(program), name);
  293. }
  294. void CarlaEngine::oscSend_control_note_on(const uint pluginId, const uint8_t channel, const uint8_t note, const uint8_t velo) const noexcept
  295. {
  296. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  297. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  298. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  299. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  300. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  301. CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_NOTE,);
  302. CARLA_SAFE_ASSERT_RETURN(velo < MAX_MIDI_VALUE,);
  303. carla_debug("CarlaEngine::oscSend_control_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo);
  304. char targetPath[std::strlen(pData->oscData->path)+9];
  305. std::strcpy(targetPath, pData->oscData->path);
  306. std::strcat(targetPath, "/note_on");
  307. try_lo_send(pData->oscData->target, targetPath, "iiii", static_cast<int32_t>(pluginId), static_cast<int32_t>(channel), static_cast<int32_t>(note), static_cast<int32_t>(velo));
  308. }
  309. void CarlaEngine::oscSend_control_note_off(const uint pluginId, const uint8_t channel, const uint8_t note) const noexcept
  310. {
  311. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  312. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  313. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  314. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  315. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  316. CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_NOTE,);
  317. carla_debug("CarlaEngine::oscSend_control_note_off(%i, %i, %i)", pluginId, channel, note);
  318. char targetPath[std::strlen(pData->oscData->path)+10];
  319. std::strcpy(targetPath, pData->oscData->path);
  320. std::strcat(targetPath, "/note_off");
  321. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(channel), static_cast<int32_t>(note));
  322. }
  323. void CarlaEngine::oscSend_control_set_peaks(const uint pluginId) const noexcept
  324. {
  325. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  326. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  327. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  328. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  329. // TODO - try and see if we can get peaks[4] ref
  330. const EnginePluginData& epData(pData->plugins[pluginId]);
  331. char targetPath[std::strlen(pData->oscData->path)+11];
  332. std::strcpy(targetPath, pData->oscData->path);
  333. std::strcat(targetPath, "/set_peaks");
  334. try_lo_send(pData->oscData->target, targetPath, "iffff", static_cast<int32_t>(pluginId), epData.insPeak[0], epData.insPeak[1], epData.outsPeak[0], epData.outsPeak[1]);
  335. }
  336. void CarlaEngine::oscSend_control_exit() const noexcept
  337. {
  338. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  339. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  340. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  341. carla_debug("CarlaEngine::oscSend_control_exit()");
  342. char targetPath[std::strlen(pData->oscData->path)+6];
  343. std::strcpy(targetPath, pData->oscData->path);
  344. std::strcat(targetPath, "/exit");
  345. try_lo_send(pData->oscData->target, targetPath, "");
  346. }
  347. #endif // BUILD_BRIDGE
  348. // -----------------------------------------------------------------------
  349. CARLA_BACKEND_END_NAMESPACE
  350. #endif // HAVE_LIBLO