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 31KB

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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  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. from platform import architecture
  21. from sys import platform, maxsize
  22. # ------------------------------------------------------------------------------------------------------------
  23. # 64bit check
  24. kIs64bit = bool(architecture()[0] == "64bit" and maxsize > 2**32)
  25. # ------------------------------------------------------------------------------------------------------------
  26. # Set Platform
  27. if platform == "darwin":
  28. HAIKU = False
  29. LINUX = False
  30. MACOS = True
  31. WINDOWS = False
  32. elif "haiku" in platform:
  33. HAIKU = True
  34. LINUX = False
  35. MACOS = False
  36. WINDOWS = False
  37. elif "linux" in platform:
  38. HAIKU = False
  39. LINUX = True
  40. MACOS = False
  41. WINDOWS = False
  42. elif platform in ("win32", "win64", "cygwin"):
  43. HAIKU = False
  44. LINUX = False
  45. MACOS = False
  46. WINDOWS = True
  47. else:
  48. HAIKU = False
  49. LINUX = False
  50. MACOS = False
  51. WINDOWS = False
  52. # ------------------------------------------------------------------------------------------------------------
  53. # Convert a ctypes struct into a python dict
  54. def structToDict(struct):
  55. return dict((attr, getattr(struct, attr)) for attr, value in struct._fields_)
  56. # ------------------------------------------------------------------------------------------------
  57. # Backend defines
  58. MAX_DEFAULT_PLUGINS = 99
  59. MAX_RACK_PLUGINS = 16
  60. MAX_PATCHBAY_PLUGINS = 999
  61. MAX_DEFAULT_PARAMETERS = 200
  62. # Plugin Hints
  63. PLUGIN_IS_BRIDGE = 0x001
  64. PLUGIN_IS_RTSAFE = 0x002
  65. PLUGIN_IS_SYNTH = 0x004
  66. PLUGIN_HAS_GUI = 0x010
  67. PLUGIN_HAS_SINGLE_THREAD = 0x020
  68. PLUGIN_CAN_DRYWET = 0x100
  69. PLUGIN_CAN_VOLUME = 0x200
  70. PLUGIN_CAN_BALANCE = 0x400
  71. PLUGIN_CAN_PANNING = 0x800
  72. # Plugin Options
  73. PLUGIN_OPTION_FIXED_BUFFER = 0x001
  74. PLUGIN_OPTION_FORCE_STEREO = 0x002
  75. PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004
  76. PLUGIN_OPTION_USE_CHUNKS = 0x008
  77. PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010
  78. PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020
  79. PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040
  80. PLUGIN_OPTION_SEND_PITCHBEND = 0x080
  81. PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100
  82. # Parameter Hints
  83. PARAMETER_IS_BOOLEAN = 0x01
  84. PARAMETER_IS_INTEGER = 0x02
  85. PARAMETER_IS_LOGARITHMIC = 0x04
  86. PARAMETER_IS_ENABLED = 0x08
  87. PARAMETER_IS_AUTOMABLE = 0x10
  88. PARAMETER_USES_SAMPLERATE = 0x20
  89. PARAMETER_USES_SCALEPOINTS = 0x40
  90. PARAMETER_USES_CUSTOM_TEXT = 0x80
  91. # Patchbay Port Hints
  92. PATCHBAY_PORT_IS_INPUT = 0x1
  93. PATCHBAY_PORT_IS_OUTPUT = 0x2
  94. PATCHBAY_PORT_IS_AUDIO = 0x4
  95. PATCHBAY_PORT_IS_MIDI = 0x8
  96. # Custom Data types
  97. CUSTOM_DATA_INVALID = None
  98. CUSTOM_DATA_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"
  99. CUSTOM_DATA_STRING = "http://kxstudio.sf.net/ns/carla/string"
  100. # Binary Type
  101. BINARY_NONE = 0
  102. BINARY_POSIX32 = 1
  103. BINARY_POSIX64 = 2
  104. BINARY_WIN32 = 3
  105. BINARY_WIN64 = 4
  106. BINARY_OTHER = 5
  107. # Plugin Type
  108. PLUGIN_NONE = 0
  109. PLUGIN_INTERNAL = 1
  110. PLUGIN_LADSPA = 2
  111. PLUGIN_DSSI = 3
  112. PLUGIN_LV2 = 4
  113. PLUGIN_VST = 5
  114. PLUGIN_VST3 = 6
  115. PLUGIN_GIG = 7
  116. PLUGIN_SF2 = 8
  117. PLUGIN_SFZ = 9
  118. # Plugin Category
  119. PLUGIN_CATEGORY_NONE = 0
  120. PLUGIN_CATEGORY_SYNTH = 1
  121. PLUGIN_CATEGORY_DELAY = 2 # also Reverb
  122. PLUGIN_CATEGORY_EQ = 3
  123. PLUGIN_CATEGORY_FILTER = 4
  124. PLUGIN_CATEGORY_DYNAMICS = 5 # Amplifier, Compressor, Gate
  125. PLUGIN_CATEGORY_MODULATOR = 6 # Chorus, Flanger, Phaser
  126. PLUGIN_CATEGORY_UTILITY = 7 # Analyzer, Converter, Mixer
  127. PLUGIN_CATEGORY_OTHER = 8 # used to check if a plugin has a category
  128. # Parameter Type
  129. PARAMETER_UNKNOWN = 0
  130. PARAMETER_INPUT = 1
  131. PARAMETER_OUTPUT = 2
  132. PARAMETER_LATENCY = 3
  133. PARAMETER_SAMPLE_RATE = 4
  134. PARAMETER_LV2_FREEWHEEL = 5
  135. PARAMETER_LV2_TIME = 6
  136. # Internal Parameters Index
  137. PARAMETER_NULL = -1
  138. PARAMETER_ACTIVE = -2
  139. PARAMETER_DRYWET = -3
  140. PARAMETER_VOLUME = -4
  141. PARAMETER_BALANCE_LEFT = -5
  142. PARAMETER_BALANCE_RIGHT = -6
  143. PARAMETER_PANNING = -7
  144. PARAMETER_CTRL_CHANNEL = -8
  145. PARAMETER_MAX = -9
  146. # Options Type
  147. OPTION_PROCESS_NAME = 0
  148. OPTION_PROCESS_MODE = 1
  149. OPTION_TRANSPORT_MODE = 2
  150. OPTION_FORCE_STEREO = 3
  151. OPTION_PREFER_PLUGIN_BRIDGES = 4
  152. OPTION_PREFER_UI_BRIDGES = 5
  153. OPTION_USE_DSSI_VST_CHUNKS = 6
  154. OPTION_MAX_PARAMETERS = 7
  155. OPTION_OSC_UI_TIMEOUT = 8
  156. OPTION_PREFERRED_BUFFER_SIZE = 9
  157. OPTION_PREFERRED_SAMPLE_RATE = 10
  158. OPTION_PATH_BRIDGE_NATIVE = 11
  159. OPTION_PATH_BRIDGE_POSIX32 = 12
  160. OPTION_PATH_BRIDGE_POSIX64 = 13
  161. OPTION_PATH_BRIDGE_WIN32 = 14
  162. OPTION_PATH_BRIDGE_WIN64 = 15
  163. OPTION_PATH_BRIDGE_LV2_GTK2 = 16
  164. OPTION_PATH_BRIDGE_LV2_GTK3 = 17
  165. OPTION_PATH_BRIDGE_LV2_QT4 = 18
  166. OPTION_PATH_BRIDGE_LV2_QT5 = 19
  167. OPTION_PATH_BRIDGE_LV2_COCOA = 20
  168. OPTION_PATH_BRIDGE_LV2_WINDOWS = 21
  169. OPTION_PATH_BRIDGE_LV2_X11 = 22
  170. OPTION_PATH_BRIDGE_VST_COCOA = 23
  171. OPTION_PATH_BRIDGE_VST_HWND = 24
  172. OPTION_PATH_BRIDGE_VST_X11 = 25
  173. # Callback Type
  174. CALLBACK_DEBUG = 0
  175. CALLBACK_PLUGIN_ADDED = 1
  176. CALLBACK_PLUGIN_REMOVED = 2
  177. CALLBACK_PLUGIN_RENAMED = 3
  178. CALLBACK_PARAMETER_VALUE_CHANGED = 4
  179. CALLBACK_PARAMETER_DEFAULT_CHANGED = 5
  180. CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 6
  181. CALLBACK_PARAMETER_MIDI_CC_CHANGED = 7
  182. CALLBACK_PROGRAM_CHANGED = 8
  183. CALLBACK_MIDI_PROGRAM_CHANGED = 9
  184. CALLBACK_NOTE_ON = 10
  185. CALLBACK_NOTE_OFF = 11
  186. CALLBACK_SHOW_GUI = 12
  187. CALLBACK_UPDATE = 13
  188. CALLBACK_RELOAD_INFO = 14
  189. CALLBACK_RELOAD_PARAMETERS = 15
  190. CALLBACK_RELOAD_PROGRAMS = 16
  191. CALLBACK_RELOAD_ALL = 17
  192. CALLBACK_PATCHBAY_CLIENT_ADDED = 18
  193. CALLBACK_PATCHBAY_CLIENT_REMOVED = 19
  194. CALLBACK_PATCHBAY_CLIENT_RENAMED = 20
  195. CALLBACK_PATCHBAY_PORT_ADDED = 21
  196. CALLBACK_PATCHBAY_PORT_REMOVED = 22
  197. CALLBACK_PATCHBAY_PORT_RENAMED = 23
  198. CALLBACK_PATCHBAY_CONNECTION_ADDED = 24
  199. CALLBACK_PATCHBAY_CONNECTION_REMOVED = 25
  200. CALLBACK_BUFFER_SIZE_CHANGED = 26
  201. CALLBACK_SAMPLE_RATE_CHANGED = 27
  202. CALLBACK_NSM_ANNOUNCE = 28
  203. CALLBACK_NSM_OPEN = 29
  204. CALLBACK_NSM_SAVE = 30
  205. CALLBACK_ERROR = 31
  206. CALLBACK_QUIT = 32
  207. # Process Mode
  208. PROCESS_MODE_SINGLE_CLIENT = 0
  209. PROCESS_MODE_MULTIPLE_CLIENTS = 1
  210. PROCESS_MODE_CONTINUOUS_RACK = 2
  211. PROCESS_MODE_PATCHBAY = 3
  212. PROCESS_MODE_BRIDGE = 4
  213. # Transport Mode
  214. TRANSPORT_MODE_INTERNAL = 0
  215. TRANSPORT_MODE_JACK = 1
  216. TRANSPORT_MODE_BRIDGE = 2
  217. # Set BINARY_NATIVE
  218. if HAIKU or LINUX or MACOS:
  219. BINARY_NATIVE = BINARY_POSIX64 if kIs64bit else BINARY_POSIX32
  220. elif WINDOWS:
  221. BINARY_NATIVE = BINARY_WIN64 if kIs64bit else BINARY_WIN32
  222. else:
  223. BINARY_NATIVE = BINARY_OTHER
  224. # ------------------------------------------------------------------------------------------------------------
  225. # Backend C++ -> Python variables
  226. c_enum = c_int
  227. c_nullptr = None
  228. CallbackFunc = CFUNCTYPE(None, c_void_p, c_enum, c_uint, c_int, c_int, c_float, c_char_p)
  229. class ParameterData(Structure):
  230. _fields_ = [
  231. ("type", c_enum),
  232. ("index", c_int32),
  233. ("rindex", c_int32),
  234. ("hints", c_uint32),
  235. ("midiChannel", c_uint8),
  236. ("midiCC", c_int16)
  237. ]
  238. class ParameterRanges(Structure):
  239. _fields_ = [
  240. ("def", c_float),
  241. ("min", c_float),
  242. ("max", c_float),
  243. ("step", c_float),
  244. ("stepSmall", c_float),
  245. ("stepLarge", c_float)
  246. ]
  247. class MidiProgramData(Structure):
  248. _fields_ = [
  249. ("bank", c_uint32),
  250. ("program", c_uint32),
  251. ("name", c_char_p)
  252. ]
  253. class CustomData(Structure):
  254. _fields_ = [
  255. ("type", c_char_p),
  256. ("key", c_char_p),
  257. ("value", c_char_p)
  258. ]
  259. # ------------------------------------------------------------------------------------------------------------
  260. # Standalone C++ -> Python variables
  261. class CarlaPluginInfo(Structure):
  262. _fields_ = [
  263. ("type", c_enum),
  264. ("category", c_enum),
  265. ("hints", c_uint),
  266. ("optionsAvailable", c_uint),
  267. ("optionsEnabled", c_uint),
  268. ("binary", c_char_p),
  269. ("name", c_char_p),
  270. ("label", c_char_p),
  271. ("maker", c_char_p),
  272. ("copyright", c_char_p),
  273. ("uniqueId", c_long),
  274. ("latency", c_uint32)
  275. ]
  276. class CarlaNativePluginInfo(Structure):
  277. _fields_ = [
  278. ("category", c_enum),
  279. ("hints", c_uint),
  280. ("audioIns", c_uint32),
  281. ("audioOuts", c_uint32),
  282. ("midiIns", c_uint32),
  283. ("midiOuts", c_uint32),
  284. ("parameterIns", c_uint32),
  285. ("parameterOuts", c_uint32),
  286. ("name", c_char_p),
  287. ("label", c_char_p),
  288. ("maker", c_char_p),
  289. ("copyright", c_char_p)
  290. ]
  291. class CarlaPortCountInfo(Structure):
  292. _fields_ = [
  293. ("ins", c_uint32),
  294. ("outs", c_uint32),
  295. ("total", c_uint32)
  296. ]
  297. class CarlaParameterInfo(Structure):
  298. _fields_ = [
  299. ("name", c_char_p),
  300. ("symbol", c_char_p),
  301. ("unit", c_char_p),
  302. ("scalePointCount", c_uint32)
  303. ]
  304. class CarlaScalePointInfo(Structure):
  305. _fields_ = [
  306. ("value", c_float),
  307. ("label", c_char_p)
  308. ]
  309. class CarlaTransportInfo(Structure):
  310. _fields_ = [
  311. ("playing", c_bool),
  312. ("frame", c_uint32),
  313. ("bar", c_int32),
  314. ("beat", c_int32),
  315. ("tick", c_int32),
  316. ("bpm", c_double)
  317. ]
  318. # ------------------------------------------------------------------------------------------------------------
  319. # Standalone Python object
  320. class Host(object):
  321. def __init__(self, libName):
  322. object.__init__(self)
  323. self.lib = cdll.LoadLibrary(libName)
  324. self.lib.carla_get_extended_license_text.argtypes = None
  325. self.lib.carla_get_extended_license_text.restype = c_char_p
  326. self.lib.carla_get_supported_file_types.argtypes = None
  327. self.lib.carla_get_supported_file_types.restype = c_char_p
  328. self.lib.carla_get_engine_driver_count.argtypes = None
  329. self.lib.carla_get_engine_driver_count.restype = c_uint
  330. self.lib.carla_get_engine_driver_name.argtypes = [c_uint]
  331. self.lib.carla_get_engine_driver_name.restype = c_char_p
  332. self.lib.carla_get_engine_driver_options.argtypes = [c_uint]
  333. self.lib.carla_get_engine_driver_options.restype = c_void_p # TODO
  334. self.lib.carla_get_internal_plugin_count.argtypes = None
  335. self.lib.carla_get_internal_plugin_count.restype = c_uint
  336. self.lib.carla_get_internal_plugin_info.argtypes = [c_uint]
  337. self.lib.carla_get_internal_plugin_info.restype = POINTER(CarlaNativePluginInfo)
  338. self.lib.carla_engine_init.argtypes = [c_char_p, c_char_p]
  339. self.lib.carla_engine_init.restype = c_bool
  340. self.lib.carla_engine_close.argtypes = None
  341. self.lib.carla_engine_close.restype = c_bool
  342. self.lib.carla_engine_idle.argtypes = None
  343. self.lib.carla_engine_idle.restype = None
  344. self.lib.carla_is_engine_running.argtypes = None
  345. self.lib.carla_is_engine_running.restype = c_bool
  346. self.lib.carla_set_engine_about_to_close.argtypes = None
  347. self.lib.carla_set_engine_about_to_close.restype = None
  348. self.lib.carla_set_engine_callback.argtypes = [CallbackFunc, c_void_p]
  349. self.lib.carla_set_engine_callback.restype = None
  350. self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p]
  351. self.lib.carla_set_engine_option.restype = None
  352. self.lib.carla_load_filename.argtypes = [c_char_p]
  353. self.lib.carla_load_filename.restype = c_bool
  354. self.lib.carla_load_project.argtypes = [c_char_p]
  355. self.lib.carla_load_project.restype = c_bool
  356. self.lib.carla_save_project.argtypes = [c_char_p]
  357. self.lib.carla_save_project.restype = c_bool
  358. self.lib.carla_patchbay_connect.argtypes = [c_int, c_int]
  359. self.lib.carla_patchbay_connect.restype = c_bool
  360. self.lib.carla_patchbay_disconnect.argtypes = [c_int]
  361. self.lib.carla_patchbay_disconnect.restype = c_bool
  362. self.lib.carla_patchbay_refresh.argtypes = None
  363. self.lib.carla_patchbay_refresh.restype = None
  364. self.lib.carla_transport_play.argtypes = None
  365. self.lib.carla_transport_play.restype = None
  366. self.lib.carla_transport_pause.argtypes = None
  367. self.lib.carla_transport_pause.restype = None
  368. self.lib.carla_transport_relocate.argtypes = [c_uint32]
  369. self.lib.carla_transport_relocate.restype = None
  370. self.lib.carla_get_current_transport_frame.argtypes = None
  371. self.lib.carla_get_current_transport_frame.restype = c_uint32
  372. self.lib.carla_get_transport_info.argtypes = None
  373. self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo)
  374. self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_void_p]
  375. self.lib.carla_add_plugin.restype = c_bool
  376. self.lib.carla_remove_plugin.argtypes = [c_uint]
  377. self.lib.carla_remove_plugin.restype = c_bool
  378. self.lib.carla_remove_all_plugins.argtypes = None
  379. self.lib.carla_remove_all_plugins.restype = None
  380. self.lib.carla_rename_plugin.argtypes = [c_uint, c_char_p]
  381. self.lib.carla_rename_plugin.restype = c_char_p
  382. self.lib.carla_clone_plugin.argtypes = [c_uint]
  383. self.lib.carla_clone_plugin.restype = c_bool
  384. self.lib.carla_replace_plugin.argtypes = [c_uint]
  385. self.lib.carla_replace_plugin.restype = c_bool
  386. self.lib.carla_switch_plugins.argtypes = [c_uint, c_uint]
  387. self.lib.carla_switch_plugins.restype = c_bool
  388. self.lib.carla_load_plugin_state.argtypes = [c_uint, c_char_p]
  389. self.lib.carla_load_plugin_state.restype = c_bool
  390. self.lib.carla_save_plugin_state.argtypes = [c_uint, c_char_p]
  391. self.lib.carla_save_plugin_state.restype = c_bool
  392. self.lib.carla_get_plugin_info.argtypes = [c_uint]
  393. self.lib.carla_get_plugin_info.restype = POINTER(CarlaPluginInfo)
  394. self.lib.carla_get_audio_port_count_info.argtypes = [c_uint]
  395. self.lib.carla_get_audio_port_count_info.restype = POINTER(CarlaPortCountInfo)
  396. self.lib.carla_get_midi_port_count_info.argtypes = [c_uint]
  397. self.lib.carla_get_midi_port_count_info.restype = POINTER(CarlaPortCountInfo)
  398. self.lib.carla_get_parameter_count_info.argtypes = [c_uint]
  399. self.lib.carla_get_parameter_count_info.restype = POINTER(CarlaPortCountInfo)
  400. self.lib.carla_get_parameter_info.argtypes = [c_uint, c_uint32]
  401. self.lib.carla_get_parameter_info.restype = POINTER(CarlaParameterInfo)
  402. self.lib.carla_get_parameter_scalepoint_info.argtypes = [c_uint, c_uint32, c_uint32]
  403. self.lib.carla_get_parameter_scalepoint_info.restype = POINTER(CarlaScalePointInfo)
  404. self.lib.carla_get_parameter_data.argtypes = [c_uint, c_uint32]
  405. self.lib.carla_get_parameter_data.restype = POINTER(ParameterData)
  406. self.lib.carla_get_parameter_ranges.argtypes = [c_uint, c_uint32]
  407. self.lib.carla_get_parameter_ranges.restype = POINTER(ParameterRanges)
  408. self.lib.carla_get_midi_program_data.argtypes = [c_uint, c_uint32]
  409. self.lib.carla_get_midi_program_data.restype = POINTER(MidiProgramData)
  410. self.lib.carla_get_custom_data.argtypes = [c_uint, c_uint32]
  411. self.lib.carla_get_custom_data.restype = POINTER(CustomData)
  412. self.lib.carla_get_chunk_data.argtypes = [c_uint]
  413. self.lib.carla_get_chunk_data.restype = c_char_p
  414. self.lib.carla_get_parameter_count.argtypes = [c_uint]
  415. self.lib.carla_get_parameter_count.restype = c_uint32
  416. self.lib.carla_get_program_count.argtypes = [c_uint]
  417. self.lib.carla_get_program_count.restype = c_uint32
  418. self.lib.carla_get_midi_program_count.argtypes = [c_uint]
  419. self.lib.carla_get_midi_program_count.restype = c_uint32
  420. self.lib.carla_get_custom_data_count.argtypes = [c_uint]
  421. self.lib.carla_get_custom_data_count.restype = c_uint32
  422. self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32]
  423. self.lib.carla_get_parameter_text.restype = c_char_p
  424. self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32]
  425. self.lib.carla_get_program_name.restype = c_char_p
  426. self.lib.carla_get_midi_program_name.argtypes = [c_uint, c_uint32]
  427. self.lib.carla_get_midi_program_name.restype = c_char_p
  428. self.lib.carla_get_real_plugin_name.argtypes = [c_uint]
  429. self.lib.carla_get_real_plugin_name.restype = c_char_p
  430. self.lib.carla_get_current_program_index.argtypes = [c_uint]
  431. self.lib.carla_get_current_program_index.restype = c_int32
  432. self.lib.carla_get_current_midi_program_index.argtypes = [c_uint]
  433. self.lib.carla_get_current_midi_program_index.restype = c_int32
  434. # TODO - consider removal
  435. self.lib.carla_get_default_parameter_value.argtypes = [c_uint, c_uint32]
  436. self.lib.carla_get_default_parameter_value.restype = c_float
  437. # TODO - consider removal
  438. self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32]
  439. self.lib.carla_get_current_parameter_value.restype = c_float
  440. self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_ushort]
  441. self.lib.carla_get_input_peak_value.restype = c_float
  442. self.lib.carla_get_output_peak_value.argtypes = [c_uint, c_ushort]
  443. self.lib.carla_get_output_peak_value.restype = c_float
  444. self.lib.carla_set_option.argtypes = [c_uint, c_uint, c_bool]
  445. self.lib.carla_set_option.restype = None
  446. self.lib.carla_set_active.argtypes = [c_uint, c_bool]
  447. self.lib.carla_set_active.restype = None
  448. self.lib.carla_set_drywet.argtypes = [c_uint, c_float]
  449. self.lib.carla_set_drywet.restype = None
  450. self.lib.carla_set_volume.argtypes = [c_uint, c_float]
  451. self.lib.carla_set_volume.restype = None
  452. self.lib.carla_set_balance_left.argtypes = [c_uint, c_float]
  453. self.lib.carla_set_balance_left.restype = None
  454. self.lib.carla_set_balance_right.argtypes = [c_uint, c_float]
  455. self.lib.carla_set_balance_right.restype = None
  456. self.lib.carla_set_panning.argtypes = [c_uint, c_float]
  457. self.lib.carla_set_panning.restype = None
  458. self.lib.carla_set_ctrl_channel.argtypes = [c_uint, c_int8]
  459. self.lib.carla_set_ctrl_channel.restype = None
  460. self.lib.carla_set_parameter_value.argtypes = [c_uint, c_uint32, c_float]
  461. self.lib.carla_set_parameter_value.restype = None
  462. self.lib.carla_set_parameter_midi_cc.argtypes = [c_uint, c_uint32, c_int16]
  463. self.lib.carla_set_parameter_midi_cc.restype = None
  464. self.lib.carla_set_parameter_midi_channel.argtypes = [c_uint, c_uint32, c_uint8]
  465. self.lib.carla_set_parameter_midi_channel.restype = None
  466. self.lib.carla_set_program.argtypes = [c_uint, c_uint32]
  467. self.lib.carla_set_program.restype = None
  468. self.lib.carla_set_midi_program.argtypes = [c_uint, c_uint32]
  469. self.lib.carla_set_midi_program.restype = None
  470. self.lib.carla_set_custom_data.argtypes = [c_uint, c_char_p, c_char_p, c_char_p]
  471. self.lib.carla_set_custom_data.restype = None
  472. self.lib.carla_set_chunk_data.argtypes = [c_uint, c_char_p]
  473. self.lib.carla_set_chunk_data.restype = None
  474. self.lib.carla_prepare_for_save.argtypes = [c_uint]
  475. self.lib.carla_prepare_for_save.restype = None
  476. self.lib.carla_send_midi_note.argtypes = [c_uint, c_uint8, c_uint8, c_uint8]
  477. self.lib.carla_send_midi_note.restype = None
  478. self.lib.carla_show_gui.argtypes = [c_uint, c_bool]
  479. self.lib.carla_show_gui.restype = None
  480. self.lib.carla_get_buffer_size.argtypes = None
  481. self.lib.carla_get_buffer_size.restype = c_uint32
  482. self.lib.carla_get_sample_rate.argtypes = None
  483. self.lib.carla_get_sample_rate.restype = c_double
  484. self.lib.carla_get_last_error.argtypes = None
  485. self.lib.carla_get_last_error.restype = c_char_p
  486. self.lib.carla_get_host_osc_url.argtypes = None
  487. self.lib.carla_get_host_osc_url.restype = c_char_p
  488. self.lib.carla_nsm_announce.argtypes = [c_char_p, c_char_p, c_int]
  489. self.lib.carla_nsm_announce.restype = None
  490. self.lib.carla_nsm_reply_open.argtypes = None
  491. self.lib.carla_nsm_reply_open.restype = None
  492. self.lib.carla_nsm_reply_save.argtypes = None
  493. self.lib.carla_nsm_reply_save.restype = None
  494. def get_extended_license_text(self):
  495. return self.lib.carla_get_extended_license_text()
  496. def get_supported_file_types(self):
  497. return self.lib.carla_get_supported_file_types()
  498. def get_engine_driver_count(self):
  499. return self.lib.carla_get_engine_driver_count()
  500. def get_engine_driver_name(self, index):
  501. return self.lib.carla_get_engine_driver_name(index)
  502. def get_engine_driver_options(self, index):
  503. return self.lib.carla_get_engine_driver_options(index)
  504. def get_internal_plugin_count(self):
  505. return self.lib.carla_get_internal_plugin_count()
  506. def get_internal_plugin_info(self, internalPluginId):
  507. return structToDict(self.lib.carla_get_internal_plugin_info(internalPluginId).contents)
  508. def engine_init(self, driverName, clientName):
  509. return self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8"))
  510. def engine_close(self):
  511. return self.lib.carla_engine_close()
  512. def engine_idle(self):
  513. self.lib.carla_engine_idle()
  514. def is_engine_running(self):
  515. return self.lib.carla_is_engine_running()
  516. def set_engine_about_to_close(self):
  517. self.lib.carla_set_engine_about_to_close()
  518. def set_engine_callback(self, func):
  519. self._callback = CallbackFunc(func)
  520. self.lib.carla_set_engine_callback(self._callback, c_nullptr)
  521. def set_engine_option(self, option, value, valueStr):
  522. self.lib.carla_set_engine_option(option, value, valueStr.encode("utf-8"))
  523. def load_filename(self, filename):
  524. return self.lib.carla_load_filename(filename.encode("utf-8"))
  525. def load_project(self, filename):
  526. return self.lib.carla_load_project(filename.encode("utf-8"))
  527. def save_project(self, filename):
  528. return self.lib.carla_save_project(filename.encode("utf-8"))
  529. def patchbay_connect(self, portIdA, portIdB):
  530. return self.lib.carla_patchbay_connect(portIdA, portIdB)
  531. def patchbay_disconnect(self, connectionId):
  532. return self.lib.carla_patchbay_disconnect(connectionId)
  533. def patchbay_refresh(self):
  534. self.lib.carla_patchbay_refresh()
  535. def transport_play(self):
  536. self.lib.carla_transport_play()
  537. def transport_pause(self):
  538. self.lib.carla_transport_pause()
  539. def transport_relocate(self, frames):
  540. self.lib.carla_transport_relocate(frames)
  541. def get_current_transport_frame(self):
  542. return self.lib.carla_get_current_transport_frame()
  543. def get_transport_info(self):
  544. return structToDict(self.lib.carla_get_transport_info().contents)
  545. def add_plugin(self, btype, ptype, filename, name, label, extraStuff):
  546. cfilename = filename.encode("utf-8") if filename else c_nullptr
  547. cname = name.encode("utf-8") if name else c_nullptr
  548. clabel = label.encode("utf-8") if label else c_nullptr
  549. return self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, cast(extraStuff, c_void_p))
  550. def remove_plugin(self, pluginId):
  551. return self.lib.carla_remove_plugin(pluginId)
  552. def remove_all_plugins(self):
  553. self.lib.carla_remove_all_plugins()
  554. def rename_plugin(self, pluginId, newName):
  555. return self.lib.carla_rename_plugin(pluginId, newName.encode("utf-8"))
  556. def clone_plugin(self, pluginId):
  557. return self.lib.carla_clone_plugin(pluginId)
  558. def replace_plugin(self, pluginId):
  559. return self.lib.carla_replace_plugin(pluginId)
  560. def switch_plugins(self, pluginIdA, pluginIdB):
  561. return self.lib.carla_switch_plugins(pluginIdA, pluginIdB)
  562. def load_plugin_state(self, pluginId, filename):
  563. return self.lib.carla_load_plugin_state(pluginId, filename.encode("utf-8"))
  564. def save_plugin_state(self, pluginId, filename):
  565. return self.lib.carla_save_plugin_state(pluginId, filename.encode("utf-8"))
  566. def get_plugin_info(self, pluginId):
  567. return structToDict(self.lib.carla_get_plugin_info(pluginId).contents)
  568. def get_audio_port_count_info(self, pluginId):
  569. return structToDict(self.lib.carla_get_audio_port_count_info(pluginId).contents)
  570. def get_midi_port_count_info(self, pluginId):
  571. return structToDict(self.lib.carla_get_midi_port_count_info(pluginId).contents)
  572. def get_parameter_count_info(self, pluginId):
  573. return structToDict(self.lib.carla_get_parameter_count_info(pluginId).contents)
  574. def get_parameter_info(self, pluginId, parameterId):
  575. return structToDict(self.lib.carla_get_parameter_info(pluginId, parameterId).contents)
  576. def get_parameter_scalepoint_info(self, pluginId, parameterId, scalePointId):
  577. return structToDict(self.lib.carla_get_parameter_scalepoint_info(pluginId, parameterId, scalePointId).contents)
  578. def get_parameter_data(self, pluginId, parameterId):
  579. return structToDict(self.lib.carla_get_parameter_data(pluginId, parameterId).contents)
  580. def get_parameter_ranges(self, pluginId, parameterId):
  581. return structToDict(self.lib.carla_get_parameter_ranges(pluginId, parameterId).contents)
  582. def get_midi_program_data(self, pluginId, midiProgramId):
  583. return structToDict(self.lib.carla_get_midi_program_data(pluginId, midiProgramId).contents)
  584. def get_custom_data(self, pluginId, customDataId):
  585. return structToDict(self.lib.carla_get_custom_data(pluginId, customDataId).contents)
  586. def get_chunk_data(self, pluginId):
  587. return self.lib.carla_get_chunk_data(pluginId)
  588. def get_parameter_count(self, pluginId):
  589. return self.lib.carla_get_parameter_count(pluginId)
  590. def get_program_count(self, pluginId):
  591. return self.lib.carla_get_program_count(pluginId)
  592. def get_midi_program_count(self, pluginId):
  593. return self.lib.carla_get_midi_program_count(pluginId)
  594. def get_custom_data_count(self, pluginId):
  595. return self.lib.carla_get_custom_data_count(pluginId)
  596. def get_parameter_text(self, pluginId, parameterId):
  597. return self.lib.carla_get_parameter_text(pluginId, parameterId)
  598. def get_program_name(self, pluginId, programId):
  599. return self.lib.carla_get_program_name(pluginId, programId)
  600. def get_midi_program_name(self, pluginId, midiProgramId):
  601. return self.lib.carla_get_midi_program_name(pluginId, midiProgramId)
  602. def get_real_plugin_name(self, pluginId):
  603. return self.lib.carla_get_real_plugin_name(pluginId)
  604. def get_current_program_index(self, pluginId):
  605. return self.lib.carla_get_current_program_index(pluginId)
  606. def get_current_midi_program_index(self, pluginId):
  607. return self.lib.carla_get_current_midi_program_index(pluginId)
  608. def get_default_parameter_value(self, pluginId, parameterId):
  609. return self.lib.carla_get_default_parameter_value(pluginId, parameterId)
  610. def get_current_parameter_value(self, pluginId, parameterId):
  611. return self.lib.carla_get_current_parameter_value(pluginId, parameterId)
  612. def get_input_peak_value(self, pluginId, portId):
  613. return self.lib.carla_get_input_peak_value(pluginId, portId)
  614. def get_output_peak_value(self, pluginId, portId):
  615. return self.lib.carla_get_output_peak_value(pluginId, portId)
  616. def set_option(self, pluginId, option, yesNo):
  617. self.lib.carla_set_option(pluginId, option, yesNo)
  618. def set_active(self, pluginId, onOff):
  619. self.lib.carla_set_active(pluginId, onOff)
  620. def set_drywet(self, pluginId, value):
  621. self.lib.carla_set_drywet(pluginId, value)
  622. def set_volume(self, pluginId, value):
  623. self.lib.carla_set_volume(pluginId, value)
  624. def set_balance_left(self, pluginId, value):
  625. self.lib.carla_set_balance_left(pluginId, value)
  626. def set_balance_right(self, pluginId, value):
  627. self.lib.carla_set_balance_right(pluginId, value)
  628. def set_panning(self, pluginId, value):
  629. self.lib.carla_set_panning(pluginId, value)
  630. def set_ctrl_channel(self, pluginId, channel):
  631. self.lib.carla_set_ctrl_channel(pluginId, channel)
  632. def set_parameter_value(self, pluginId, parameterId, value):
  633. self.lib.carla_set_parameter_value(pluginId, parameterId, value)
  634. def set_parameter_midi_cc(self, pluginId, parameterId, cc):
  635. self.lib.carla_set_parameter_midi_cc(pluginId, parameterId, cc)
  636. def set_parameter_midi_channel(self, pluginId, parameterId, channel):
  637. self.lib.carla_set_parameter_midi_channel(pluginId, parameterId, channel)
  638. def set_program(self, pluginId, programId):
  639. self.lib.carla_set_program(pluginId, programId)
  640. def set_midi_program(self, pluginId, midiProgramId):
  641. self.lib.carla_set_midi_program(pluginId, midiProgramId)
  642. def set_custom_data(self, pluginId, type_, key, value):
  643. self.lib.carla_set_custom_data(pluginId, type_.encode("utf-8"), key.encode("utf-8"), value.encode("utf-8"))
  644. def set_chunk_data(self, pluginId, chunkData):
  645. self.lib.carla_set_chunk_data(pluginId, chunkData.encode("utf-8"))
  646. def prepare_for_save(self, pluginId):
  647. self.lib.carla_prepare_for_save(pluginId)
  648. def send_midi_note(self, pluginId, channel, note, velocity):
  649. self.lib.carla_send_midi_note(pluginId, channel, note, velocity)
  650. def show_gui(self, pluginId, yesNo):
  651. self.lib.carla_show_gui(pluginId, yesNo)
  652. def get_last_error(self):
  653. return self.lib.carla_get_last_error()
  654. def get_host_osc_url(self):
  655. return self.lib.carla_get_host_osc_url()
  656. def get_buffer_size(self):
  657. return self.lib.carla_get_buffer_size()
  658. def get_sample_rate(self):
  659. return self.lib.carla_get_sample_rate()
  660. def nsm_announce(self, url, appName, pid):
  661. self.lib.carla_nsm_announce(url.encode("utf-8"), appName.encode("utf-8"), pid)
  662. def nsm_reply_open(self):
  663. self.lib.carla_nsm_reply_open()
  664. def nsm_reply_save(self):
  665. self.lib.carla_nsm_reply_save()