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.

425 lines
23KB

  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_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", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), def, min, max);
  184. }
  185. 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
  186. {
  187. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  188. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  189. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  190. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  191. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  192. CARLA_SAFE_ASSERT(step >= stepSmall && step <= stepLarge);
  193. CARLA_SAFE_ASSERT(stepSmall <= stepLarge);
  194. carla_debug("CarlaEngine::oscSend_control_set_parameter_ranges2(%i, %i, %f, %f, %f)", pluginId, index, step, stepSmall, stepLarge);
  195. char targetPath[std::strlen(pData->oscData->path)+24];
  196. std::strcpy(targetPath, pData->oscData->path);
  197. std::strcat(targetPath, "/set_parameter_ranges2");
  198. try_lo_send(pData->oscData->target, targetPath, "iifff", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), step, stepSmall, stepLarge);
  199. }
  200. void CarlaEngine::oscSend_control_set_parameter_midi_cc(const uint pluginId, const uint32_t index, const int16_t cc) const noexcept
  201. {
  202. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  203. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  204. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  205. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  206. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  207. CARLA_SAFE_ASSERT_RETURN(cc >= -1 && cc < MAX_MIDI_CONTROL,);
  208. carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_cc(%i, %i, %i)", pluginId, index, cc);
  209. char targetPath[std::strlen(pData->oscData->path)+23];
  210. std::strcpy(targetPath, pData->oscData->path);
  211. std::strcat(targetPath, "/set_parameter_midi_cc");
  212. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(cc));
  213. }
  214. void CarlaEngine::oscSend_control_set_parameter_midi_channel(const uint pluginId, const uint32_t index, const uint8_t channel) const noexcept
  215. {
  216. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  217. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  218. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  219. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  220. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  221. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  222. carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_channel(%i, %i, %i)", pluginId, index, channel);
  223. char targetPath[std::strlen(pData->oscData->path)+28];
  224. std::strcpy(targetPath, pData->oscData->path);
  225. std::strcat(targetPath, "/set_parameter_midi_channel");
  226. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(channel));
  227. }
  228. void CarlaEngine::oscSend_control_set_parameter_value(const uint pluginId, const int32_t index, const float value) const noexcept
  229. {
  230. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  231. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  232. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  233. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  234. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  235. CARLA_SAFE_ASSERT_RETURN(index != PARAMETER_NULL,);
  236. carla_debug("CarlaEngine::oscSend_control_set_parameter_value(%i, %i:%s, %f)", pluginId, index, (index < 0) ? InternalParameterIndex2Str(static_cast<InternalParameterIndex>(index)) : "(none)", value);
  237. char targetPath[std::strlen(pData->oscData->path)+21];
  238. std::strcpy(targetPath, pData->oscData->path);
  239. std::strcat(targetPath, "/set_parameter_value");
  240. try_lo_send(pData->oscData->target, targetPath, "iif", static_cast<int32_t>(pluginId), index, value);
  241. }
  242. void CarlaEngine::oscSend_control_set_default_value(const uint pluginId, const uint32_t index, const float value) const noexcept
  243. {
  244. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  245. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  246. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  247. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  248. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  249. carla_debug("CarlaEngine::oscSend_control_set_default_value(%i, %i, %f)", pluginId, index, value);
  250. char targetPath[std::strlen(pData->oscData->path)+19];
  251. std::strcpy(targetPath, pData->oscData->path);
  252. std::strcat(targetPath, "/set_default_value");
  253. try_lo_send(pData->oscData->target, targetPath, "iif", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), value);
  254. }
  255. void CarlaEngine::oscSend_control_set_current_program(const uint pluginId, const int32_t index) const noexcept
  256. {
  257. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  258. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  259. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  260. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  261. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  262. carla_debug("CarlaEngine::oscSend_control_set_current_program(%i, %i)", pluginId, index);
  263. char targetPath[std::strlen(pData->oscData->path)+21];
  264. std::strcpy(targetPath, pData->oscData->path);
  265. std::strcat(targetPath, "/set_current_program");
  266. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), index);
  267. }
  268. void CarlaEngine::oscSend_control_set_current_midi_program(const uint pluginId, const int32_t index) 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(index < 50,);
  275. carla_debug("CarlaEngine::oscSend_control_set_current_midi_program(%i, %i)", pluginId, index);
  276. char targetPath[std::strlen(pData->oscData->path)+26];
  277. std::strcpy(targetPath, pData->oscData->path);
  278. std::strcat(targetPath, "/set_current_midi_program");
  279. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), index);
  280. }
  281. void CarlaEngine::oscSend_control_set_program_name(const uint pluginId, const uint32_t index, 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(index < 50,);
  288. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  289. carla_debug("CarlaEngine::oscSend_control_set_program_name(%i, %i, \"%s\")", pluginId, index, name);
  290. char targetPath[std::strlen(pData->oscData->path)+18];
  291. std::strcpy(targetPath, pData->oscData->path);
  292. std::strcat(targetPath, "/set_program_name");
  293. try_lo_send(pData->oscData->target, targetPath, "iis", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), name);
  294. }
  295. 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
  296. {
  297. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  298. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  299. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  300. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  301. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  302. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  303. carla_debug("CarlaEngine::oscSend_control_set_midi_program_data(%i, %i, %i, %i, \"%s\")", pluginId, index, bank, program, name);
  304. char targetPath[std::strlen(pData->oscData->path)+23];
  305. std::strcpy(targetPath, pData->oscData->path);
  306. std::strcat(targetPath, "/set_midi_program_data");
  307. 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);
  308. }
  309. void CarlaEngine::oscSend_control_note_on(const uint pluginId, const uint8_t channel, const uint8_t note, const uint8_t velo) 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_SAFE_ASSERT_RETURN(velo < MAX_MIDI_VALUE,);
  318. carla_debug("CarlaEngine::oscSend_control_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo);
  319. char targetPath[std::strlen(pData->oscData->path)+9];
  320. std::strcpy(targetPath, pData->oscData->path);
  321. std::strcat(targetPath, "/note_on");
  322. 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));
  323. }
  324. void CarlaEngine::oscSend_control_note_off(const uint pluginId, const uint8_t channel, const uint8_t note) const noexcept
  325. {
  326. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  327. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  328. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  329. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  330. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  331. CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_NOTE,);
  332. carla_debug("CarlaEngine::oscSend_control_note_off(%i, %i, %i)", pluginId, channel, note);
  333. char targetPath[std::strlen(pData->oscData->path)+10];
  334. std::strcpy(targetPath, pData->oscData->path);
  335. std::strcat(targetPath, "/note_off");
  336. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(channel), static_cast<int32_t>(note));
  337. }
  338. void CarlaEngine::oscSend_control_set_peaks(const uint pluginId) const noexcept
  339. {
  340. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  341. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  342. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  343. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  344. // TODO - try and see if we can get peaks[4] ref
  345. const EnginePluginData& epData(pData->plugins[pluginId]);
  346. char targetPath[std::strlen(pData->oscData->path)+11];
  347. std::strcpy(targetPath, pData->oscData->path);
  348. std::strcat(targetPath, "/set_peaks");
  349. 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]);
  350. }
  351. void CarlaEngine::oscSend_control_exit() const noexcept
  352. {
  353. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  354. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  355. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  356. carla_debug("CarlaEngine::oscSend_control_exit()");
  357. char targetPath[std::strlen(pData->oscData->path)+6];
  358. std::strcpy(targetPath, pData->oscData->path);
  359. std::strcat(targetPath, "/exit");
  360. try_lo_send(pData->oscData->target, targetPath, "");
  361. }
  362. #endif // BUILD_BRIDGE
  363. // -----------------------------------------------------------------------
  364. CARLA_BACKEND_END_NAMESPACE
  365. #endif // HAVE_LIBLO