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.

carla_backend.py 22KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla Backend code
  4. # Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the GPL.txt file
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. from ctypes import *
  20. # ------------------------------------------------------------------------------------------------------------
  21. # Imports (Custom)
  22. from carla_shared import *
  23. # ------------------------------------------------------------------------------------------------------------
  24. # Convert a ctypes struct into a python dict
  25. def structToDict(struct):
  26. return dict((attr, getattr(struct, attr)) for attr, value in struct._fields_)
  27. # ------------------------------------------------------------------------------------------------------------
  28. # Backend C++ -> Python variables
  29. c_enum = c_int
  30. c_nullptr = None
  31. c_uintptr = c_uint64 if kIs64bit else c_uint32
  32. CallbackFunc = CFUNCTYPE(None, c_void_p, c_enum, c_uint, c_int, c_int, c_float, c_char_p)
  33. class ParameterData(Structure):
  34. _fields_ = [
  35. ("type", c_enum),
  36. ("index", c_int32),
  37. ("rindex", c_int32),
  38. ("hints", c_uint32),
  39. ("midiChannel", c_uint8),
  40. ("midiCC", c_int16)
  41. ]
  42. class ParameterRanges(Structure):
  43. _fields_ = [
  44. ("def", c_float),
  45. ("min", c_float),
  46. ("max", c_float),
  47. ("step", c_float),
  48. ("stepSmall", c_float),
  49. ("stepLarge", c_float)
  50. ]
  51. class MidiProgramData(Structure):
  52. _fields_ = [
  53. ("bank", c_uint32),
  54. ("program", c_uint32),
  55. ("name", c_char_p)
  56. ]
  57. class CustomData(Structure):
  58. _fields_ = [
  59. ("type", c_char_p),
  60. ("key", c_char_p),
  61. ("value", c_char_p)
  62. ]
  63. # ------------------------------------------------------------------------------------------------------------
  64. # Standalone C++ -> Python variables
  65. class CarlaPluginInfo(Structure):
  66. _fields_ = [
  67. ("type", c_enum),
  68. ("category", c_enum),
  69. ("hints", c_uint),
  70. ("optionsAvailable", c_uint),
  71. ("optionsEnabled", c_uint),
  72. ("binary", c_char_p),
  73. ("name", c_char_p),
  74. ("label", c_char_p),
  75. ("maker", c_char_p),
  76. ("copyright", c_char_p),
  77. ("uniqueId", c_long),
  78. ("latency", c_uint32)
  79. ]
  80. class CarlaNativePluginInfo(Structure):
  81. _fields_ = [
  82. ("category", c_enum),
  83. ("hints", c_uint),
  84. ("audioIns", c_uint32),
  85. ("audioOuts", c_uint32),
  86. ("midiIns", c_uint32),
  87. ("midiOuts", c_uint32),
  88. ("parameterIns", c_uint32),
  89. ("parameterOuts", c_uint32),
  90. ("name", c_char_p),
  91. ("label", c_char_p),
  92. ("maker", c_char_p),
  93. ("copyright", c_char_p)
  94. ]
  95. class CarlaPortCountInfo(Structure):
  96. _fields_ = [
  97. ("ins", c_uint32),
  98. ("outs", c_uint32),
  99. ("total", c_uint32)
  100. ]
  101. class CarlaParameterInfo(Structure):
  102. _fields_ = [
  103. ("name", c_char_p),
  104. ("symbol", c_char_p),
  105. ("unit", c_char_p),
  106. ("scalePointCount", c_uint32)
  107. ]
  108. class CarlaScalePointInfo(Structure):
  109. _fields_ = [
  110. ("value", c_float),
  111. ("label", c_char_p)
  112. ]
  113. # ------------------------------------------------------------------------------------------------------------
  114. # Standalone Python object
  115. class Host(object):
  116. def __init__(self, lib_prefix_arg):
  117. object.__init__(self)
  118. global carla_library_path
  119. if lib_prefix_arg:
  120. carla_library_path = os.path.join(lib_prefix_arg, "lib", "carla", carla_libname)
  121. if not carla_library_path:
  122. self.lib = None
  123. return
  124. self.lib = cdll.LoadLibrary(carla_library_path)
  125. self.lib.carla_get_extended_license_text.argtypes = None
  126. self.lib.carla_get_extended_license_text.restype = c_char_p
  127. self.lib.carla_get_engine_driver_count.argtypes = None
  128. self.lib.carla_get_engine_driver_count.restype = c_uint
  129. self.lib.carla_get_engine_driver_name.argtypes = [c_uint]
  130. self.lib.carla_get_engine_driver_name.restype = c_char_p
  131. self.lib.carla_get_internal_plugin_count.argtypes = None
  132. self.lib.carla_get_internal_plugin_count.restype = c_uint
  133. self.lib.carla_get_internal_plugin_info.argtypes = [c_uint]
  134. self.lib.carla_get_internal_plugin_info.restype = POINTER(CarlaNativePluginInfo)
  135. self.lib.carla_engine_init.argtypes = [c_char_p, c_char_p]
  136. self.lib.carla_engine_init.restype = c_bool
  137. self.lib.carla_engine_close.argtypes = None
  138. self.lib.carla_engine_close.restype = c_bool
  139. self.lib.carla_engine_idle.argtypes = None
  140. self.lib.carla_engine_idle.restype = None
  141. self.lib.carla_is_engine_running.argtypes = None
  142. self.lib.carla_is_engine_running.restype = c_bool
  143. self.lib.carla_set_engine_about_to_close.argtypes = None
  144. self.lib.carla_set_engine_about_to_close.restype = None
  145. self.lib.carla_set_engine_callback.argtypes = [CallbackFunc, c_void_p]
  146. self.lib.carla_set_engine_callback.restype = None
  147. self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p]
  148. self.lib.carla_set_engine_option.restype = None
  149. self.lib.carla_load_project.argtypes = [c_char_p]
  150. self.lib.carla_load_project.restype = c_bool
  151. self.lib.carla_save_project.argtypes = [c_char_p]
  152. self.lib.carla_save_project.restype = c_bool
  153. self.lib.carla_transport_play.argtypes = None
  154. self.lib.carla_transport_play.restype = None
  155. self.lib.carla_transport_pause.argtypes = None
  156. self.lib.carla_transport_pause.restype = None
  157. self.lib.carla_transport_relocate.argtypes = [c_uint32]
  158. self.lib.carla_transport_relocate.restype = None
  159. self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_void_p]
  160. self.lib.carla_add_plugin.restype = c_bool
  161. self.lib.carla_remove_plugin.argtypes = [c_uint]
  162. self.lib.carla_remove_plugin.restype = c_bool
  163. self.lib.carla_remove_all_plugins.argtypes = None
  164. self.lib.carla_remove_all_plugins.restype = None
  165. self.lib.carla_load_plugin_state.argtypes = [c_uint, c_char_p]
  166. self.lib.carla_load_plugin_state.restype = c_bool
  167. self.lib.carla_save_plugin_state.argtypes = [c_uint, c_char_p]
  168. self.lib.carla_save_plugin_state.restype = c_bool
  169. self.lib.carla_get_plugin_info.argtypes = [c_uint]
  170. self.lib.carla_get_plugin_info.restype = POINTER(CarlaPluginInfo)
  171. self.lib.carla_get_audio_port_count_info.argtypes = [c_uint]
  172. self.lib.carla_get_audio_port_count_info.restype = POINTER(CarlaPortCountInfo)
  173. self.lib.carla_get_midi_port_count_info.argtypes = [c_uint]
  174. self.lib.carla_get_midi_port_count_info.restype = POINTER(CarlaPortCountInfo)
  175. self.lib.carla_get_parameter_count_info.argtypes = [c_uint]
  176. self.lib.carla_get_parameter_count_info.restype = POINTER(CarlaPortCountInfo)
  177. self.lib.carla_get_parameter_info.argtypes = [c_uint, c_uint32]
  178. self.lib.carla_get_parameter_info.restype = POINTER(CarlaParameterInfo)
  179. self.lib.carla_get_parameter_scalepoint_info.argtypes = [c_uint, c_uint32, c_uint32]
  180. self.lib.carla_get_parameter_scalepoint_info.restype = POINTER(CarlaScalePointInfo)
  181. self.lib.carla_get_parameter_data.argtypes = [c_uint, c_uint32]
  182. self.lib.carla_get_parameter_data.restype = POINTER(ParameterData)
  183. self.lib.carla_get_parameter_ranges.argtypes = [c_uint, c_uint32]
  184. self.lib.carla_get_parameter_ranges.restype = POINTER(ParameterRanges)
  185. self.lib.carla_get_midi_program_data.argtypes = [c_uint, c_uint32]
  186. self.lib.carla_get_midi_program_data.restype = POINTER(MidiProgramData)
  187. self.lib.carla_get_custom_data.argtypes = [c_uint, c_uint32]
  188. self.lib.carla_get_custom_data.restype = POINTER(CustomData)
  189. self.lib.carla_get_chunk_data.argtypes = [c_uint]
  190. self.lib.carla_get_chunk_data.restype = c_char_p
  191. self.lib.carla_get_parameter_count.argtypes = [c_uint]
  192. self.lib.carla_get_parameter_count.restype = c_uint32
  193. self.lib.carla_get_program_count.argtypes = [c_uint]
  194. self.lib.carla_get_program_count.restype = c_uint32
  195. self.lib.carla_get_midi_program_count.argtypes = [c_uint]
  196. self.lib.carla_get_midi_program_count.restype = c_uint32
  197. self.lib.carla_get_custom_data_count.argtypes = [c_uint]
  198. self.lib.carla_get_custom_data_count.restype = c_uint32
  199. self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32]
  200. self.lib.carla_get_parameter_text.restype = c_char_p
  201. self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32]
  202. self.lib.carla_get_program_name.restype = c_char_p
  203. self.lib.carla_get_midi_program_name.argtypes = [c_uint, c_uint32]
  204. self.lib.carla_get_midi_program_name.restype = c_char_p
  205. self.lib.carla_get_real_plugin_name.argtypes = [c_uint]
  206. self.lib.carla_get_real_plugin_name.restype = c_char_p
  207. self.lib.carla_get_current_program_index.argtypes = [c_uint]
  208. self.lib.carla_get_current_program_index.restype = c_int32
  209. self.lib.carla_get_current_midi_program_index.argtypes = [c_uint]
  210. self.lib.carla_get_current_midi_program_index.restype = c_int32
  211. # TODO - consider removal
  212. self.lib.carla_get_default_parameter_value.argtypes = [c_uint, c_uint32]
  213. self.lib.carla_get_default_parameter_value.restype = c_float
  214. # TODO - consider removal
  215. self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32]
  216. self.lib.carla_get_current_parameter_value.restype = c_float
  217. self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_ushort]
  218. self.lib.carla_get_input_peak_value.restype = c_float
  219. self.lib.carla_get_output_peak_value.argtypes = [c_uint, c_ushort]
  220. self.lib.carla_get_output_peak_value.restype = c_float
  221. self.lib.carla_set_option.argtypes = [c_uint, c_uint, c_bool]
  222. self.lib.carla_set_option.restype = None
  223. self.lib.carla_set_active.argtypes = [c_uint, c_bool]
  224. self.lib.carla_set_active.restype = None
  225. self.lib.carla_set_drywet.argtypes = [c_uint, c_float]
  226. self.lib.carla_set_drywet.restype = None
  227. self.lib.carla_set_volume.argtypes = [c_uint, c_float]
  228. self.lib.carla_set_volume.restype = None
  229. self.lib.carla_set_balance_left.argtypes = [c_uint, c_float]
  230. self.lib.carla_set_balance_left.restype = None
  231. self.lib.carla_set_balance_right.argtypes = [c_uint, c_float]
  232. self.lib.carla_set_balance_right.restype = None
  233. self.lib.carla_set_panning.argtypes = [c_uint, c_float]
  234. self.lib.carla_set_panning.restype = None
  235. self.lib.carla_set_ctrl_channel.argtypes = [c_uint, c_int8]
  236. self.lib.carla_set_ctrl_channel.restype = None
  237. self.lib.carla_set_parameter_value.argtypes = [c_uint, c_uint32, c_float]
  238. self.lib.carla_set_parameter_value.restype = None
  239. self.lib.carla_set_parameter_midi_cc.argtypes = [c_uint, c_uint32, c_int16]
  240. self.lib.carla_set_parameter_midi_cc.restype = None
  241. self.lib.carla_set_parameter_midi_channel.argtypes = [c_uint, c_uint32, c_uint8]
  242. self.lib.carla_set_parameter_midi_channel.restype = None
  243. self.lib.carla_set_program.argtypes = [c_uint, c_uint32]
  244. self.lib.carla_set_program.restype = None
  245. self.lib.carla_set_midi_program.argtypes = [c_uint, c_uint32]
  246. self.lib.carla_set_midi_program.restype = None
  247. self.lib.carla_set_custom_data.argtypes = [c_uint, c_char_p, c_char_p, c_char_p]
  248. self.lib.carla_set_custom_data.restype = None
  249. self.lib.carla_set_chunk_data.argtypes = [c_uint, c_char_p]
  250. self.lib.carla_set_chunk_data.restype = None
  251. self.lib.carla_prepare_for_save.argtypes = [c_uint]
  252. self.lib.carla_prepare_for_save.restype = None
  253. self.lib.carla_send_midi_note.argtypes = [c_uint, c_uint8, c_uint8, c_uint8]
  254. self.lib.carla_send_midi_note.restype = None
  255. self.lib.carla_show_gui.argtypes = [c_uint, c_bool]
  256. self.lib.carla_show_gui.restype = None
  257. self.lib.carla_get_buffer_size.argtypes = None
  258. self.lib.carla_get_buffer_size.restype = c_uint32
  259. self.lib.carla_get_sample_rate.argtypes = None
  260. self.lib.carla_get_sample_rate.restype = c_double
  261. self.lib.carla_get_last_error.argtypes = None
  262. self.lib.carla_get_last_error.restype = c_char_p
  263. self.lib.carla_get_host_osc_url.argtypes = None
  264. self.lib.carla_get_host_osc_url.restype = c_char_p
  265. #self.lib.nsm_announce.argtypes = [c_char_p, c_int]
  266. #self.lib.nsm_announce.restype = None
  267. #self.lib.nsm_reply_open.argtypes = None
  268. #self.lib.nsm_reply_open.restype = None
  269. #self.lib.nsm_reply_save.argtypes = None
  270. #self.lib.nsm_reply_save.restype = None
  271. def get_extended_license_text(self):
  272. return self.lib.carla_get_extended_license_text()
  273. def get_engine_driver_count(self):
  274. return self.lib.carla_get_engine_driver_count()
  275. def get_engine_driver_name(self, index):
  276. return self.lib.carla_get_engine_driver_name(index)
  277. def get_internal_plugin_count(self):
  278. return self.lib.carla_get_internal_plugin_count()
  279. def get_internal_plugin_info(self, internalPluginId):
  280. return structToDict(self.lib.carla_get_internal_plugin_info(internalPluginId).contents)
  281. def engine_init(self, driverName, clientName):
  282. return self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8"))
  283. def engine_close(self):
  284. return self.lib.carla_engine_close()
  285. def engine_idle(self):
  286. self.lib.carla_engine_idle()
  287. def is_engine_running(self):
  288. return self.lib.carla_is_engine_running()
  289. def set_engine_about_to_close(self):
  290. self.lib.carla_set_engine_about_to_close()
  291. def set_engine_callback(self, func):
  292. self._callback = CallbackFunc(func)
  293. self.lib.carla_set_engine_callback(self._callback, c_nullptr)
  294. def set_engine_option(self, option, value, valueStr):
  295. self.lib.carla_set_engine_option(option, value, valueStr.encode("utf-8"))
  296. def load_project(self, filename):
  297. return self.lib.carla_load_project(filename.encode("utf-8"))
  298. def save_project(self, filename):
  299. return self.lib.carla_save_project(filename.encode("utf-8"))
  300. def transport_play(self):
  301. self.lib.carla_transport_play()
  302. def transport_pause(self):
  303. self.lib.carla_transport_pause()
  304. def transport_relocate(self, frames):
  305. self.lib.carla_transport_relocate(frames)
  306. def add_plugin(self, btype, ptype, filename, name, label, extraStuff):
  307. cname = name.encode("utf-8") if name else c_nullptr
  308. return self.lib.carla_add_plugin(btype, ptype, filename.encode("utf-8"), cname, label.encode("utf-8"), cast(extraStuff, c_void_p))
  309. def remove_plugin(self, pluginId):
  310. return self.lib.carla_remove_plugin(pluginId)
  311. def remove_all_plugins(self):
  312. self.lib.carla_remove_all_plugins()
  313. def load_plugin_state(self, pluginId, filename):
  314. return self.lib.carla_load_plugin_state(pluginId, filename.encode("utf-8"))
  315. def save_plugin_state(self, pluginId, filename):
  316. return self.lib.carla_save_plugin_state(pluginId, filename.encode("utf-8"))
  317. def get_plugin_info(self, pluginId):
  318. return structToDict(self.lib.carla_get_plugin_info(pluginId).contents)
  319. def get_audio_port_count_info(self, pluginId):
  320. return structToDict(self.lib.carla_get_audio_port_count_info(pluginId).contents)
  321. def get_midi_port_count_info(self, pluginId):
  322. return structToDict(self.lib.carla_get_midi_port_count_info(pluginId).contents)
  323. def get_parameter_count_info(self, pluginId):
  324. return structToDict(self.lib.carla_get_parameter_count_info(pluginId).contents)
  325. def get_parameter_info(self, pluginId, parameterId):
  326. return structToDict(self.lib.carla_get_parameter_info(pluginId, parameterId).contents)
  327. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  328. return structToDict(self.lib.carla_get_parameter_scalepoint_info(pluginId, parameterId, scalePointId).contents)
  329. def get_parameter_data(self, pluginId, parameterId):
  330. return structToDict(self.lib.carla_get_parameter_data(pluginId, parameterId).contents)
  331. def get_parameter_ranges(self, pluginId, parameterId):
  332. return structToDict(self.lib.carla_get_parameter_ranges(pluginId, parameterId).contents)
  333. def get_midi_program_data(self, pluginId, midiProgramId):
  334. return structToDict(self.lib.carla_get_midi_program_data(pluginId, midiProgramId).contents)
  335. def get_custom_data(self, pluginId, customDataId):
  336. return structToDict(self.lib.carla_get_custom_data(pluginId, customDataId).contents)
  337. def get_chunk_data(self, pluginId):
  338. return self.lib.carla_get_chunk_data(pluginId)
  339. def get_parameter_count(self, pluginId):
  340. return self.lib.carla_get_parameter_count(pluginId)
  341. def get_program_count(self, pluginId):
  342. return self.lib.carla_get_program_count(pluginId)
  343. def get_midi_program_count(self, pluginId):
  344. return self.lib.carla_get_midi_program_count(pluginId)
  345. def get_custom_data_count(self, pluginId):
  346. return self.lib.carla_get_custom_data_count(pluginId)
  347. def get_parameter_text(self, pluginId, parameterId):
  348. return self.lib.carla_get_parameter_text(pluginId, parameterId)
  349. def get_program_name(self, pluginId, programId):
  350. return self.lib.carla_get_program_name(pluginId, programId)
  351. def get_midi_program_name(self, pluginId, midiProgramId):
  352. return self.lib.carla_get_midi_program_name(pluginId, midiProgramId)
  353. def get_real_plugin_name(self, pluginId):
  354. return self.lib.carla_get_real_plugin_name(pluginId)
  355. def get_current_program_index(self, pluginId):
  356. return self.lib.carla_get_current_program_index(pluginId)
  357. def get_current_midi_program_index(self, pluginId):
  358. return self.lib.carla_get_current_midi_program_index(pluginId)
  359. def get_default_parameter_value(self, pluginId, parameterId):
  360. return self.lib.carla_get_default_parameter_value(pluginId, parameterId)
  361. def get_current_parameter_value(self, pluginId, parameterId):
  362. return self.lib.carla_get_current_parameter_value(pluginId, parameterId)
  363. def get_input_peak_value(self, pluginId, portId):
  364. return self.lib.carla_get_input_peak_value(pluginId, portId)
  365. def get_output_peak_value(self, pluginId, portId):
  366. return self.lib.carla_get_output_peak_value(pluginId, portId)
  367. def set_option(self, pluginId, option, yesNo):
  368. self.lib.carla_set_option(pluginId, option, yesNo)
  369. def set_active(self, pluginId, onOff):
  370. self.lib.carla_set_active(pluginId, onOff)
  371. def set_drywet(self, pluginId, value):
  372. self.lib.carla_set_drywet(pluginId, value)
  373. def set_volume(self, pluginId, value):
  374. self.lib.carla_set_volume(pluginId, value)
  375. def set_balance_left(self, pluginId, value):
  376. self.lib.carla_set_balance_left(pluginId, value)
  377. def set_balance_right(self, pluginId, value):
  378. self.lib.carla_set_balance_right(pluginId, value)
  379. def set_panning(self, pluginId, value):
  380. self.lib.carla_set_panning(pluginId, value)
  381. def set_ctrl_channel(self, pluginId, channel):
  382. self.lib.carla_set_ctrl_channel(pluginId, channel)
  383. def set_parameter_value(self, pluginId, parameterId, value):
  384. self.lib.carla_set_parameter_value(pluginId, parameterId, value)
  385. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  386. self.lib.carla_set_parameter_midi_cc(pluginId, parameterId, cc)
  387. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  388. self.lib.carla_set_parameter_midi_channel(pluginId, parameterId, channel)
  389. def set_program(self, pluginId, programId):
  390. self.lib.carla_set_program(pluginId, programId)
  391. def set_midi_program(self, pluginId, midiProgramId):
  392. self.lib.carla_set_midi_program(pluginId, midiProgramId)
  393. def set_custom_data(self, pluginId, type_, key, value):
  394. self.lib.carla_set_custom_data(pluginId, type_.encode("utf-8"), key.encode("utf-8"), value.encode("utf-8"))
  395. def set_chunk_data(self, pluginId, chunkData):
  396. self.lib.carla_set_chunk_data(pluginId, chunkData.encode("utf-8"))
  397. def prepare_for_save(self, pluginId):
  398. self.lib.carla_prepare_for_save(pluginId)
  399. def send_midi_note(self, pluginId, channel, note, velocity):
  400. self.lib.carla_send_midi_note(pluginId, channel, note, velocity)
  401. def show_gui(self, pluginId, yesNo):
  402. self.lib.carla_show_gui(pluginId, yesNo)
  403. def get_last_error(self):
  404. return self.lib.carla_get_last_error()
  405. def get_host_osc_url(self):
  406. return self.lib.carla_get_host_osc_url()
  407. def get_buffer_size(self):
  408. return self.lib.carla_get_buffer_size()
  409. def get_sample_rate(self):
  410. return self.lib.carla_get_sample_rate()
  411. #def nsm_announce(self, url, pid):
  412. #self.lib.nsm_announce(url.encode("utf-8"), pid)
  413. #def nsm_reply_open(self):
  414. #self.lib.nsm_reply_open()
  415. #def nsm_reply_save(self):
  416. #self.lib.nsm_reply_save()
  417. #Carla.host = Host(None)
  418. ## Test available drivers
  419. #driverCount = Carla.host.get_engine_driver_count()
  420. #driverList = []
  421. #for i in range(driverCount):
  422. #driver = cString(Carla.host.get_engine_driver_name(i))
  423. #if driver:
  424. #driverList.append(driver)
  425. #print(i, driver)
  426. ## Test available internal plugins
  427. #pluginCount = Carla.host.get_internal_plugin_count()
  428. #for i in range(pluginCount):
  429. #plugin = Carla.host.get_internal_plugin_info(i)
  430. #print(plugin)