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.

446 lines
24KB

  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2019 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_SAFE_ASSERT_RETURN(ins < 50,);
  122. CARLA_SAFE_ASSERT_RETURN(outs < 50,);
  123. carla_debug("CarlaEngine::oscSend_control_set_parameter_count(%i, %i, %i)", pluginId, ins, outs);
  124. char targetPath[std::strlen(pData->oscData->path)+18];
  125. std::strcpy(targetPath, pData->oscData->path);
  126. std::strcat(targetPath, "/set_parameter_count");
  127. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  128. }
  129. void CarlaEngine::oscSend_control_set_program_count(const uint pluginId, const uint32_t count) const noexcept
  130. {
  131. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  132. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  133. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  134. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  135. CARLA_SAFE_ASSERT_RETURN(count <= 50,);
  136. carla_debug("CarlaEngine::oscSend_control_set_program_count(%i, %i)", pluginId, count);
  137. char targetPath[std::strlen(pData->oscData->path)+19];
  138. std::strcpy(targetPath, pData->oscData->path);
  139. std::strcat(targetPath, "/set_program_count");
  140. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), static_cast<int32_t>(count));
  141. }
  142. void CarlaEngine::oscSend_control_set_midi_program_count(const uint pluginId, const uint32_t count) const noexcept
  143. {
  144. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  145. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  146. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  147. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  148. CARLA_SAFE_ASSERT_RETURN(count <= 50,);
  149. carla_debug("CarlaEngine::oscSend_control_set_midi_program_count(%i, %i)", pluginId, count);
  150. char targetPath[std::strlen(pData->oscData->path)+24];
  151. std::strcpy(targetPath, pData->oscData->path);
  152. std::strcat(targetPath, "/set_midi_program_count");
  153. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), static_cast<int32_t>(count));
  154. }
  155. 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
  156. {
  157. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  158. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  159. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  160. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  161. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  162. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0',);
  163. CARLA_SAFE_ASSERT_RETURN(unit != nullptr,);
  164. carla_debug("CarlaEngine::oscSend_control_set_parameter_data(%i, %i, %i:%s, %X, \"%s\", \"%s\")", pluginId, index, type, ParameterType2Str(type), hints, name, unit);
  165. char targetPath[std::strlen(pData->oscData->path)+20];
  166. std::strcpy(targetPath, pData->oscData->path);
  167. std::strcat(targetPath, "/set_parameter_data");
  168. 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);
  169. }
  170. 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
  171. {
  172. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  173. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  174. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  175. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  176. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  177. CARLA_SAFE_ASSERT(def >= min && def <= max);
  178. CARLA_SAFE_ASSERT(min < max);
  179. carla_debug("CarlaEngine::oscSend_control_set_parameter_ranges1(%i, %i, %f, %f, %f)", pluginId, index, def, min, max, def);
  180. char targetPath[std::strlen(pData->oscData->path)+24];
  181. std::strcpy(targetPath, pData->oscData->path);
  182. std::strcat(targetPath, "/set_parameter_ranges1");
  183. try_lo_send(pData->oscData->target, targetPath, "iifff",
  184. static_cast<int32_t>(pluginId),
  185. static_cast<int32_t>(index),
  186. static_cast<double>(def),
  187. static_cast<double>(min),
  188. static_cast<double>(max));
  189. }
  190. 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
  191. {
  192. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  193. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  194. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  195. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  196. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  197. CARLA_SAFE_ASSERT(step >= stepSmall && step <= stepLarge);
  198. CARLA_SAFE_ASSERT(stepSmall <= stepLarge);
  199. carla_debug("CarlaEngine::oscSend_control_set_parameter_ranges2(%i, %i, %f, %f, %f)", pluginId, index, step, stepSmall, stepLarge);
  200. char targetPath[std::strlen(pData->oscData->path)+24];
  201. std::strcpy(targetPath, pData->oscData->path);
  202. std::strcat(targetPath, "/set_parameter_ranges2");
  203. try_lo_send(pData->oscData->target, targetPath, "iifff",
  204. static_cast<int32_t>(pluginId),
  205. static_cast<int32_t>(index),
  206. static_cast<double>(step),
  207. static_cast<double>(stepSmall),
  208. static_cast<double>(stepLarge));
  209. }
  210. void CarlaEngine::oscSend_control_set_parameter_midi_cc(const uint pluginId, const uint32_t index, const int16_t cc) const noexcept
  211. {
  212. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  213. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  214. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  215. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  216. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  217. CARLA_SAFE_ASSERT_RETURN(cc >= -1 && cc < MAX_MIDI_CONTROL,);
  218. carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_cc(%i, %i, %i)", pluginId, index, cc);
  219. char targetPath[std::strlen(pData->oscData->path)+23];
  220. std::strcpy(targetPath, pData->oscData->path);
  221. std::strcat(targetPath, "/set_parameter_midi_cc");
  222. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(cc));
  223. }
  224. void CarlaEngine::oscSend_control_set_parameter_midi_channel(const uint pluginId, const uint32_t index, const uint8_t channel) const noexcept
  225. {
  226. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  227. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  228. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  229. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  230. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  231. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  232. carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_channel(%i, %i, %i)", pluginId, index, channel);
  233. char targetPath[std::strlen(pData->oscData->path)+28];
  234. std::strcpy(targetPath, pData->oscData->path);
  235. std::strcat(targetPath, "/set_parameter_midi_channel");
  236. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(channel));
  237. }
  238. void CarlaEngine::oscSend_control_set_parameter_value(const uint pluginId, const int32_t index, const float value) const noexcept
  239. {
  240. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  241. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  242. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  243. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  244. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  245. CARLA_SAFE_ASSERT_RETURN(index != PARAMETER_NULL,);
  246. carla_debug("CarlaEngine::oscSend_control_set_parameter_value(%i, %i:%s, %f)", pluginId, index,
  247. (index < 0) ? InternalParameterIndex2Str(static_cast<InternalParameterIndex>(index)) : "(none)", value);
  248. char targetPath[std::strlen(pData->oscData->path)+21];
  249. std::strcpy(targetPath, pData->oscData->path);
  250. std::strcat(targetPath, "/set_parameter_value");
  251. try_lo_send(pData->oscData->target, targetPath, "iif",
  252. static_cast<int32_t>(pluginId),
  253. index,
  254. static_cast<double>(value));
  255. }
  256. void CarlaEngine::oscSend_control_set_default_value(const uint pluginId, const uint32_t index, const float value) 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_SAFE_ASSERT_RETURN(index < 50,);
  263. carla_debug("CarlaEngine::oscSend_control_set_default_value(%i, %i, %f)", pluginId, index, value);
  264. char targetPath[std::strlen(pData->oscData->path)+19];
  265. std::strcpy(targetPath, pData->oscData->path);
  266. std::strcat(targetPath, "/set_default_value");
  267. try_lo_send(pData->oscData->target, targetPath, "iif",
  268. static_cast<int32_t>(pluginId),
  269. static_cast<int32_t>(index),
  270. static_cast<double>(value));
  271. }
  272. void CarlaEngine::oscSend_control_set_current_program(const uint pluginId, const int32_t index) const noexcept
  273. {
  274. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  275. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  276. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  277. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  278. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  279. carla_debug("CarlaEngine::oscSend_control_set_current_program(%i, %i)", pluginId, index);
  280. char targetPath[std::strlen(pData->oscData->path)+21];
  281. std::strcpy(targetPath, pData->oscData->path);
  282. std::strcat(targetPath, "/set_current_program");
  283. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), index);
  284. }
  285. void CarlaEngine::oscSend_control_set_current_midi_program(const uint pluginId, const int32_t index) const noexcept
  286. {
  287. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  288. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  289. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  290. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  291. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  292. carla_debug("CarlaEngine::oscSend_control_set_current_midi_program(%i, %i)", pluginId, index);
  293. char targetPath[std::strlen(pData->oscData->path)+26];
  294. std::strcpy(targetPath, pData->oscData->path);
  295. std::strcat(targetPath, "/set_current_midi_program");
  296. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), index);
  297. }
  298. void CarlaEngine::oscSend_control_set_program_name(const uint pluginId, const uint32_t index, const char* const name) const noexcept
  299. {
  300. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  301. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  302. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  303. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  304. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  305. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  306. carla_debug("CarlaEngine::oscSend_control_set_program_name(%i, %i, \"%s\")", pluginId, index, name);
  307. char targetPath[std::strlen(pData->oscData->path)+18];
  308. std::strcpy(targetPath, pData->oscData->path);
  309. std::strcat(targetPath, "/set_program_name");
  310. try_lo_send(pData->oscData->target, targetPath, "iis", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), name);
  311. }
  312. 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
  313. {
  314. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  315. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  316. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  317. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  318. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  319. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  320. carla_debug("CarlaEngine::oscSend_control_set_midi_program_data(%i, %i, %i, %i, \"%s\")", pluginId, index, bank, program, name);
  321. char targetPath[std::strlen(pData->oscData->path)+23];
  322. std::strcpy(targetPath, pData->oscData->path);
  323. std::strcat(targetPath, "/set_midi_program_data");
  324. 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);
  325. }
  326. void CarlaEngine::oscSend_control_note_on(const uint pluginId, const uint8_t channel, const uint8_t note, const uint8_t velo) const noexcept
  327. {
  328. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  329. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  330. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  331. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  332. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  333. CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_NOTE,);
  334. CARLA_SAFE_ASSERT_RETURN(velo < MAX_MIDI_VALUE,);
  335. carla_debug("CarlaEngine::oscSend_control_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo);
  336. char targetPath[std::strlen(pData->oscData->path)+9];
  337. std::strcpy(targetPath, pData->oscData->path);
  338. std::strcat(targetPath, "/note_on");
  339. 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));
  340. }
  341. void CarlaEngine::oscSend_control_note_off(const uint pluginId, const uint8_t channel, const uint8_t note) const noexcept
  342. {
  343. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  344. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  345. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  346. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  347. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  348. CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_NOTE,);
  349. carla_debug("CarlaEngine::oscSend_control_note_off(%i, %i, %i)", pluginId, channel, note);
  350. char targetPath[std::strlen(pData->oscData->path)+10];
  351. std::strcpy(targetPath, pData->oscData->path);
  352. std::strcat(targetPath, "/note_off");
  353. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(channel), static_cast<int32_t>(note));
  354. }
  355. void CarlaEngine::oscSend_control_set_peaks(const uint pluginId) const noexcept
  356. {
  357. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  358. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  359. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  360. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  361. // TODO - try and see if we can get peaks[4] ref
  362. const EnginePluginData& epData(pData->plugins[pluginId]);
  363. char targetPath[std::strlen(pData->oscData->path)+11];
  364. std::strcpy(targetPath, pData->oscData->path);
  365. std::strcat(targetPath, "/set_peaks");
  366. try_lo_send(pData->oscData->target, targetPath, "iffff", static_cast<int32_t>(pluginId),
  367. static_cast<double>(epData.peaks[0]),
  368. static_cast<double>(epData.peaks[1]),
  369. static_cast<double>(epData.peaks[2]),
  370. static_cast<double>(epData.peaks[3]));
  371. }
  372. void CarlaEngine::oscSend_control_exit() const noexcept
  373. {
  374. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  375. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  376. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  377. carla_debug("CarlaEngine::oscSend_control_exit()");
  378. char targetPath[std::strlen(pData->oscData->path)+6];
  379. std::strcpy(targetPath, pData->oscData->path);
  380. std::strcat(targetPath, "/exit");
  381. try_lo_send(pData->oscData->target, targetPath, "");
  382. }
  383. #endif // BUILD_BRIDGE
  384. // -----------------------------------------------------------------------
  385. CARLA_BACKEND_END_NAMESPACE
  386. #endif // HAVE_LIBLO