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.

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