2 # SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # ------------------------------------------------------------------------------------------------------------
8 # ------------------------------------------------------------------------------------------------------------
12 c_bool
, c_char
, c_char_p
, c_int
, c_uint
, c_uint64
, c_void_p
, cast
,
18 from sip
import unwrapinstance
20 def unwrapinstance(_
):
23 # ------------------------------------------------------------------------------------------------------------
26 from carla_backend
import (
30 # ---------------------------------------------------------------------------------------------------------------------
31 # Convert a ctypes struct into a python dict, or None if null
33 def structToDictOrNull(struct
):
34 return structToDict(struct
.contents
) if struct
else None
36 # ------------------------------------------------------------------------------------------------------------
37 # Carla Frontend API (C stuff)
39 class JackApplicationDialogResults(Structure
):
41 ("command", c_char_p
),
43 ("labelSetup", c_char_p
)
46 class HostSettings(Structure
):
48 ("showPluginBridges", c_bool
),
49 ("showWineBridges", c_bool
),
50 ("useSystemIcons", c_bool
),
51 ("wineAutoPrefix", c_bool
),
52 ("wineExecutable", c_char_p
),
53 ("wineFallbackPrefix", c_char_p
),
56 class PluginListDialogResults(Structure
):
61 ("category", c_char_p
),
62 ("filename", c_char_p
),
66 ("uniqueId", c_uint64
),
68 ("audioOuts", c_uint
),
73 ("parametersIns", c_uint
),
74 ("parametersOuts", c_uint
),
77 # ------------------------------------------------------------------------------------------------------------
78 # Carla Frontend object using a DLL
80 class CarlaFrontendLib():
81 def __init__(self
, filename
):
82 self
.lib
= cdll
.LoadLibrary(filename
)
84 self
.lib
.carla_frontend_createAndExecJackAppDialog
.argtypes
= (c_void_p
, c_char_p
)
85 self
.lib
.carla_frontend_createAndExecJackAppDialog
.restype
= POINTER(JackApplicationDialogResults
)
87 self
.lib
.carla_frontend_createPluginListDialog
.argtypes
= (c_void_p
, POINTER(HostSettings
))
88 self
.lib
.carla_frontend_createPluginListDialog
.restype
= c_void_p
90 self
.lib
.carla_frontend_destroyPluginListDialog
.argtypes
= (c_void_p
,)
91 self
.lib
.carla_frontend_destroyPluginListDialog
.restype
= None
93 self
.lib
.carla_frontend_setPluginListDialogPath
.argtypes
= (c_void_p
, c_int
, c_char_p
)
94 self
.lib
.carla_frontend_setPluginListDialogPath
.restype
= None
96 self
.lib
.carla_frontend_execPluginListDialog
.argtypes
= (c_void_p
,)
97 self
.lib
.carla_frontend_execPluginListDialog
.restype
= POINTER(PluginListDialogResults
)
99 # --------------------------------------------------------------------------------------------------------
101 def createAndExecJackAppDialog(self
, parent
, projectFilename
):
102 return structToDictOrNull(self
.lib
.carla_frontend_createAndExecJackAppDialog(unwrapinstance(parent
),
103 projectFilename
.encode("utf-8")))
105 def createPluginListDialog(self
, parent
, hostSettings
):
106 hostSettingsC
= HostSettings()
107 hostSettingsC
.showPluginBridges
= hostSettings
['showPluginBridges']
108 hostSettingsC
.showWineBridges
= hostSettings
['showWineBridges']
109 hostSettingsC
.useSystemIcons
= hostSettings
['useSystemIcons']
110 hostSettingsC
.wineAutoPrefix
= hostSettings
['wineAutoPrefix']
111 hostSettingsC
.wineExecutable
= hostSettings
['wineExecutable'].encode("utf-8")
112 hostSettingsC
.wineFallbackPrefix
= hostSettings
['wineFallbackPrefix'].encode("utf-8")
113 return self
.lib
.carla_frontend_createPluginListDialog(unwrapinstance(parent
), hostSettingsC
)
115 def destroyPluginListDialog(self
, dialog
):
116 self
.lib
.carla_frontend_destroyPluginListDialog(dialog
)
118 def setPluginListDialogPath(self
, dialog
, ptype
, path
):
119 self
.lib
.carla_frontend_setPluginListDialogPath(dialog
, ptype
, path
.encode("utf-8"))
121 def execPluginListDialog(self
, dialog
):
122 return structToDictOrNull(self
.lib
.carla_frontend_execPluginListDialog(dialog
))
124 # ------------------------------------------------------------------------------------------------------------