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

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