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.

476 lines
25KB

  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_callback(const EngineCallbackOpcode action, const uint pluginId,
  26. const int value1, const int value2, const int value3,
  27. const float valuef, const char* const valueStr) const noexcept
  28. {
  29. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  30. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  31. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  32. carla_debug("CarlaEngine::oscSend_control_callback(%i:%s, %i, %i, %i, %i, %f, \"%s\")",
  33. action, EngineCallbackOpcode2Str(action), pluginId, value1, value2, value3, valuef, valueStr);
  34. static const char* const kFakeNullString = "(null)";
  35. char targetPath[std::strlen(pData->oscData->path)+10];
  36. std::strcpy(targetPath, pData->oscData->path);
  37. std::strcat(targetPath, "/callback");
  38. try_lo_send(pData->oscData->target, targetPath, "iiiiifs",
  39. action, pluginId, value1, value2, value3, static_cast<double>(valuef),
  40. valueStr != nullptr ? valueStr : kFakeNullString);
  41. }
  42. void CarlaEngine::oscSend_control_add_plugin_start(const uint pluginId, const char* const pluginName) const noexcept
  43. {
  44. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  45. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  46. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  47. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  48. CARLA_SAFE_ASSERT_RETURN(pluginName != nullptr && pluginName[0] != '\0',);
  49. carla_debug("CarlaEngine::oscSend_control_add_plugin_start(%i, \"%s\")", pluginId, pluginName);
  50. char targetPath[std::strlen(pData->oscData->path)+18];
  51. std::strcpy(targetPath, pData->oscData->path);
  52. std::strcat(targetPath, "/add_plugin_start");
  53. try_lo_send(pData->oscData->target, targetPath, "is", static_cast<int32_t>(pluginId), pluginName);
  54. }
  55. #if 0
  56. void CarlaEngine::oscSend_control_add_plugin_end(const uint pluginId) const noexcept
  57. {
  58. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  59. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  60. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  61. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  62. carla_debug("CarlaEngine::oscSend_control_add_plugin_end(%i)", pluginId);
  63. char targetPath[std::strlen(pData->oscData->path)+16];
  64. std::strcpy(targetPath, pData->oscData->path);
  65. std::strcat(targetPath, "/add_plugin_end");
  66. try_lo_send(pData->oscData->target, targetPath, "i", static_cast<int32_t>(pluginId));
  67. }
  68. void CarlaEngine::oscSend_control_remove_plugin(const uint pluginId) const noexcept
  69. {
  70. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  71. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  72. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  73. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  74. carla_debug("CarlaEngine::oscSend_control_remove_plugin(%i)", pluginId);
  75. char targetPath[std::strlen(pData->oscData->path)+15];
  76. std::strcpy(targetPath, pData->oscData->path);
  77. std::strcat(targetPath, "/remove_plugin");
  78. try_lo_send(pData->oscData->target, targetPath, "i", static_cast<int32_t>(pluginId));
  79. }
  80. #endif
  81. 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
  82. {
  83. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  84. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  85. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  86. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  87. CARLA_SAFE_ASSERT_RETURN(type != PLUGIN_NONE,);
  88. 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);
  89. char targetPath[std::strlen(pData->oscData->path)+18];
  90. std::strcpy(targetPath, pData->oscData->path);
  91. std::strcat(targetPath, "/set_plugin_info1");
  92. 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));
  93. }
  94. 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
  95. {
  96. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  97. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  98. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  99. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  100. CARLA_SAFE_ASSERT_RETURN(realName != nullptr && realName[0] != '\0',);
  101. CARLA_SAFE_ASSERT_RETURN(label != nullptr && label[0] != '\0',);
  102. CARLA_SAFE_ASSERT_RETURN(maker != nullptr,);
  103. CARLA_SAFE_ASSERT_RETURN(copyright != nullptr,);
  104. carla_debug("CarlaEngine::oscSend_control_set_plugin_data(%i, \"%s\", \"%s\", \"%s\", \"%s\")", pluginId, realName, label, maker, copyright);
  105. char targetPath[std::strlen(pData->oscData->path)+18];
  106. std::strcpy(targetPath, pData->oscData->path);
  107. std::strcat(targetPath, "/set_plugin_info2");
  108. try_lo_send(pData->oscData->target, targetPath, "issss", static_cast<int32_t>(pluginId), realName, label, maker, copyright);
  109. }
  110. void CarlaEngine::oscSend_control_set_audio_count(const uint pluginId, const uint32_t ins, const uint32_t outs) const noexcept
  111. {
  112. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  113. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  114. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  115. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  116. carla_debug("CarlaEngine::oscSend_control_set_audio_count(%i, %i, %i)", pluginId, ins, outs);
  117. char targetPath[std::strlen(pData->oscData->path)+18];
  118. std::strcpy(targetPath, pData->oscData->path);
  119. std::strcat(targetPath, "/set_audio_count");
  120. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  121. }
  122. void CarlaEngine::oscSend_control_set_midi_count(const uint pluginId, const uint32_t ins, const uint32_t outs) const noexcept
  123. {
  124. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  125. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  126. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  127. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  128. carla_debug("CarlaEngine::oscSend_control_set_midi_count(%i, %i, %i)", pluginId, ins, outs);
  129. char targetPath[std::strlen(pData->oscData->path)+18];
  130. std::strcpy(targetPath, pData->oscData->path);
  131. std::strcat(targetPath, "/set_midi_count");
  132. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  133. }
  134. void CarlaEngine::oscSend_control_set_parameter_count(const uint pluginId, const uint32_t ins, const uint32_t outs) const noexcept
  135. {
  136. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  137. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  138. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  139. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  140. CARLA_SAFE_ASSERT_RETURN(ins < 50,);
  141. CARLA_SAFE_ASSERT_RETURN(outs < 50,);
  142. carla_debug("CarlaEngine::oscSend_control_set_parameter_count(%i, %i, %i)", pluginId, ins, outs);
  143. char targetPath[std::strlen(pData->oscData->path)+18];
  144. std::strcpy(targetPath, pData->oscData->path);
  145. std::strcat(targetPath, "/set_parameter_count");
  146. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(ins), static_cast<int32_t>(outs));
  147. }
  148. void CarlaEngine::oscSend_control_set_program_count(const uint pluginId, const uint32_t count) const noexcept
  149. {
  150. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  151. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  152. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  153. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  154. CARLA_SAFE_ASSERT_RETURN(count <= 50,);
  155. carla_debug("CarlaEngine::oscSend_control_set_program_count(%i, %i)", pluginId, count);
  156. char targetPath[std::strlen(pData->oscData->path)+19];
  157. std::strcpy(targetPath, pData->oscData->path);
  158. std::strcat(targetPath, "/set_program_count");
  159. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), static_cast<int32_t>(count));
  160. }
  161. void CarlaEngine::oscSend_control_set_midi_program_count(const uint pluginId, const uint32_t count) const noexcept
  162. {
  163. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  164. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  165. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  166. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  167. CARLA_SAFE_ASSERT_RETURN(count <= 50,);
  168. carla_debug("CarlaEngine::oscSend_control_set_midi_program_count(%i, %i)", pluginId, count);
  169. char targetPath[std::strlen(pData->oscData->path)+24];
  170. std::strcpy(targetPath, pData->oscData->path);
  171. std::strcat(targetPath, "/set_midi_program_count");
  172. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), static_cast<int32_t>(count));
  173. }
  174. 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
  175. {
  176. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  177. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  178. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  179. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  180. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  181. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0',);
  182. CARLA_SAFE_ASSERT_RETURN(unit != nullptr,);
  183. carla_debug("CarlaEngine::oscSend_control_set_parameter_data(%i, %i, %i:%s, %X, \"%s\", \"%s\")", pluginId, index, type, ParameterType2Str(type), hints, name, unit);
  184. char targetPath[std::strlen(pData->oscData->path)+20];
  185. std::strcpy(targetPath, pData->oscData->path);
  186. std::strcat(targetPath, "/set_parameter_data");
  187. 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);
  188. }
  189. 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
  190. {
  191. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  192. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  193. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  194. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  195. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  196. CARLA_SAFE_ASSERT(def >= min && def <= max);
  197. CARLA_SAFE_ASSERT(min < max);
  198. carla_debug("CarlaEngine::oscSend_control_set_parameter_ranges1(%i, %i, %f, %f, %f)", pluginId, index, def, min, max, def);
  199. char targetPath[std::strlen(pData->oscData->path)+24];
  200. std::strcpy(targetPath, pData->oscData->path);
  201. std::strcat(targetPath, "/set_parameter_ranges1");
  202. try_lo_send(pData->oscData->target, targetPath, "iifff",
  203. static_cast<int32_t>(pluginId),
  204. static_cast<int32_t>(index),
  205. static_cast<double>(def),
  206. static_cast<double>(min),
  207. static_cast<double>(max));
  208. }
  209. 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
  210. {
  211. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  212. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  213. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  214. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  215. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  216. CARLA_SAFE_ASSERT(step >= stepSmall && step <= stepLarge);
  217. CARLA_SAFE_ASSERT(stepSmall <= stepLarge);
  218. carla_debug("CarlaEngine::oscSend_control_set_parameter_ranges2(%i, %i, %f, %f, %f)", pluginId, index, step, stepSmall, stepLarge);
  219. char targetPath[std::strlen(pData->oscData->path)+24];
  220. std::strcpy(targetPath, pData->oscData->path);
  221. std::strcat(targetPath, "/set_parameter_ranges2");
  222. try_lo_send(pData->oscData->target, targetPath, "iifff",
  223. static_cast<int32_t>(pluginId),
  224. static_cast<int32_t>(index),
  225. static_cast<double>(step),
  226. static_cast<double>(stepSmall),
  227. static_cast<double>(stepLarge));
  228. }
  229. #if 0
  230. void CarlaEngine::oscSend_control_set_parameter_midi_cc(const uint pluginId, const uint32_t index, const int16_t cc) const noexcept
  231. {
  232. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  233. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  234. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  235. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  236. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  237. CARLA_SAFE_ASSERT_RETURN(cc >= -1 && cc < MAX_MIDI_CONTROL,);
  238. carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_cc(%i, %i, %i)", pluginId, index, cc);
  239. char targetPath[std::strlen(pData->oscData->path)+23];
  240. std::strcpy(targetPath, pData->oscData->path);
  241. std::strcat(targetPath, "/set_parameter_midi_cc");
  242. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(cc));
  243. }
  244. void CarlaEngine::oscSend_control_set_parameter_midi_channel(const uint pluginId, const uint32_t index, const uint8_t channel) 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_SAFE_ASSERT_RETURN(index < 50,);
  251. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  252. carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_channel(%i, %i, %i)", pluginId, index, channel);
  253. char targetPath[std::strlen(pData->oscData->path)+28];
  254. std::strcpy(targetPath, pData->oscData->path);
  255. std::strcat(targetPath, "/set_parameter_midi_channel");
  256. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(channel));
  257. }
  258. #endif
  259. void CarlaEngine::oscSend_control_set_output_parameter_value(const uint pluginId, const int32_t index, const float value) const noexcept
  260. {
  261. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  262. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  263. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  264. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  265. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  266. CARLA_SAFE_ASSERT_RETURN(index != PARAMETER_NULL,);
  267. carla_debug("CarlaEngine::oscSend_control_set_output_parameter_value(%i, %i:%s, %f)", pluginId, index,
  268. (index < 0) ? InternalParameterIndex2Str(static_cast<InternalParameterIndex>(index)) : "(none)", value);
  269. char targetPath[std::strlen(pData->oscData->path)+21];
  270. std::strcpy(targetPath, pData->oscData->path);
  271. std::strcat(targetPath, "/set_output_parameter_value");
  272. try_lo_send(pData->oscData->target, targetPath, "iif",
  273. static_cast<int32_t>(pluginId),
  274. index,
  275. static_cast<double>(value));
  276. }
  277. #if 0
  278. void CarlaEngine::oscSend_control_set_default_value(const uint pluginId, const uint32_t index, const float value) const noexcept
  279. {
  280. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  281. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  282. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  283. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  284. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  285. carla_debug("CarlaEngine::oscSend_control_set_default_value(%i, %i, %f)", pluginId, index, value);
  286. char targetPath[std::strlen(pData->oscData->path)+19];
  287. std::strcpy(targetPath, pData->oscData->path);
  288. std::strcat(targetPath, "/set_default_value");
  289. try_lo_send(pData->oscData->target, targetPath, "iif",
  290. static_cast<int32_t>(pluginId),
  291. static_cast<int32_t>(index),
  292. static_cast<double>(value));
  293. }
  294. void CarlaEngine::oscSend_control_set_current_program(const uint pluginId, const int32_t index) 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(index < 50,);
  301. carla_debug("CarlaEngine::oscSend_control_set_current_program(%i, %i)", pluginId, index);
  302. char targetPath[std::strlen(pData->oscData->path)+21];
  303. std::strcpy(targetPath, pData->oscData->path);
  304. std::strcat(targetPath, "/set_current_program");
  305. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), index);
  306. }
  307. void CarlaEngine::oscSend_control_set_current_midi_program(const uint pluginId, const int32_t index) const noexcept
  308. {
  309. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  310. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  311. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  312. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  313. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  314. carla_debug("CarlaEngine::oscSend_control_set_current_midi_program(%i, %i)", pluginId, index);
  315. char targetPath[std::strlen(pData->oscData->path)+26];
  316. std::strcpy(targetPath, pData->oscData->path);
  317. std::strcat(targetPath, "/set_current_midi_program");
  318. try_lo_send(pData->oscData->target, targetPath, "ii", static_cast<int32_t>(pluginId), index);
  319. }
  320. #endif
  321. void CarlaEngine::oscSend_control_set_program_name(const uint pluginId, const uint32_t index, const char* const name) const noexcept
  322. {
  323. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  324. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  325. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  326. CARLA_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  327. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  328. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  329. carla_debug("CarlaEngine::oscSend_control_set_program_name(%i, %i, \"%s\")", pluginId, index, name);
  330. char targetPath[std::strlen(pData->oscData->path)+18];
  331. std::strcpy(targetPath, pData->oscData->path);
  332. std::strcat(targetPath, "/set_program_name");
  333. try_lo_send(pData->oscData->target, targetPath, "iis", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), name);
  334. }
  335. 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
  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_SAFE_ASSERT_RETURN(pluginId <= pData->curPluginCount,);
  341. CARLA_SAFE_ASSERT_RETURN(index < 50,);
  342. CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
  343. carla_debug("CarlaEngine::oscSend_control_set_midi_program_data(%i, %i, %i, %i, \"%s\")", pluginId, index, bank, program, name);
  344. char targetPath[std::strlen(pData->oscData->path)+23];
  345. std::strcpy(targetPath, pData->oscData->path);
  346. std::strcat(targetPath, "/set_midi_program_data");
  347. 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);
  348. }
  349. #if 0
  350. void CarlaEngine::oscSend_control_note_on(const uint pluginId, const uint8_t channel, const uint8_t note, const uint8_t velo) const noexcept
  351. {
  352. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  353. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  354. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  355. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  356. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  357. CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_NOTE,);
  358. CARLA_SAFE_ASSERT_RETURN(velo < MAX_MIDI_VALUE,);
  359. carla_debug("CarlaEngine::oscSend_control_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo);
  360. char targetPath[std::strlen(pData->oscData->path)+9];
  361. std::strcpy(targetPath, pData->oscData->path);
  362. std::strcat(targetPath, "/note_on");
  363. 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));
  364. }
  365. void CarlaEngine::oscSend_control_note_off(const uint pluginId, const uint8_t channel, const uint8_t note) const noexcept
  366. {
  367. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  368. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  369. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  370. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  371. CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);
  372. CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_NOTE,);
  373. carla_debug("CarlaEngine::oscSend_control_note_off(%i, %i, %i)", pluginId, channel, note);
  374. char targetPath[std::strlen(pData->oscData->path)+10];
  375. std::strcpy(targetPath, pData->oscData->path);
  376. std::strcat(targetPath, "/note_off");
  377. try_lo_send(pData->oscData->target, targetPath, "iii", static_cast<int32_t>(pluginId), static_cast<int32_t>(channel), static_cast<int32_t>(note));
  378. }
  379. #endif
  380. void CarlaEngine::oscSend_control_set_peaks(const uint pluginId) const noexcept
  381. {
  382. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  383. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  384. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  385. CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,);
  386. // TODO - try and see if we can get peaks[4] ref
  387. const EnginePluginData& epData(pData->plugins[pluginId]);
  388. char targetPath[std::strlen(pData->oscData->path)+11];
  389. std::strcpy(targetPath, pData->oscData->path);
  390. std::strcat(targetPath, "/set_peaks");
  391. try_lo_send(pData->oscData->target, targetPath, "iffff", static_cast<int32_t>(pluginId),
  392. static_cast<double>(epData.peaks[0]),
  393. static_cast<double>(epData.peaks[1]),
  394. static_cast<double>(epData.peaks[2]),
  395. static_cast<double>(epData.peaks[3]));
  396. }
  397. #if 0
  398. void CarlaEngine::oscSend_control_exit() const noexcept
  399. {
  400. CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,);
  401. CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',);
  402. CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,);
  403. carla_debug("CarlaEngine::oscSend_control_exit()");
  404. char targetPath[std::strlen(pData->oscData->path)+6];
  405. std::strcpy(targetPath, pData->oscData->path);
  406. std::strcat(targetPath, "/exit");
  407. try_lo_send(pData->oscData->target, targetPath, "");
  408. }
  409. #endif
  410. #endif // BUILD_BRIDGE
  411. // -----------------------------------------------------------------------
  412. CARLA_BACKEND_END_NAMESPACE
  413. #endif // HAVE_LIBLO