From 69e07df2f766eff91a21c9fc3657019cd393ff3b Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 6 Jul 2025 22:25:24 +0200 Subject: [PATCH] Keep base macros consistent between C++ and Python code Signed-off-by: falkTX --- source/frontend/C++/carla_app.cpp | 4 +- source/frontend/carla-plugin | 4 +- source/frontend/carla_app.py | 40 ++++++---- source/frontend/carla_backend.py | 45 ++++++----- source/frontend/carla_host.py | 24 +++--- source/frontend/carla_settings.py | 22 +++--- source/frontend/carla_shared.py | 65 ++++++++------- source/frontend/carla_utils.py | 26 ++---- source/frontend/carla_widgets.py | 20 ++--- source/frontend/common/__init__.py | 79 ++++++++----------- .../frontend/pluginlist/pluginlistdialog.cpp | 4 +- .../frontend/widgets/draggablegraphicsview.py | 7 +- source/frontend/widgets/paramspinbox.py | 7 +- source/frontend/widgets/racklistwidget.py | 6 +- 14 files changed, 179 insertions(+), 174 deletions(-) diff --git a/source/frontend/C++/carla_app.cpp b/source/frontend/C++/carla_app.cpp index 15260332f..332aef341 100644 --- a/source/frontend/C++/carla_app.cpp +++ b/source/frontend/C++/carla_app.cpp @@ -58,8 +58,8 @@ CarlaApplication::CarlaApplication(const QString appName, int& argc, char* argv[ QApplication.addLibraryPath(CWD) // Needed for local wine build - if WINDOWS and CWD.endswith(("frontend", "resources")) and os.getenv("CXFREEZE") is None: - if kIs64bit: + if CARLA_OS_WIN and CWD.endswith(("frontend", "resources")) and os.getenv("CXFREEZE") is None: + if CARLA_OS_64BIT: path = "H:\\builds\\msys2-x86_64\\mingw64\\share\\qt5\\plugins" else: path = "H:\\builds\\msys2-i686\\mingw32\\share\\qt5\\plugins" diff --git a/source/frontend/carla-plugin b/source/frontend/carla-plugin index f23b0356e..cf2a9dbc1 100755 --- a/source/frontend/carla-plugin +++ b/source/frontend/carla-plugin @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho # SPDX-License-Identifier: GPL-2.0-or-later # ------------------------------------------------------------------------------------------------------------ @@ -541,7 +541,7 @@ class CarlaEmbedW(QEmbedWidget): # set our gui as parent for all plugins UIs if self.host.manageUIs: - if MACOS: + if CARLA_OS_MAC: nsViewPtr = int(self.fWinId) winIdStr = "%x" % gCarla.utils.cocoa_get_window(nsViewPtr) else: diff --git a/source/frontend/carla_app.py b/source/frontend/carla_app.py index d14d1cbb8..42cce8b7e 100644 --- a/source/frontend/carla_app.py +++ b/source/frontend/carla_app.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho # SPDX-License-Identifier: GPL-2.0-or-later # ------------------------------------------------------------------------------------------------------------ @@ -18,6 +18,8 @@ from ctypes import CDLL, RTLD_GLOBAL from qt_compat import qt_config +# pylint: disable=import-error + if qt_config == 5: from PyQt5.QtCore import QT_VERSION, Qt, QCoreApplication, QLibraryInfo, QLocale, QTranslator from PyQt5.QtGui import QColor, QIcon, QPalette @@ -27,17 +29,26 @@ elif qt_config == 6: from PyQt6.QtGui import QColor, QIcon, QPalette from PyQt6.QtWidgets import QApplication +# pylint: enable=import-error +# pylint: disable=possibly-used-before-assignment + # ------------------------------------------------------------------------------------------------------------ # Imports (Custom) -from carla_backend import kIs64bit, LINUX, MACOS, WINDOWS +from carla_backend import ( + CARLA_OS_64BIT, + CARLA_OS_LINUX, + CARLA_OS_MAC, + CARLA_OS_WIN, + CARLA_VERSION_STRING, +) from carla_shared import ( CARLA_KEY_MAIN_USE_PRO_THEME, CARLA_KEY_MAIN_PRO_THEME_COLOR, CARLA_DEFAULT_MAIN_USE_PRO_THEME, CARLA_DEFAULT_MAIN_PRO_THEME_COLOR, - CWD, VERSION, + CWD, getPaths, gCarla ) @@ -50,13 +61,13 @@ class CarlaApplication(): def __init__(self, appName = "Carla2", libPrefix = None): pathBinaries, pathResources = getPaths(libPrefix) - # Needed for MacOS and Windows - if os.path.exists(CWD) and (MACOS or WINDOWS): + # Needed for macOS and Windows + if os.path.exists(CWD) and (CARLA_OS_MAC or CARLA_OS_WIN): QApplication.addLibraryPath(CWD) # Needed for local wine build - if WINDOWS and CWD.endswith(("frontend", "resources")) and os.getenv("CXFREEZE") is None: - if kIs64bit: + if CARLA_OS_WIN and CWD.endswith(("frontend", "resources")) and os.getenv("CXFREEZE") is None: + if CARLA_OS_64BIT: path = "H:\\PawPawBuilds\\targets\\win64\\lib\\qt5\\plugins" else: path = "H:\\PawPawBuilds\\targets\\win32\\lib\\qt5\\plugins" @@ -94,7 +105,7 @@ class CarlaApplication(): # base settings settings = QSafeSettings("falkTX", appName) - useProTheme = MACOS or settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, CARLA_DEFAULT_MAIN_USE_PRO_THEME, bool) + useProTheme = CARLA_OS_MAC or settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, CARLA_DEFAULT_MAIN_USE_PRO_THEME, bool) if not useProTheme: self.createApp(appName) @@ -111,7 +122,7 @@ class CarlaApplication(): self.fApp.setStyle("carla" if stylesDir else "fusion") - if WINDOWS: + if CARLA_OS_WIN: carlastyle1 = os.path.join(pathBinaries, "styles", "carlastyle.dll") carlastyle2 = os.path.join(pathResources, "styles", "carlastyle.dll") carlastyle = carlastyle2 if os.path.exists(carlastyle2) else carlastyle1 @@ -123,14 +134,14 @@ class CarlaApplication(): # set palette proThemeColor = settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, CARLA_DEFAULT_MAIN_PRO_THEME_COLOR, str).lower() - if MACOS or proThemeColor == "black": + if CARLA_OS_MAC or proThemeColor == "black": self.createPaletteBlack() elif proThemeColor == "blue": self.createPaletteBlue() def createApp(self, appName): - if qt_config == 5 and LINUX: + if qt_config == 5 and CARLA_OS_LINUX: # AA_X11InitThreads is not available on old PyQt versions try: attr = Qt.AA_X11InitThreads @@ -142,17 +153,17 @@ class CarlaApplication(): QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) - if MACOS: + if CARLA_OS_MAC: QApplication.setAttribute(Qt.AA_DontShowIconsInMenus) args = sys.argv[:] - if WINDOWS: + if CARLA_OS_WIN: args += ["-platform", "windows:fontengine=freetype"] self.fApp = QCoreApplication(args) if gCarla.nogui else QApplication(args) self.fApp.setApplicationName(appName) - self.fApp.setApplicationVersion(VERSION) + self.fApp.setApplicationVersion(CARLA_VERSION_STRING) self.fApp.setOrganizationName("falkTX") if self.fAppTranslator is not None: @@ -306,3 +317,4 @@ class CarlaApplication(): self.fApp.quit() # ------------------------------------------------------------------------------------------------------------ +# pylint: enable=possibly-used-before-assignment diff --git a/source/frontend/carla_backend.py b/source/frontend/carla_backend.py index 9ff33e39e..5447030df 100644 --- a/source/frontend/carla_backend.py +++ b/source/frontend/carla_backend.py @@ -1,20 +1,6 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Carla Backend code -# Copyright (C) 2011-2021 Filipe Coelho -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# For a full copy of the GNU General Public License see the doc/GPL.txt file. +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho +# SPDX-License-Identifier: GPL-2.0-or-later # --------------------------------------------------------------------------------------------------------------------- # Imports (Global) @@ -36,14 +22,27 @@ from ctypes import ( # Imports (Custom) from common import ( - kIs64bit, HAIKU, LINUX, MACOS, WINDOWS, VERSION + CARLA_OS_64BIT, + CARLA_OS_BSD, + CARLA_OS_GNU_HURD, + CARLA_OS_HAIKU, + CARLA_OS_LINUX, + CARLA_OS_MAC, + CARLA_OS_UNIX, + CARLA_OS_WASM, + CARLA_OS_WIN, + CARLA_OS_WIN32, + CARLA_OS_WIN64, + CARLA_VERSION_HEX, + CARLA_VERSION_STRING, + CARLA_VERSION_STRMIN, ) # --------------------------------------------------------------------------------------------------------------------- # Define custom types c_enum = c_int -c_uintptr = c_uint64 if kIs64bit else c_uint32 +c_uintptr = c_uint64 if CARLA_OS_64BIT else c_uint32 # --------------------------------------------------------------------------------------------------------------------- # Convert a ctypes c_char_p into a python string @@ -1513,10 +1512,14 @@ PyCarlaRuntimeEngineDriverDeviceInfo = { # --------------------------------------------------------------------------------------------------------------------- # Set BINARY_NATIVE -if WINDOWS: - BINARY_NATIVE = BINARY_WIN64 if kIs64bit else BINARY_WIN32 +if CARLA_OS_WIN64: + BINARY_NATIVE = BINARY_WIN64 +elif CARLA_OS_WIN32: + BINARY_NATIVE = BINARY_WIN32 +elif CARLA_OS_64BIT: + BINARY_NATIVE = BINARY_POSIX64 else: - BINARY_NATIVE = BINARY_POSIX64 if kIs64bit else BINARY_POSIX32 + BINARY_NATIVE = BINARY_POSIX32 # --------------------------------------------------------------------------------------------------------------------- # Carla Host object (Meta) diff --git a/source/frontend/carla_host.py b/source/frontend/carla_host.py index 6480a5b95..bbe2c3000 100644 --- a/source/frontend/carla_host.py +++ b/source/frontend/carla_host.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho # SPDX-License-Identifier: GPL-2.0-or-later # ------------------------------------------------------------------------------------------------------------ @@ -218,7 +218,7 @@ class HostWindow(QMainWindow): self.fOscAddressTCP = "" self.fOscAddressUDP = "" - if MACOS: + if CARLA_OS_MAC: self.fMacClosingHelper = True # CancelableActionCallback Box @@ -301,7 +301,7 @@ class HostWindow(QMainWindow): else: self.ui.act_engine_start.setEnabled(True) - if WINDOWS: + if CARLA_OS_WIN: self.ui.tabWidget.removeTab(2) if self.host.isControl: @@ -352,7 +352,7 @@ class HostWindow(QMainWindow): self.ui.menu_Canvas.menuAction().setVisible(False) self.ui.tw_miniCanvas.hide() self.ui.tabWidget.removeTab(1) - if WINDOWS: + if CARLA_OS_WIN: self.ui.tabWidget.tabBar().hide() # ---------------------------------------------------------------------------------------------------- @@ -467,7 +467,7 @@ class HostWindow(QMainWindow): # ---------------------------------------------------------------------------------------------------- # Set up GUI (special stuff for Mac OS) - if MACOS: + if CARLA_OS_MAC: self.ui.act_file_quit.setMenuRole(QAction.QuitRole) self.ui.act_settings_configure.setMenuRole(QAction.PreferencesRole) self.ui.act_help_about.setMenuRole(QAction.AboutRole) @@ -2029,7 +2029,7 @@ class HostWindow(QMainWindow): folder = diskFolders[i] self.ui.cb_disk.addItem(os.path.basename(folder), folder) - #if MACOS and not settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, True, bool): + #if CARLA_OS_MAC and not settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, True, bool): # self.setUnifiedTitleAndToolBarOnMac(True) showMeters = settings.value("ShowMeters", True, bool) @@ -2839,10 +2839,10 @@ class HostWindow(QMainWindow): # set our gui as parent for all plugins UIs if self.host.manageUIs and not self.host.isControl: - if MACOS: + if CARLA_OS_MAC: nsViewPtr = int(self.winId()) winIdStr = "%x" % gCarla.utils.cocoa_get_window(nsViewPtr) - elif WINDOWS or QApplication.platformName() == "xcb": + elif CARLA_OS_WIN or QApplication.platformName() == "xcb": winIdStr = "%x" % int(self.winId()) else: winIdStr = "0" @@ -3004,7 +3004,7 @@ class HostWindow(QMainWindow): #def paintEvent(self, event): #QMainWindow.paintEvent(self, event) - #if MACOS or not self.fSavedSettings[CARLA_KEY_CUSTOM_PAINTING]: + #if CARLA_OS_MAC or not self.fSavedSettings[CARLA_KEY_CUSTOM_PAINTING]: #return #painter = QPainter(self) @@ -3040,7 +3040,7 @@ class HostWindow(QMainWindow): patchcanvas.handleAllPluginsRemoved() - if MACOS and self.fMacClosingHelper and not (self.host.isControl or self.host.isPlugin): + if CARLA_OS_MAC and self.fMacClosingHelper and not (self.host.isControl or self.host.isPlugin): self.fCustomStopAction = self.CUSTOM_ACTION_APP_CLOSE self.fMacClosingHelper = False event.ignore() @@ -3350,7 +3350,7 @@ def initHost(initName, libPrefix, isControl, isPlugin, failError, HostClass = No # Print info if not (gCarla.nogui and isinstance(gCarla.nogui, int)): - print("Carla %s started, status:" % VERSION) + print("Carla %s started, status:" % CARLA_VERSION_STRING) print(" Python version: %s" % sys.version.split(" ",1)[0]) print(" Qt version: %s" % QT_VERSION_STR) print(" PyQt version: %s" % PYQT_VERSION_STR) @@ -3429,7 +3429,7 @@ def loadHostSettings(host): host.preferPluginBridges = settings.value(CARLA_KEY_ENGINE_PREFER_PLUGIN_BRIDGES, CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES, bool) host.preferUIBridges = settings.value(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, CARLA_DEFAULT_PREFER_UI_BRIDGES, bool) host.preventBadBehaviour = settings.value(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR, CARLA_DEFAULT_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR, bool) - host.showLogs = settings.value(CARLA_KEY_MAIN_SHOW_LOGS, CARLA_DEFAULT_MAIN_SHOW_LOGS, bool) and not WINDOWS + host.showLogs = settings.value(CARLA_KEY_MAIN_SHOW_LOGS, CARLA_DEFAULT_MAIN_SHOW_LOGS, bool) and not CARLA_OS_WIN host.showPluginBridges = settings.value(CARLA_KEY_EXPERIMENTAL_PLUGIN_BRIDGES, CARLA_DEFAULT_EXPERIMENTAL_PLUGIN_BRIDGES, bool) host.showWineBridges = settings.value(CARLA_KEY_EXPERIMENTAL_WINE_BRIDGES, CARLA_DEFAULT_EXPERIMENTAL_WINE_BRIDGES, bool) host.uiBridgesTimeout = settings.value(CARLA_KEY_ENGINE_UI_BRIDGES_TIMEOUT, CARLA_DEFAULT_UI_BRIDGES_TIMEOUT, int) diff --git a/source/frontend/carla_settings.py b/source/frontend/carla_settings.py index b35c2ddc0..80fff3340 100755 --- a/source/frontend/carla_settings.py +++ b/source/frontend/carla_settings.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho # SPDX-License-Identifier: GPL-2.0-or-later # --------------------------------------------------------------------------------------------------------------------- @@ -21,7 +21,9 @@ import ui_carla_settings import ui_carla_settings_driver from carla_backend import ( - LINUX, MACOS, WINDOWS, + CARLA_OS_LINUX, + CARLA_OS_MAC, + CARLA_OS_WIN, ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL, ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER, ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE, @@ -215,7 +217,7 @@ class DriverSettingsW(QDialog): self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) - if MACOS: + if CARLA_OS_MAC: self.setWindowModality(Qt.WindowModal) # ------------------------------------------------------------------------------------------------------------- @@ -406,7 +408,7 @@ class RuntimeDriverSettingsW(QDialog): self.adjustSize() self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) - if MACOS: + if CARLA_OS_MAC: self.setWindowModality(Qt.WindowModal) # ------------------------------------------------------------------------------------------------------------- @@ -533,11 +535,11 @@ class CarlaSettingsW(QDialog): for i in range(Theme.THEME_MAX): self.ui.cb_canvas_theme.addItem(getThemeName(i)) - if MACOS: + if CARLA_OS_MAC: self.ui.group_main_theme.setEnabled(False) self.ui.group_main_theme.setVisible(False) - if WINDOWS or host.isControl: + if CARLA_OS_WIN or host.isControl: self.ui.ch_main_show_logs.setEnabled(False) self.ui.ch_main_show_logs.setVisible(False) @@ -576,15 +578,15 @@ class CarlaSettingsW(QDialog): self.ui.lw_page.hideRow(self.TAB_INDEX_OSC) self.ui.lw_page.hideRow(self.TAB_INDEX_WINE) - if not LINUX: + if not CARLA_OS_LINUX: self.ui.ch_exp_wine_bridges.setVisible(False) self.ui.ch_exp_prevent_bad_behaviour.setVisible(False) self.ui.lw_page.hideRow(self.TAB_INDEX_WINE) - if not MACOS: + if not CARLA_OS_MAC: self.ui.label_engine_ui_bridges_mac_note.setVisible(False) - if not (LINUX or MACOS): + if not (CARLA_OS_LINUX or CARLA_OS_MAC): self.ui.ch_exp_jack_apps.setVisible(False) # FIXME, not implemented yet @@ -599,7 +601,7 @@ class CarlaSettingsW(QDialog): self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) - if MACOS: + if CARLA_OS_MAC: self.setWindowModality(Qt.WindowModal) # ------------------------------------------------------------------------------------------------------------- diff --git a/source/frontend/carla_shared.py b/source/frontend/carla_shared.py index e8a7c66e2..aae07a0d0 100644 --- a/source/frontend/carla_shared.py +++ b/source/frontend/carla_shared.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho # SPDX-License-Identifier: GPL-2.0-or-later # ------------------------------------------------------------------------------------------------------------ @@ -26,6 +26,8 @@ except: from qt_compat import qt_config +# pylint: disable=import-error + if qt_config == 5: # import changed in PyQt 5.15.8, so try both try: @@ -42,19 +44,25 @@ elif qt_config == 6: from PyQt6.QtGui import QIcon from PyQt6.QtWidgets import QFileDialog, QMessageBox +# pylint: enable=import-error +# pylint: disable=possibly-used-before-assignment + # ------------------------------------------------------------------------------------------------------------ # Imports (Custom) from carla_backend import ( + CARLA_OS_64BIT, + CARLA_OS_HAIKU, + CARLA_OS_MAC, + CARLA_OS_WIN, + CARLA_VERSION_STRING, MAX_DEFAULT_PARAMETERS, ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, ENGINE_PROCESS_MODE_PATCHBAY, ENGINE_TRANSPORT_MODE_INTERNAL, - ENGINE_TRANSPORT_MODE_JACK + ENGINE_TRANSPORT_MODE_JACK, ) -from common import kIs64bit, HAIKU, LINUX, MACOS, WINDOWS, VERSION - # ------------------------------------------------------------------------------------------------------------ # Config @@ -65,7 +73,7 @@ X_DATADIR_X = None # ------------------------------------------------------------------------------------------------------------ # Platform specific stuff -if WINDOWS: +if CARLA_OS_WIN: WINDIR = os.getenv("WINDIR") # ------------------------------------------------------------------------------------------------------------ @@ -74,7 +82,7 @@ if WINDOWS: envTMP = os.getenv("TMP") if envTMP is None: - if WINDOWS: + if CARLA_OS_WIN: qWarning("TMP variable not set") TMP = QDir.tempPath() else: @@ -92,7 +100,7 @@ del envTMP envHOME = os.getenv("HOME") if envHOME is None: - if not WINDOWS: + if not CARLA_OS_WIN: qWarning("HOME variable not set") HOME = QDir.toNativeSeparators(QDir.homePath()) else: @@ -111,9 +119,9 @@ envPATH = os.getenv("PATH") if envPATH is None: qWarning("PATH variable not set") - if MACOS: + if CARLA_OS_MAC: PATH = ("/opt/local/bin", "/usr/local/bin", "/usr/bin", "/bin") - elif WINDOWS: + elif CARLA_OS_WIN: PATH = (os.path.join(WINDIR, "system32"), WINDIR) else: PATH = ("/usr/local/bin", "/usr/bin", "/bin") @@ -262,7 +270,7 @@ CARLA_DEFAULT_MAIN_PRO_THEME_COLOR = "Black" CARLA_DEFAULT_MAIN_REFRESH_INTERVAL = 20 CARLA_DEFAULT_MAIN_CONFIRM_EXIT = True CARLA_DEFAULT_MAIN_CLASSIC_SKIN = False -CARLA_DEFAULT_MAIN_SHOW_LOGS = bool(not WINDOWS) +CARLA_DEFAULT_MAIN_SHOW_LOGS = bool(not CARLA_OS_WIN) CARLA_DEFAULT_MAIN_SYSTEM_ICONS = False CARLA_DEFAULT_MAIN_EXPERIMENTAL = False @@ -296,11 +304,11 @@ CARLA_DEFAULT_AUDIO_BUFFER_SIZE = 512 CARLA_DEFAULT_AUDIO_SAMPLE_RATE = 44100 CARLA_DEFAULT_AUDIO_TRIPLE_BUFFER = False -if HAIKU: +if CARLA_OS_HAIKU: CARLA_DEFAULT_AUDIO_DRIVER = "SDL" -elif MACOS: +elif CARLA_OS_MAC: CARLA_DEFAULT_AUDIO_DRIVER = "CoreAudio" -elif WINDOWS: +elif CARLA_OS_WIN: CARLA_DEFAULT_AUDIO_DRIVER = "Windows Audio" elif os.path.exists("/usr/bin/jackd") or os.path.exists("/usr/bin/jackdbus") or os.path.exists("/usr/bin/pw-jack"): CARLA_DEFAULT_AUDIO_DRIVER = "JACK" @@ -315,7 +323,7 @@ else: CARLA_DEFAULT_TRANSPORT_MODE = ENGINE_TRANSPORT_MODE_INTERNAL # OSC -CARLA_DEFAULT_OSC_ENABLED = not (MACOS or WINDOWS) +CARLA_DEFAULT_OSC_ENABLED = not (CARLA_OS_MAC or CARLA_OS_WIN) CARLA_DEFAULT_OSC_TCP_PORT_ENABLED = True CARLA_DEFAULT_OSC_TCP_PORT_NUMBER = 22752 CARLA_DEFAULT_OSC_TCP_PORT_RANDOM = False @@ -358,7 +366,7 @@ DEFAULT_SF2_PATH = "" DEFAULT_SFZ_PATH = "" DEFAULT_JSFX_PATH = "" -if WINDOWS: +if CARLA_OS_WIN: splitter = ";" APPDATA = os.getenv("APPDATA") @@ -396,7 +404,7 @@ if WINDOWS: DEFAULT_JSFX_PATH = APPDATA + "\\REAPER\\Effects" #DEFAULT_JSFX_PATH += ";" + PROGRAMFILES + "\\REAPER\\InstallData\\Effects" - if kIs64bit: + if CARLA_OS_64BIT: DEFAULT_VST2_PATH += ";" + COMMONPROGRAMFILES + "\\VST2" DEFAULT_VST3_PATH = COMMONPROGRAMFILES + "\\VST3" @@ -419,7 +427,7 @@ if WINDOWS: DEFAULT_VST3_PATH += COMMONPROGRAMFILESx86 + "\\VST3" DEFAULT_CLAP_PATH += COMMONPROGRAMFILESx86 + "\\CLAP" -elif HAIKU: +elif CARLA_OS_HAIKU: splitter = ":" DEFAULT_LADSPA_PATH = HOME + "/.ladspa" @@ -442,7 +450,7 @@ elif HAIKU: DEFAULT_CLAP_PATH = HOME + "/.clap" DEFAULT_CLAP_PATH += ":/system/add-ons/media/clapplugins" -elif MACOS: +elif CARLA_OS_MAC: splitter = ":" DEFAULT_LADSPA_PATH = HOME + "/Library/Audio/Plug-Ins/LADSPA" @@ -511,7 +519,7 @@ else: DEFAULT_JSFX_PATH = CONFIG_HOME + "/REAPER/Effects" #DEFAULT_JSFX_PATH += ":" + "/opt/REAPER/InstallData/Effects" -if not WINDOWS: +if not CARLA_OS_WIN: winePrefix = os.getenv("WINEPREFIX") if not winePrefix: @@ -525,7 +533,7 @@ if not WINDOWS: DEFAULT_VST3_PATH += ":" + winePrefix + "/drive_c/Program Files/Common Files/VST3" DEFAULT_CLAP_PATH += ":" + winePrefix + "/drive_c/Program Files/Common Files/CLAP" - if kIs64bit: + if CARLA_OS_64BIT: DEFAULT_VST2_PATH += ":" + winePrefix + "/drive_c/Program Files (x86)/VstPlugins" DEFAULT_VST2_PATH += ":" + winePrefix + "/drive_c/Program Files (x86)/VSTPlugins" DEFAULT_VST2_PATH += ":" + winePrefix + "/drive_c/Program Files (x86)/Steinberg/VstPlugins" @@ -540,7 +548,7 @@ if not WINDOWS: readEnvVars = True -if WINDOWS: +if CARLA_OS_WIN: # Check if running Wine. If yes, ignore env vars # pylint: disable=import-error from winreg import ConnectRegistry, OpenKey, CloseKey, HKEY_CURRENT_USER @@ -620,7 +628,7 @@ if os.path.isfile(CWD): if CWD.endswith("/lib"): CWD = CWD.rsplit("/lib",1)[0] CXFREEZE = True - if not WINDOWS: + if not CARLA_OS_WIN: os.environ['CARLA_MAGIC_FILE'] = os.path.join(CWD, "magic.mgc") else: CXFREEZE = False @@ -628,9 +636,9 @@ else: # ------------------------------------------------------------------------------------------------------------ # Set DLL_EXTENSION -if WINDOWS: +if CARLA_OS_WIN: DLL_EXTENSION = "dll" -elif MACOS: +elif CARLA_OS_MAC: DLL_EXTENSION = "dylib" else: DLL_EXTENSION = "so" @@ -708,7 +716,7 @@ def handleInitialCommandLineArguments(file): elif arg in ("-n", "--n", "-no-gui", "--no-gui", "-nogui", "--nogui"): gCarla.nogui = True - elif MACOS and arg.startswith("-psn_"): + elif CARLA_OS_MAC and arg.startswith("-psn_"): pass elif arg in ("-h", "--h", "-help", "--help"): @@ -737,7 +745,7 @@ def handleInitialCommandLineArguments(file): elif arg in ("-v", "--v", "-version", "--version"): pathBinaries, pathResources = getPaths(libPrefix) - print("Using Carla version %s" % VERSION) + print("Using Carla version %s" % CARLA_VERSION_STRING) print(" Python version: %s" % sys.version.split(" ",1)[0]) print(" Qt version: %s" % QT_VERSION_STR) print(" PyQt version: %s" % PYQT_VERSION_STR) @@ -785,7 +793,7 @@ def getInitialProjectFile(skipExistCheck = False): continue if arg in ("-n", "--n", "-no-gui", "--no-gui", "-nogui", "--nogui", "--gdb"): continue - if MACOS and arg.startswith("-psn_"): + if CARLA_OS_MAC and arg.startswith("-psn_"): continue arg = os.path.expanduser(arg) if skipExistCheck or os.path.exists(arg): @@ -914,7 +922,10 @@ def CustomMessageBox(parent, icon, title, text, msgBox.setInformativeText(extraText) msgBox.setStandardButtons(buttons) msgBox.setDefaultButton(defButton) + # pylint: disable=no-value-for-parameter return msgBox.exec_() + # pylint: enable=no-value-for-parameter # pylint: enable=too-many-arguments # ------------------------------------------------------------------------------------------------------------ +# pylint: enable=possibly-used-before-assignment diff --git a/source/frontend/carla_utils.py b/source/frontend/carla_utils.py index 4f6b13530..126e1a850 100644 --- a/source/frontend/carla_utils.py +++ b/source/frontend/carla_utils.py @@ -1,20 +1,6 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Carla Backend utils -# Copyright (C) 2011-2020 Filipe Coelho -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# For a full copy of the GNU General Public License see the doc/GPL.txt file. +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho +# SPDX-License-Identifier: GPL-2.0-or-later # ------------------------------------------------------------------------------------------------------------ # Imports (Global) @@ -35,6 +21,7 @@ from ctypes import ( # Imports (Custom) from carla_backend import ( + CARLA_OS_WIN, PLUGIN_NONE, PLUGIN_INTERNAL, PLUGIN_LADSPA, @@ -60,7 +47,6 @@ from carla_backend import ( PLUGIN_CATEGORY_MODULATOR, PLUGIN_CATEGORY_UTILITY, PLUGIN_CATEGORY_OTHER, - WINDOWS, c_enum, c_uintptr, charPtrToString, charPtrPtrToStringList, @@ -347,7 +333,7 @@ class CarlaUtils(): self._pipeClientCallback = None # use _putenv on windows - if not WINDOWS: + if not CARLA_OS_WIN: self.msvcrt = None return @@ -363,7 +349,7 @@ class CarlaUtils(): def setenv(self, key, value): environ[key] = value - if WINDOWS: + if CARLA_OS_WIN: keyvalue = "%s=%s" % (key, value) # pylint: disable=protected-access self.msvcrt._putenv(keyvalue.encode("utf-8")) @@ -374,7 +360,7 @@ class CarlaUtils(): if environ.get(key) is not None: environ.pop(key) - if WINDOWS: + if CARLA_OS_WIN: keyrm = "%s=" % key # pylint: disable=protected-access self.msvcrt._putenv(keyrm.encode("utf-8")) diff --git a/source/frontend/carla_widgets.py b/source/frontend/carla_widgets.py index 136268467..451ef0dd0 100755 --- a/source/frontend/carla_widgets.py +++ b/source/frontend/carla_widgets.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho # SPDX-License-Identifier: GPL-2.0-or-later # ------------------------------------------------------------------------------------------------------------ @@ -47,8 +47,10 @@ import ui_carla_edit import ui_carla_parameter from carla_backend import ( - MACOS, WINDOWS, BINARY_NATIVE, + CARLA_VERSION_STRING, + CARLA_OS_MAC, + CARLA_OS_WIN, PLUGIN_INTERNAL, PLUGIN_DSSI, PLUGIN_LV2, @@ -92,7 +94,6 @@ from carla_backend import ( from carla_shared import ( MIDI_CC_LIST, MAX_MIDI_CC_LIST_ITEM, - VERSION, countDecimalPoints, fontMetricsHorizontalAdvance, setUpSignals, @@ -100,7 +101,6 @@ from carla_shared import ( ) from carla_utils import getPluginTypeAsString -#) from widgets.collapsablewidget import CollapsibleBox from widgets.pixmapkeyboard import PixmapKeyboardHArea @@ -132,8 +132,8 @@ class CarlaAboutW(QDialog): self.ui.l_about.setText(self.tr("" "
Version %s" "
Carla is a fully-featured audio plugin host%s.
" - "
Copyright (C) 2011-2022 falkTX
" - "" % (VERSION, extraInfo))) + "
Copyright (C) 2011-2025 falkTX
" + "" % (CARLA_VERSION_STRING, extraInfo))) if self.ui.about.palette().color(QPalette.Background).blackF() < 0.5: self.ui.l_icons.setPixmap(QPixmap(":/bitmaps/carla_about_black.png")) @@ -216,7 +216,7 @@ class CarlaAboutW(QDialog): self.ui.l_vst2.setText(self.tr("About 85% complete (missing vst bank/presets and some minor stuff)")) self.ui.l_vst3.setText(self.tr("About 66% complete")) - if MACOS: + if CARLA_OS_MAC: self.ui.l_au.setText(self.tr("About 20% complete")) else: self.ui.line_vst3.hide() @@ -234,12 +234,12 @@ class CarlaAboutW(QDialog): flags = self.windowFlags() flags &= ~Qt.WindowContextHelpButtonHint - if WINDOWS: + if CARLA_OS_WIN: flags |= Qt.MSWindowsFixedSizeDialogHint self.setWindowFlags(flags) - if MACOS: + if CARLA_OS_MAC: self.setWindowModality(Qt.WindowModal) # ------------------------------------------------------------------------------------------------------------ @@ -1281,7 +1281,7 @@ class PluginEdit(QDialog): QDialog.setVisible(self, yesNo) - if MACOS and yesNo: + if CARLA_OS_MAC and yesNo: parent = self.parent() if parent is None: return diff --git a/source/frontend/common/__init__.py b/source/frontend/common/__init__.py index 28c9e6238..51b0b1f7e 100644 --- a/source/frontend/common/__init__.py +++ b/source/frontend/common/__init__.py @@ -1,20 +1,6 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Common Carla code -# Copyright (C) 2011-2022 Filipe Coelho -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# For a full copy of the GNU General Public License see the doc/GPL.txt file. +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho +# SPDX-License-Identifier: GPL-2.0-or-later # --------------------------------------------------------------------------------------------------------------------- # Imports (Global) @@ -25,40 +11,43 @@ from sys import platform, maxsize # --------------------------------------------------------------------------------------------------------------------- # Set Version -VERSION = "2.6.0-alpha1" +CARLA_VERSION_HEX = 0x020591 +CARLA_VERSION_STRING = "2.6.0-alpha1" +CARLA_VERSION_STRMIN = "2.6" # --------------------------------------------------------------------------------------------------------------------- -# 64bit check +# Set Platform + +CARLA_OS_BSD = False +CARLA_OS_GNU_HURD = False +CARLA_OS_HAIKU = False +CARLA_OS_LINUX = False +CARLA_OS_MAC = False +CARLA_OS_UNIX = False +CARLA_OS_WASM = False +CARLA_OS_WIN = False +CARLA_OS_WIN32 = False +CARLA_OS_WIN64 = False -kIs64bit = bool(architecture()[0] == "64bit" and maxsize > 2**32) +if platform == "darwin": + CARLA_OS_MAC = True +elif platform == "haiku": + CARLA_OS_HAIKU = True +elif platform == "linux": + CARLA_OS_LINUX = True +elif platform == "win32": + CARLA_OS_WIN32 = True +elif platform == "win64": + CARLA_OS_WIN64 = True + +if CARLA_OS_WIN32 and CARLA_OS_WIN64: + CARLA_OS_WIN = True +elif CARLA_OS_BSD or CARLA_OS_GNU_HURD or CARLA_OS_LINUX or CARLA_OS_MAC: + CARLA_OS_UNIX = True # --------------------------------------------------------------------------------------------------------------------- -# Set Platform +# 64bit check -if platform == "darwin": - HAIKU = False - LINUX = False - MACOS = True - WINDOWS = False -elif "haiku" in platform: - HAIKU = True - LINUX = False - MACOS = False - WINDOWS = False -elif "linux" in platform: - HAIKU = False - LINUX = True - MACOS = False - WINDOWS = False -elif platform in ("win32", "win64", "cygwin"): - HAIKU = False - LINUX = False - MACOS = False - WINDOWS = True -else: - HAIKU = False - LINUX = False - MACOS = False - WINDOWS = False +CARLA_OS_64BIT = bool(architecture()[0] == "64bit" and maxsize > 2**32) # --------------------------------------------------------------------------------------------------------------------- diff --git a/source/frontend/pluginlist/pluginlistdialog.cpp b/source/frontend/pluginlist/pluginlistdialog.cpp index 3847699d8..95fe247d2 100644 --- a/source/frontend/pluginlist/pluginlistdialog.cpp +++ b/source/frontend/pluginlist/pluginlistdialog.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2011-2024 Filipe Coelho +// SPDX-FileCopyrightText: 2011-2025 Filipe Coelho // SPDX-License-Identifier: GPL-2.0-or-later #include "pluginlistdialog.hpp" @@ -908,7 +908,7 @@ PluginListDialog::PluginListDialog(QWidget* const parent, const HostSettings* co #if 0 // NOTE: We Assume win32 carla build will not run win64 plugins - if (WINDOWS and not kIs64bit) or not host.showPluginBridges: + if (CARLA_OS_WIN and not CARLA_OS_64BIT) or not host.showPluginBridges: ui.ch_native.setChecked(True) ui.ch_native.setEnabled(False) ui.ch_native.setVisible(True) diff --git a/source/frontend/widgets/draggablegraphicsview.py b/source/frontend/widgets/draggablegraphicsview.py index 36293f404..519b9661c 100644 --- a/source/frontend/widgets/draggablegraphicsview.py +++ b/source/frontend/widgets/draggablegraphicsview.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho # SPDX-License-Identifier: GPL-2.0-or-later # --------------------------------------------------------------------------------------------------------------------- @@ -21,7 +21,8 @@ elif qt_config == 6: # --------------------------------------------------------------------------------------------------------------------- # Imports (Custom Stuff) -from carla_shared import MACOS, CustomMessageBox, gCarla +from carla_backend import CARLA_OS_MAC +from carla_shared import CustomMessageBox, gCarla # --------------------------------------------------------------------------------------------------------------------- # Widget Class @@ -47,7 +48,7 @@ class DraggableGraphicsView(QGraphicsView): if os.path.isdir(filename): #if os.path.exists(os.path.join(filename, "manifest.ttl")): #return True - if MACOS and lfilename.endswith(".vst"): + if CARLA_OS_MAC and lfilename.endswith(".vst"): return True if lfilename.endswith(".vst3") and ".vst3" in self.fSupportedExtensions: return True diff --git a/source/frontend/widgets/paramspinbox.py b/source/frontend/widgets/paramspinbox.py index 8d6c2dfe0..4a85a1669 100644 --- a/source/frontend/widgets/paramspinbox.py +++ b/source/frontend/widgets/paramspinbox.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho # SPDX-License-Identifier: GPL-2.0-or-later # ------------------------------------------------------------------------------------------------------------ @@ -24,7 +24,8 @@ elif qt_config == 6: import ui_inputdialog_value -from carla_shared import countDecimalPoints, MACOS +from carla_backend import CARLA_OS_MAC +from carla_shared import countDecimalPoints # ------------------------------------------------------------------------------------------------------------ # Get a fixed value within min/max bounds @@ -59,7 +60,7 @@ class CustomInputDialog(QDialog): self.ui.doubleSpinBox.setPrefix(prefix) self.ui.doubleSpinBox.setSuffix(suffix) - if MACOS: + if CARLA_OS_MAC: self.setWindowModality(Qt.WindowModal) if not scalePoints: diff --git a/source/frontend/widgets/racklistwidget.py b/source/frontend/widgets/racklistwidget.py index f9513d17b..d64c5761e 100644 --- a/source/frontend/widgets/racklistwidget.py +++ b/source/frontend/widgets/racklistwidget.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2011-2024 Filipe Coelho +# SPDX-FileCopyrightText: 2011-2025 Filipe Coelho # SPDX-License-Identifier: GPL-2.0-or-later # ------------------------------------------------------------------------------------------------------------ @@ -24,7 +24,7 @@ elif qt_config == 6: # ------------------------------------------------------------------------------------------------------------ # Imports (Custom Stuff) -from carla_backend import CUSTOM_DATA_TYPE_PROPERTY, MACOS +from carla_backend import CARLA_OS_MAC, CUSTOM_DATA_TYPE_PROPERTY from carla_shared import gCarla, CustomMessageBox from carla_skin import createPluginSlot @@ -259,7 +259,7 @@ class RackListWidget(QListWidget): if os.path.isdir(filename): #if os.path.exists(os.path.join(filename, "manifest.ttl")): #return True - if MACOS and lfilename.endswith(".vst"): + if CARLA_OS_MAC and lfilename.endswith(".vst"): return True if lfilename.endswith(".vst3") and ".vst3" in self.fSupportedExtensions: return True