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.

2151 lines
84KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla host code
  4. # Copyright (C) 2011-2014 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 doc/GPL.txt file.
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Config)
  19. from carla_config import *
  20. # ------------------------------------------------------------------------------------------------------------
  21. # Imports (Global)
  22. if config_UseQt5:
  23. from PyQt5.QtCore import qCritical, QFileInfo, QModelIndex, QPointF, QTimer
  24. from PyQt5.QtGui import QImage, QPalette
  25. from PyQt5.QtPrintSupport import QPrinter, QPrintDialog
  26. from PyQt5.QtWidgets import QAction, QApplication, QFileSystemModel, QListWidgetItem, QMainWindow
  27. else:
  28. from PyQt4.QtCore import qCritical, QFileInfo, QModelIndex, QPointF, QTimer
  29. from PyQt4.QtGui import QAction, QApplication, QFileSystemModel, QImage, QListWidgetItem, QMainWindow, QPalette, QPrinter, QPrintDialog
  30. # ------------------------------------------------------------------------------------------------------------
  31. # Imports (Custom)
  32. import patchcanvas
  33. import ui_carla_host
  34. from carla_app import *
  35. from carla_database import *
  36. from carla_panels import *
  37. from carla_settings import *
  38. from carla_utils import *
  39. from carla_widgets import *
  40. from digitalpeakmeter import DigitalPeakMeter
  41. from pixmapkeyboard import PixmapKeyboardHArea
  42. # ------------------------------------------------------------------------------------------------------------
  43. # Try Import OpenGL
  44. try:
  45. if config_UseQt5:
  46. from PyQt5.QtOpenGL import QGLWidget
  47. else:
  48. from PyQt4.QtOpenGL import QGLWidget
  49. hasGL = True
  50. except:
  51. hasGL = False
  52. # ------------------------------------------------------------------------------------------------------------
  53. # Session Management support
  54. CARLA_CLIENT_NAME = os.getenv("CARLA_CLIENT_NAME")
  55. LADISH_APP_NAME = os.getenv("LADISH_APP_NAME")
  56. NSM_URL = os.getenv("NSM_URL")
  57. # ------------------------------------------------------------------------------------------------------------
  58. # Host Window
  59. class HostWindow(QMainWindow):
  60. #class HostWindow(QMainWindow, PluginEditParentMeta, metaclass=PyQtMetaClass):
  61. # signals
  62. SIGTERM = pyqtSignal()
  63. SIGUSR1 = pyqtSignal()
  64. # --------------------------------------------------------------------------------------------------------
  65. def __init__(self, host, withCanvas, parent=None):
  66. QMainWindow.__init__(self, parent)
  67. self.host = host
  68. self.ui = ui_carla_host.Ui_CarlaHostW()
  69. self.ui.setupUi(self)
  70. gCarla.gui = self
  71. if False:
  72. # kdevelop likes this :)
  73. host = CarlaHostMeta()
  74. self.host = host
  75. self._true = c_char_p("true".encode("utf-8"))
  76. # ----------------------------------------------------------------------------------------------------
  77. # Internal stuff
  78. self.fIdleTimerFast = 0
  79. self.fIdleTimerSlow = 0
  80. self.fLadspaRdfNeedsUpdate = True
  81. self.fLadspaRdfList = []
  82. self.fPluginCount = 0
  83. self.fPluginList = []
  84. self.fProjectFilename = ""
  85. self.fIsProjectLoading = False
  86. self.fCurrentlyRemovingAllPlugins = False
  87. # first attempt of auto-start engine doesn't show an error
  88. self.fFirstEngineInit = True
  89. # to be filled with key-value pairs of current settings
  90. self.fSavedSettings = {}
  91. if host.isPlugin:
  92. self.fClientName = "Carla-Plugin"
  93. self.fSessionManagerName = "Plugin"
  94. elif LADISH_APP_NAME:
  95. self.fClientName = LADISH_APP_NAME
  96. self.fSessionManagerName = "LADISH"
  97. elif NSM_URL:
  98. self.fClientName = "Carla" # "Carla.tmp"
  99. self.fSessionManagerName = "Non Session Manager"
  100. else:
  101. self.fClientName = CARLA_CLIENT_NAME or "Carla"
  102. self.fSessionManagerName = ""
  103. # ----------------------------------------------------------------------------------------------------
  104. # Internal stuff (rack)
  105. self.fCurrentRow = -1
  106. self.fLastSelectedItem = None
  107. # ----------------------------------------------------------------------------------------------------
  108. # Internal stuff (patchbay)
  109. self.fExportImage = QImage()
  110. self.fExportPrinter = QPrinter()
  111. self.fPeaksCleared = True
  112. self.fExternalPatchbay = False
  113. self.fSelectedPlugins = []
  114. self.fCanvasWidth = 0
  115. self.fCanvasHeight = 0
  116. self.fMiniCanvasUpdateTimeout = 0
  117. self.fWithCanvas = withCanvas
  118. # ----------------------------------------------------------------------------------------------------
  119. # Set up GUI (engine stopped)
  120. if self.host.isPlugin:
  121. self.ui.act_engine_start.setEnabled(False)
  122. self.ui.menu_Engine.setEnabled(False)
  123. else:
  124. self.ui.act_engine_start.setEnabled(True)
  125. if self.fSessionManagerName:
  126. self.ui.act_file_new.setEnabled(False)
  127. self.ui.act_file_open.setEnabled(False)
  128. self.ui.act_file_save.setEnabled(False)
  129. self.ui.act_file_save_as.setEnabled(False)
  130. self.ui.act_engine_stop.setEnabled(False)
  131. self.ui.act_plugin_remove_all.setEnabled(False)
  132. self.ui.act_canvas_show_internal.setChecked(False)
  133. self.ui.act_canvas_show_internal.setVisible(False)
  134. self.ui.act_canvas_show_external.setChecked(False)
  135. self.ui.act_canvas_show_external.setVisible(False)
  136. self.ui.menu_PluginMacros.setEnabled(False)
  137. self.ui.menu_Canvas.setEnabled(False)
  138. self.ui.dockWidgetTitleBar = QWidget(self)
  139. self.ui.dockWidget.setTitleBarWidget(self.ui.dockWidgetTitleBar)
  140. if not withCanvas:
  141. self.ui.act_canvas_show_internal.setVisible(False)
  142. self.ui.act_canvas_show_external.setVisible(False)
  143. self.ui.act_canvas_arrange.setVisible(False)
  144. self.ui.act_canvas_print.setVisible(False)
  145. self.ui.act_canvas_refresh.setVisible(False)
  146. self.ui.act_canvas_save_image.setVisible(False)
  147. self.ui.act_canvas_zoom_100.setVisible(False)
  148. self.ui.act_canvas_zoom_fit.setVisible(False)
  149. self.ui.act_canvas_zoom_in.setVisible(False)
  150. self.ui.act_canvas_zoom_out.setVisible(False)
  151. self.ui.act_settings_show_meters.setVisible(False)
  152. self.ui.act_settings_show_keyboard.setVisible(False)
  153. self.ui.menu_Canvas_Zoom.setEnabled(False)
  154. self.ui.menu_Canvas_Zoom.setVisible(False)
  155. self.ui.menu_Canvas_Zoom.menuAction().setVisible(False)
  156. self.ui.menu_Canvas.setEnabled(False)
  157. self.ui.menu_Canvas.setVisible(False)
  158. self.ui.menu_Canvas.menuAction().setVisible(False)
  159. self.ui.miniCanvasPreview.hide()
  160. self.ui.tabWidget.removeTab(1)
  161. self.ui.tabWidget.tabBar().hide()
  162. # ----------------------------------------------------------------------------------------------------
  163. # Set up GUI (disk)
  164. self.fDirModel = QFileSystemModel(self)
  165. self.fDirModel.setRootPath(HOME)
  166. self.fDirModel.setNameFilters(gCarla.utils.get_supported_file_extensions().split(";"))
  167. self.ui.fileTreeView.setModel(self.fDirModel)
  168. self.ui.fileTreeView.setRootIndex(self.fDirModel.index(HOME))
  169. self.ui.fileTreeView.setColumnHidden(1, True)
  170. self.ui.fileTreeView.setColumnHidden(2, True)
  171. self.ui.fileTreeView.setColumnHidden(3, True)
  172. self.ui.fileTreeView.setHeaderHidden(True)
  173. # ----------------------------------------------------------------------------------------------------
  174. # Set up GUI (panels)
  175. self.fPanelTime = CarlaPanelTime(host, self)
  176. self.fPanelTime.setEnabled(False)
  177. if not host.isPlugin:
  178. QTimer.singleShot(0, self.fPanelTime.show)
  179. # ----------------------------------------------------------------------------------------------------
  180. # Set up GUI (rack)
  181. self.ui.listWidget.setHost(self.host)
  182. sb = self.ui.listWidget.verticalScrollBar()
  183. self.ui.rackScrollBar.setMinimum(sb.minimum())
  184. self.ui.rackScrollBar.setMaximum(sb.maximum())
  185. self.ui.rackScrollBar.setValue(sb.value())
  186. sb.rangeChanged.connect(self.ui.rackScrollBar.setRange)
  187. sb.valueChanged.connect(self.ui.rackScrollBar.setValue)
  188. self.ui.rackScrollBar.rangeChanged.connect(sb.setRange)
  189. self.ui.rackScrollBar.valueChanged.connect(sb.setValue)
  190. self.ui.listWidget.currentRowChanged.connect(self.slot_currentRowChanged)
  191. self.ui.rack.setStyleSheet("""
  192. QLabel#pad_left {
  193. background-image: url(:/bitmaps/rack_padding_left.png);
  194. background-repeat: repeat-y;
  195. }
  196. QLabel#pad_right {
  197. background-image: url(:/bitmaps/rack_padding_right.png);
  198. background-repeat: repeat-y;
  199. }
  200. CarlaRackList#CarlaRackList {
  201. background-color: black;
  202. }
  203. """)
  204. # ----------------------------------------------------------------------------------------------------
  205. # Set up GUI (patchbay)
  206. self.ui.peak_in.setChannelCount(2)
  207. self.ui.peak_in.setMeterColor(DigitalPeakMeter.COLOR_BLUE)
  208. self.ui.peak_in.setMeterOrientation(DigitalPeakMeter.VERTICAL)
  209. self.ui.peak_in.setFixedWidth(25)
  210. self.ui.peak_out.setChannelCount(2)
  211. self.ui.peak_out.setMeterColor(DigitalPeakMeter.COLOR_GREEN)
  212. self.ui.peak_out.setMeterOrientation(DigitalPeakMeter.VERTICAL)
  213. self.ui.peak_out.setFixedWidth(25)
  214. self.ui.scrollArea = PixmapKeyboardHArea(self.ui.patchbay)
  215. self.ui.keyboard = self.ui.scrollArea.keyboard
  216. self.ui.patchbay.layout().addWidget(self.ui.scrollArea, 1, 0, 1, 0)
  217. self.ui.scrollArea.setEnabled(False)
  218. self.ui.miniCanvasPreview.setRealParent(self)
  219. # ----------------------------------------------------------------------------------------------------
  220. # Set up GUI (special stuff for Mac OS)
  221. if MACOS:
  222. self.ui.act_file_quit.setMenuRole(QAction.QuitRole)
  223. self.ui.act_settings_configure.setMenuRole(QAction.PreferencesRole)
  224. self.ui.act_help_about.setMenuRole(QAction.AboutRole)
  225. self.ui.act_help_about_juce.setMenuRole(QAction.AboutQtRole)
  226. self.ui.act_help_about_qt.setMenuRole(QAction.AboutQtRole)
  227. self.ui.menu_Settings.setTitle("Panels")
  228. #self.ui.menu_Help.hide()
  229. # ----------------------------------------------------------------------------------------------------
  230. # Load Settings
  231. self.loadSettings(True)
  232. # ----------------------------------------------------------------------------------------------------
  233. # Set-up Canvas
  234. self.scene = patchcanvas.PatchScene(self, self.ui.graphicsView)
  235. self.ui.graphicsView.setScene(self.scene)
  236. self.ui.graphicsView.setRenderHint(QPainter.Antialiasing, bool(self.fSavedSettings[CARLA_KEY_CANVAS_ANTIALIASING] == patchcanvas.ANTIALIASING_FULL))
  237. if self.fSavedSettings[CARLA_KEY_CANVAS_USE_OPENGL] and hasGL:
  238. self.ui.glView = QGLWidget(self)
  239. self.ui.graphicsView.setViewport(self.ui.glView)
  240. self.ui.graphicsView.setRenderHint(QPainter.HighQualityAntialiasing, self.fSavedSettings[CARLA_KEY_CANVAS_HQ_ANTIALIASING])
  241. self.setupCanvas()
  242. # ----------------------------------------------------------------------------------------------------
  243. # Connect actions to functions
  244. self.ui.act_file_new.triggered.connect(self.slot_fileNew)
  245. self.ui.act_file_open.triggered.connect(self.slot_fileOpen)
  246. self.ui.act_file_save.triggered.connect(self.slot_fileSave)
  247. self.ui.act_file_save_as.triggered.connect(self.slot_fileSaveAs)
  248. self.ui.act_engine_start.triggered.connect(self.slot_engineStart)
  249. self.ui.act_engine_stop.triggered.connect(self.slot_engineStop)
  250. self.ui.act_plugin_add.triggered.connect(self.slot_pluginAdd)
  251. self.ui.act_plugin_add2.triggered.connect(self.slot_pluginAdd)
  252. self.ui.act_plugin_remove_all.triggered.connect(self.slot_pluginRemoveAll)
  253. self.ui.act_plugins_enable.triggered.connect(self.slot_pluginsEnable)
  254. self.ui.act_plugins_disable.triggered.connect(self.slot_pluginsDisable)
  255. self.ui.act_plugins_volume100.triggered.connect(self.slot_pluginsVolume100)
  256. self.ui.act_plugins_mute.triggered.connect(self.slot_pluginsMute)
  257. self.ui.act_plugins_wet100.triggered.connect(self.slot_pluginsWet100)
  258. self.ui.act_plugins_bypass.triggered.connect(self.slot_pluginsBypass)
  259. self.ui.act_plugins_center.triggered.connect(self.slot_pluginsCenter)
  260. self.ui.act_plugins_panic.triggered.connect(self.slot_pluginsDisable)
  261. self.ui.act_canvas_show_internal.triggered.connect(self.slot_canvasShowInternal)
  262. self.ui.act_canvas_show_external.triggered.connect(self.slot_canvasShowExternal)
  263. self.ui.act_canvas_arrange.triggered.connect(self.slot_canvasArrange)
  264. self.ui.act_canvas_refresh.triggered.connect(self.slot_canvasRefresh)
  265. self.ui.act_canvas_zoom_fit.triggered.connect(self.slot_canvasZoomFit)
  266. self.ui.act_canvas_zoom_in.triggered.connect(self.slot_canvasZoomIn)
  267. self.ui.act_canvas_zoom_out.triggered.connect(self.slot_canvasZoomOut)
  268. self.ui.act_canvas_zoom_100.triggered.connect(self.slot_canvasZoomReset)
  269. self.ui.act_canvas_print.triggered.connect(self.slot_canvasPrint)
  270. self.ui.act_canvas_save_image.triggered.connect(self.slot_canvasSaveImage)
  271. self.ui.act_canvas_arrange.setEnabled(False) # TODO, later
  272. self.ui.act_settings_show_meters.toggled.connect(self.slot_showCanvasMeters)
  273. self.ui.act_settings_show_keyboard.toggled.connect(self.slot_showCanvasKeyboard)
  274. self.ui.act_settings_configure.triggered.connect(self.slot_configureCarla)
  275. self.ui.act_help_about.triggered.connect(self.slot_aboutCarla)
  276. self.ui.act_help_about_juce.triggered.connect(self.slot_aboutJuce)
  277. self.ui.act_help_about_qt.triggered.connect(self.slot_aboutQt)
  278. self.ui.cb_disk.currentIndexChanged.connect(self.slot_diskFolderChanged)
  279. self.ui.b_disk_add.clicked.connect(self.slot_diskFolderAdd)
  280. self.ui.b_disk_remove.clicked.connect(self.slot_diskFolderRemove)
  281. self.ui.fileTreeView.doubleClicked.connect(self.slot_fileTreeDoubleClicked)
  282. self.ui.graphicsView.horizontalScrollBar().valueChanged.connect(self.slot_horizontalScrollBarChanged)
  283. self.ui.graphicsView.verticalScrollBar().valueChanged.connect(self.slot_verticalScrollBarChanged)
  284. self.ui.keyboard.noteOn.connect(self.slot_noteOn)
  285. self.ui.keyboard.noteOff.connect(self.slot_noteOff)
  286. self.ui.miniCanvasPreview.miniCanvasMoved.connect(self.slot_miniCanvasMoved)
  287. self.ui.tabWidget.currentChanged.connect(self.slot_tabChanged)
  288. self.scene.scaleChanged.connect(self.slot_canvasScaleChanged)
  289. self.scene.sceneGroupMoved.connect(self.slot_canvasItemMoved)
  290. self.scene.pluginSelected.connect(self.slot_canvasPluginSelected)
  291. self.SIGUSR1.connect(self.slot_handleSIGUSR1)
  292. self.SIGTERM.connect(self.slot_handleSIGTERM)
  293. host.EngineStartedCallback.connect(self.slot_handleEngineStartedCallback)
  294. host.EngineStoppedCallback.connect(self.slot_handleEngineStoppedCallback)
  295. host.PluginAddedCallback.connect(self.slot_handlePluginAddedCallback)
  296. host.PluginRemovedCallback.connect(self.slot_handlePluginRemovedCallback)
  297. host.ReloadAllCallback.connect(self.slot_handleReloadAllCallback)
  298. host.NoteOnCallback.connect(self.slot_handleNoteOnCallback)
  299. host.NoteOffCallback.connect(self.slot_handleNoteOffCallback)
  300. host.PatchbayClientAddedCallback.connect(self.slot_handlePatchbayClientAddedCallback)
  301. host.PatchbayClientRemovedCallback.connect(self.slot_handlePatchbayClientRemovedCallback)
  302. host.PatchbayClientRenamedCallback.connect(self.slot_handlePatchbayClientRenamedCallback)
  303. host.PatchbayClientDataChangedCallback.connect(self.slot_handlePatchbayClientDataChangedCallback)
  304. host.PatchbayPortAddedCallback.connect(self.slot_handlePatchbayPortAddedCallback)
  305. host.PatchbayPortRemovedCallback.connect(self.slot_handlePatchbayPortRemovedCallback)
  306. host.PatchbayPortRenamedCallback.connect(self.slot_handlePatchbayPortRenamedCallback)
  307. host.PatchbayConnectionAddedCallback.connect(self.slot_handlePatchbayConnectionAddedCallback)
  308. host.PatchbayConnectionRemovedCallback.connect(self.slot_handlePatchbayConnectionRemovedCallback)
  309. host.DebugCallback.connect(self.slot_handleDebugCallback)
  310. host.InfoCallback.connect(self.slot_handleInfoCallback)
  311. host.ErrorCallback.connect(self.slot_handleErrorCallback)
  312. host.QuitCallback.connect(self.slot_handleQuitCallback)
  313. # ----------------------------------------------------------------------------------------------------
  314. # Final setup
  315. self.setProperWindowTitle()
  316. # Qt needs this so it properly creates & resizes the canvas
  317. self.ui.tabWidget.blockSignals(True)
  318. self.ui.tabWidget.setCurrentIndex(1)
  319. self.ui.tabWidget.setCurrentIndex(0)
  320. self.ui.tabWidget.blockSignals(False)
  321. # Plugin needs to have timers always running so it receives messages
  322. if self.host.isPlugin:
  323. self.startTimers()
  324. QTimer.singleShot(0, self.slot_engineStart)
  325. # --------------------------------------------------------------------------------------------------------
  326. # Setup
  327. def setLoadRDFsNeeded(self):
  328. self.fLadspaRdfNeedsUpdate = True
  329. def setProperWindowTitle(self):
  330. title = self.fClientName
  331. if self.fProjectFilename:
  332. title += " - %s" % os.path.basename(self.fProjectFilename)
  333. if self.fSessionManagerName:
  334. title += " (%s)" % self.fSessionManagerName
  335. self.setWindowTitle(title)
  336. # --------------------------------------------------------------------------------------------------------
  337. # Files
  338. def loadProjectNow(self):
  339. if not self.fProjectFilename:
  340. return qCritical("ERROR: loading project without filename set")
  341. self.projectLoadingStarted()
  342. self.fIsProjectLoading = True
  343. self.host.load_project(self.fProjectFilename)
  344. self.fIsProjectLoading = False
  345. self.projectLoadingFinished()
  346. def loadProjectLater(self, filename):
  347. self.fProjectFilename = QFileInfo(filename).absoluteFilePath()
  348. self.setProperWindowTitle()
  349. QTimer.singleShot(0, self.slot_loadProjectNow)
  350. def saveProjectNow(self):
  351. if not self.fProjectFilename:
  352. return qCritical("ERROR: saving project without filename set")
  353. self.host.save_project(self.fProjectFilename)
  354. def projectLoadingStarted(self):
  355. self.ui.rack.setEnabled(False)
  356. self.ui.graphicsView.setEnabled(False)
  357. def projectLoadingFinished(self):
  358. self.ui.rack.setEnabled(True)
  359. self.ui.graphicsView.setEnabled(True)
  360. QTimer.singleShot(1000, self.slot_canvasRefresh)
  361. # --------------------------------------------------------------------------------------------------------
  362. # Files (menu actions)
  363. @pyqtSlot()
  364. def slot_fileNew(self):
  365. self.slot_pluginRemoveAll()
  366. self.fProjectFilename = ""
  367. self.setProperWindowTitle()
  368. @pyqtSlot()
  369. def slot_fileOpen(self):
  370. fileFilter = self.tr("Carla Project File (*.carxp)")
  371. filename = QFileDialog.getOpenFileName(self, self.tr("Open Carla Project File"), self.fSavedSettings[CARLA_KEY_MAIN_PROJECT_FOLDER], filter=fileFilter)
  372. if config_UseQt5:
  373. filename = filename[0]
  374. if not filename:
  375. return
  376. newFile = True
  377. if self.fPluginCount > 0:
  378. ask = QMessageBox.question(self, self.tr("Question"), self.tr("There are some plugins loaded, do you want to remove them now?"),
  379. QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
  380. newFile = (ask == QMessageBox.Yes)
  381. if newFile:
  382. self.slot_pluginRemoveAll()
  383. self.fProjectFilename = filename
  384. self.setProperWindowTitle()
  385. self.loadProjectNow()
  386. else:
  387. filenameOld = self.fProjectFilename
  388. self.fProjectFilename = filename
  389. self.loadProjectNow()
  390. self.fProjectFilename = filenameOld
  391. @pyqtSlot()
  392. def slot_fileSave(self, saveAs=False):
  393. if self.fProjectFilename and not saveAs:
  394. return self.saveProjectNow()
  395. fileFilter = self.tr("Carla Project File (*.carxp)")
  396. filename = QFileDialog.getSaveFileName(self, self.tr("Save Carla Project File"), self.fSavedSettings[CARLA_KEY_MAIN_PROJECT_FOLDER], filter=fileFilter)
  397. if config_UseQt5:
  398. filename = filename[0]
  399. if not filename:
  400. return
  401. if not filename.lower().endswith(".carxp"):
  402. filename += ".carxp"
  403. if self.fProjectFilename != filename:
  404. self.fProjectFilename = filename
  405. self.setProperWindowTitle()
  406. self.saveProjectNow()
  407. @pyqtSlot()
  408. def slot_fileSaveAs(self):
  409. self.slot_fileSave(True)
  410. @pyqtSlot()
  411. def slot_loadProjectNow(self):
  412. self.loadProjectNow()
  413. # --------------------------------------------------------------------------------------------------------
  414. # Engine (menu actions)
  415. @pyqtSlot()
  416. def slot_engineStart(self):
  417. audioDriver = self.setEngineSettings()
  418. firstInit = self.fFirstEngineInit
  419. self.fFirstEngineInit = False
  420. if self.host.engine_init(audioDriver, self.fClientName) or firstInit:
  421. return
  422. audioError = self.host.get_last_error()
  423. if audioError:
  424. QMessageBox.critical(self, self.tr("Error"), self.tr("Could not connect to Audio backend '%s', possible reasons:\n%s" % (audioDriver, audioError)))
  425. else:
  426. QMessageBox.critical(self, self.tr("Error"), self.tr("Could not connect to Audio backend '%s'" % audioDriver))
  427. @pyqtSlot()
  428. def slot_engineStop(self, forced = False):
  429. if self.fPluginCount > 0:
  430. if not forced:
  431. ask = QMessageBox.question(self, self.tr("Warning"), self.tr("There are still some plugins loaded, you need to remove them to stop the engine.\n"
  432. "Do you want to do this now?"),
  433. QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
  434. if ask != QMessageBox.Yes:
  435. return
  436. self.killTimers()
  437. self.removeAllPlugins()
  438. self.host.set_engine_about_to_close()
  439. self.host.remove_all_plugins()
  440. if self.host.is_engine_running() and not self.host.engine_close():
  441. print(self.host.get_last_error())
  442. # --------------------------------------------------------------------------------------------------------
  443. # Engine (host callbacks)
  444. @pyqtSlot(str)
  445. def slot_handleEngineStartedCallback(self, processMode, transportMode, driverName):
  446. self.ui.menu_PluginMacros.setEnabled(True)
  447. self.ui.menu_Canvas.setEnabled(True)
  448. self.ui.act_canvas_show_internal.blockSignals(True)
  449. self.ui.act_canvas_show_external.blockSignals(True)
  450. if processMode == ENGINE_PROCESS_MODE_PATCHBAY and driverName == "JACK":
  451. self.ui.act_canvas_show_internal.setChecked(True)
  452. self.ui.act_canvas_show_internal.setVisible(True)
  453. self.ui.act_canvas_show_external.setChecked(False)
  454. self.ui.act_canvas_show_external.setVisible(True)
  455. else:
  456. self.ui.act_canvas_show_internal.setChecked(False)
  457. self.ui.act_canvas_show_internal.setVisible(False)
  458. self.ui.act_canvas_show_external.setChecked(False)
  459. self.ui.act_canvas_show_external.setVisible(False)
  460. self.ui.act_canvas_show_internal.blockSignals(False)
  461. self.ui.act_canvas_show_external.blockSignals(False)
  462. if not self.host.isPlugin:
  463. self.ui.act_engine_start.setEnabled(False)
  464. self.ui.act_engine_stop.setEnabled(True)
  465. if not self.fSessionManagerName:
  466. self.ui.act_file_open.setEnabled(True)
  467. self.ui.act_file_save.setEnabled(True)
  468. self.ui.act_file_save_as.setEnabled(True)
  469. self.fPanelTime.setEnabled(True)
  470. self.startTimers()
  471. @pyqtSlot()
  472. def slot_handleEngineStoppedCallback(self):
  473. patchcanvas.clear()
  474. self.killTimers()
  475. # just in case
  476. self.removeAllPlugins()
  477. self.ui.menu_PluginMacros.setEnabled(False)
  478. self.ui.menu_Canvas.setEnabled(False)
  479. if not self.host.isPlugin:
  480. self.ui.act_engine_start.setEnabled(True)
  481. self.ui.act_engine_stop.setEnabled(False)
  482. if not self.fSessionManagerName:
  483. self.ui.act_file_open.setEnabled(False)
  484. self.ui.act_file_save.setEnabled(False)
  485. self.ui.act_file_save_as.setEnabled(False)
  486. self.fPanelTime.setEnabled(False)
  487. # --------------------------------------------------------------------------------------------------------
  488. # Plugins
  489. def removeAllPlugins(self):
  490. self.ui.act_plugin_remove_all.setEnabled(False)
  491. patchcanvas.handleAllPluginsRemoved()
  492. while self.ui.listWidget.takeItem(0):
  493. pass
  494. self.clearSideStuff()
  495. for pitem in self.fPluginList:
  496. if pitem is None:
  497. continue
  498. pitem.close()
  499. del pitem
  500. self.fPluginCount = 0
  501. self.fPluginList = []
  502. # --------------------------------------------------------------------------------------------------------
  503. # Plugins (menu actions)
  504. @pyqtSlot()
  505. def slot_pluginAdd(self, pluginToReplace = -1):
  506. dialog = PluginDatabaseW(self, self.host)
  507. if not dialog.exec_():
  508. return
  509. if not self.host.is_engine_running():
  510. QMessageBox.warning(self, self.tr("Warning"), self.tr("Cannot add new plugins while engine is stopped"))
  511. return
  512. btype = dialog.fRetPlugin['build']
  513. ptype = dialog.fRetPlugin['type']
  514. filename = dialog.fRetPlugin['filename']
  515. label = dialog.fRetPlugin['label']
  516. uniqueId = dialog.fRetPlugin['uniqueId']
  517. extraPtr = self.getExtraPtr(dialog.fRetPlugin)
  518. if pluginToReplace >= 0:
  519. if not self.host.replace_plugin(pluginToReplace):
  520. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to replace plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  521. return
  522. ok = self.host.add_plugin(btype, ptype, filename, None, label, uniqueId, extraPtr)
  523. if pluginToReplace >= 0:
  524. self.host.replace_plugin(self.host.get_max_plugin_number())
  525. if not ok:
  526. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to load plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  527. @pyqtSlot()
  528. def slot_pluginRemoveAll(self):
  529. if self.fPluginCount == 0:
  530. return
  531. # FIXME - this is not working
  532. # removing a plugin causes flicker, the rack-list becomes empty for some time
  533. # this breaks the remove-all animation, so don't bother using it
  534. if False and not self.host.isPlugin:
  535. self.projectLoadingStarted()
  536. app = QApplication.instance()
  537. app.processEvents()
  538. for i in reversed(range(self.fPluginCount)):
  539. self.host.remove_plugin(i)
  540. app.processEvents()
  541. self.projectLoadingFinished()
  542. self.fCurrentlyRemovingAllPlugins = True
  543. ok = self.host.remove_all_plugins()
  544. self.fCurrentlyRemovingAllPlugins = False
  545. if ok:
  546. self.removeAllPlugins()
  547. else:
  548. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  549. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  550. self.fCurrentlyRemovingAllPlugins = False
  551. # --------------------------------------------------------------------------------------------------------
  552. # Plugins (macros)
  553. @pyqtSlot()
  554. def slot_pluginsEnable(self):
  555. if not self.host.is_engine_running():
  556. return
  557. for pitem in self.fPluginList:
  558. if pitem is None:
  559. break
  560. pitem.getWidget().setActive(True, True, True)
  561. @pyqtSlot()
  562. def slot_pluginsDisable(self):
  563. if not self.host.is_engine_running():
  564. return
  565. for pitem in self.fPluginList:
  566. if pitem is None:
  567. break
  568. pitem.getWidget().setActive(False, True, True)
  569. @pyqtSlot()
  570. def slot_pluginsVolume100(self):
  571. if not self.host.is_engine_running():
  572. return
  573. for pitem in self.fPluginList:
  574. if pitem is None:
  575. break
  576. pitem.getWidget().setInternalParameter(PLUGIN_CAN_VOLUME, 1.0)
  577. @pyqtSlot()
  578. def slot_pluginsMute(self):
  579. if not self.host.is_engine_running():
  580. return
  581. for pitem in self.fPluginList:
  582. if pitem is None:
  583. break
  584. pitem.getWidget().setInternalParameter(PLUGIN_CAN_VOLUME, 0.0)
  585. @pyqtSlot()
  586. def slot_pluginsWet100(self):
  587. if not self.host.is_engine_running():
  588. return
  589. for pitem in self.fPluginList:
  590. if pitem is None:
  591. break
  592. pitem.getWidget().setInternalParameter(PLUGIN_CAN_DRYWET, 1.0)
  593. @pyqtSlot()
  594. def slot_pluginsBypass(self):
  595. if not self.host.is_engine_running():
  596. return
  597. for pitem in self.fPluginList:
  598. if pitem is None:
  599. break
  600. pitem.getWidget().setInternalParameter(PLUGIN_CAN_DRYWET, 0.0)
  601. @pyqtSlot()
  602. def slot_pluginsCenter(self):
  603. if not self.host.is_engine_running():
  604. return
  605. for pitem in self.fPluginList:
  606. if pitem is None:
  607. break
  608. pitem.getWidget().setInternalParameter(PARAMETER_BALANCE_LEFT, -1.0)
  609. pitem.getWidget().setInternalParameter(PARAMETER_BALANCE_RIGHT, 1.0)
  610. pitem.getWidget().setInternalParameter(PARAMETER_PANNING, 0.0)
  611. # --------------------------------------------------------------------------------------------------------
  612. # Plugins (host callbacks)
  613. @pyqtSlot(int, str)
  614. def slot_handlePluginAddedCallback(self, pluginId, pluginName):
  615. pitem = self.ui.listWidget.createItem(pluginId, self.fSavedSettings[CARLA_KEY_MAIN_USE_CUSTOM_SKINS])
  616. self.fPluginList.append(pitem)
  617. self.fPluginCount += 1
  618. if not self.fIsProjectLoading:
  619. pitem.getWidget().setActive(True, True, True)
  620. self.ui.act_plugin_remove_all.setEnabled(self.fPluginCount > 0)
  621. @pyqtSlot(int)
  622. def slot_handlePluginRemovedCallback(self, pluginId):
  623. patchcanvas.handlePluginRemoved(pluginId)
  624. if pluginId in self.fSelectedPlugins:
  625. self.clearSideStuff()
  626. pitem = self.getPluginItem(pluginId)
  627. self.fPluginCount -= 1
  628. self.fPluginList.pop(pluginId)
  629. self.ui.listWidget.takeItem(pluginId)
  630. if pitem is not None:
  631. pitem.close()
  632. del pitem
  633. # push all plugins 1 slot back
  634. for i in range(pluginId, self.fPluginCount):
  635. pitem = self.fPluginList[i]
  636. pitem.setPluginId(i)
  637. self.ui.act_plugin_remove_all.setEnabled(self.fPluginCount > 0)
  638. # --------------------------------------------------------------------------------------------------------
  639. # Canvas
  640. def clearSideStuff(self):
  641. self.scene.clearSelection()
  642. self.fSelectedPlugins = []
  643. self.ui.keyboard.allNotesOff(False)
  644. self.ui.scrollArea.setEnabled(False)
  645. self.fPeaksCleared = True
  646. self.ui.peak_in.displayMeter(1, 0.0, True)
  647. self.ui.peak_in.displayMeter(2, 0.0, True)
  648. self.ui.peak_out.displayMeter(1, 0.0, True)
  649. self.ui.peak_out.displayMeter(2, 0.0, True)
  650. def setupCanvas(self):
  651. pOptions = patchcanvas.options_t()
  652. pOptions.theme_name = self.fSavedSettings[CARLA_KEY_CANVAS_THEME]
  653. pOptions.auto_hide_groups = self.fSavedSettings[CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS]
  654. pOptions.use_bezier_lines = self.fSavedSettings[CARLA_KEY_CANVAS_USE_BEZIER_LINES]
  655. pOptions.antialiasing = self.fSavedSettings[CARLA_KEY_CANVAS_ANTIALIASING]
  656. pOptions.eyecandy = self.fSavedSettings[CARLA_KEY_CANVAS_EYE_CANDY]
  657. pFeatures = patchcanvas.features_t()
  658. pFeatures.group_info = False
  659. pFeatures.group_rename = False
  660. pFeatures.port_info = False
  661. pFeatures.port_rename = False
  662. pFeatures.handle_group_pos = True
  663. patchcanvas.setOptions(pOptions)
  664. patchcanvas.setFeatures(pFeatures)
  665. patchcanvas.init("Carla2", self.scene, canvasCallback, False)
  666. tryCanvasSize = self.fSavedSettings[CARLA_KEY_CANVAS_SIZE].split("x")
  667. if len(tryCanvasSize) == 2 and tryCanvasSize[0].isdigit() and tryCanvasSize[1].isdigit():
  668. self.fCanvasWidth = int(tryCanvasSize[0])
  669. self.fCanvasHeight = int(tryCanvasSize[1])
  670. else:
  671. self.fCanvasWidth = CARLA_DEFAULT_CANVAS_SIZE_WIDTH
  672. self.fCanvasHeight = CARLA_DEFAULT_CANVAS_SIZE_HEIGHT
  673. patchcanvas.setCanvasSize(0, 0, self.fCanvasWidth, self.fCanvasHeight)
  674. patchcanvas.setInitialPos(self.fCanvasWidth / 2, self.fCanvasHeight / 2)
  675. self.ui.graphicsView.setSceneRect(0, 0, self.fCanvasWidth, self.fCanvasHeight)
  676. self.ui.miniCanvasPreview.setViewTheme(patchcanvas.canvas.theme.canvas_bg, patchcanvas.canvas.theme.rubberband_brush, patchcanvas.canvas.theme.rubberband_pen.color())
  677. self.ui.miniCanvasPreview.init(self.scene, self.fCanvasWidth, self.fCanvasHeight, self.fSavedSettings[CARLA_KEY_CUSTOM_PAINTING])
  678. def updateCanvasInitialPos(self):
  679. x = self.ui.graphicsView.horizontalScrollBar().value() + self.width()/4
  680. y = self.ui.graphicsView.verticalScrollBar().value() + self.height()/4
  681. patchcanvas.setInitialPos(x, y)
  682. # --------------------------------------------------------------------------------------------------------
  683. # Canvas (menu actions)
  684. @pyqtSlot()
  685. def slot_canvasShowInternal(self):
  686. self.fExternalPatchbay = False
  687. self.ui.act_canvas_show_internal.blockSignals(True)
  688. self.ui.act_canvas_show_external.blockSignals(True)
  689. self.ui.act_canvas_show_internal.setChecked(True)
  690. self.ui.act_canvas_show_external.setChecked(False)
  691. self.ui.act_canvas_show_internal.blockSignals(False)
  692. self.ui.act_canvas_show_external.blockSignals(False)
  693. self.slot_canvasRefresh()
  694. @pyqtSlot()
  695. def slot_canvasShowExternal(self):
  696. self.fExternalPatchbay = True
  697. self.ui.act_canvas_show_internal.blockSignals(True)
  698. self.ui.act_canvas_show_external.blockSignals(True)
  699. self.ui.act_canvas_show_internal.setChecked(False)
  700. self.ui.act_canvas_show_external.setChecked(True)
  701. self.ui.act_canvas_show_internal.blockSignals(False)
  702. self.ui.act_canvas_show_external.blockSignals(False)
  703. self.slot_canvasRefresh()
  704. @pyqtSlot()
  705. def slot_canvasArrange(self):
  706. patchcanvas.arrange()
  707. @pyqtSlot()
  708. def slot_canvasRefresh(self):
  709. patchcanvas.clear()
  710. if self.host.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK and self.host.isPlugin:
  711. return
  712. if self.host.is_engine_running():
  713. self.host.patchbay_refresh(self.fExternalPatchbay)
  714. QTimer.singleShot(self.fMiniCanvasUpdateTimeout, self.ui.miniCanvasPreview.update)
  715. @pyqtSlot()
  716. def slot_canvasZoomFit(self):
  717. self.scene.zoom_fit()
  718. @pyqtSlot()
  719. def slot_canvasZoomIn(self):
  720. self.scene.zoom_in()
  721. @pyqtSlot()
  722. def slot_canvasZoomOut(self):
  723. self.scene.zoom_out()
  724. @pyqtSlot()
  725. def slot_canvasZoomReset(self):
  726. self.scene.zoom_reset()
  727. @pyqtSlot()
  728. def slot_canvasPrint(self):
  729. self.scene.clearSelection()
  730. dialog = QPrintDialog(self.fExportPrinter, self)
  731. if dialog.exec_():
  732. painter = QPainter(self.fExportPrinter)
  733. painter.save()
  734. painter.setRenderHint(QPainter.Antialiasing)
  735. painter.setRenderHint(QPainter.TextAntialiasing)
  736. self.scene.render(painter)
  737. painter.restore()
  738. @pyqtSlot()
  739. def slot_canvasSaveImage(self):
  740. newPath = QFileDialog.getSaveFileName(self, self.tr("Save Image"), filter=self.tr("PNG Image (*.png);;JPEG Image (*.jpg)"))
  741. if config_UseQt5:
  742. newPath = newPath[0]
  743. if not newPath:
  744. return
  745. self.scene.clearSelection()
  746. if newPath.lower().endswith((".jpg", ".jpeg")):
  747. imgFormat = "JPG"
  748. elif newPath.lower().endswith((".png",)):
  749. imgFormat = "PNG"
  750. else:
  751. # File-dialog may not auto-add the extension
  752. imgFormat = "PNG"
  753. newPath += ".png"
  754. self.fExportImage = QImage(self.scene.sceneRect().width(), self.scene.sceneRect().height(), QImage.Format_RGB32)
  755. painter = QPainter(self.fExportImage)
  756. painter.save()
  757. painter.setRenderHint(QPainter.Antialiasing) # TODO - set true, cleanup this
  758. painter.setRenderHint(QPainter.TextAntialiasing)
  759. self.scene.render(painter)
  760. self.fExportImage.save(newPath, imgFormat, 100)
  761. painter.restore()
  762. # --------------------------------------------------------------------------------------------------------
  763. # Canvas (canvas callbacks)
  764. @pyqtSlot(int, int, QPointF)
  765. def slot_canvasItemMoved(self, group_id, split_mode, pos):
  766. self.ui.miniCanvasPreview.update()
  767. @pyqtSlot(float)
  768. def slot_canvasScaleChanged(self, scale):
  769. self.ui.miniCanvasPreview.setViewScale(scale)
  770. @pyqtSlot(list)
  771. def slot_canvasPluginSelected(self, pluginList):
  772. self.ui.keyboard.allNotesOff(False)
  773. self.ui.scrollArea.setEnabled(len(pluginList) != 0) # and self.fPluginCount > 0
  774. self.fSelectedPlugins = pluginList
  775. # --------------------------------------------------------------------------------------------------------
  776. # Canvas (host callbacks)
  777. @pyqtSlot(int, int, int, str)
  778. def slot_handlePatchbayClientAddedCallback(self, clientId, clientIcon, pluginId, clientName):
  779. pcSplit = patchcanvas.SPLIT_UNDEF
  780. pcIcon = patchcanvas.ICON_APPLICATION
  781. if clientIcon == PATCHBAY_ICON_PLUGIN:
  782. pcIcon = patchcanvas.ICON_PLUGIN
  783. if clientIcon == PATCHBAY_ICON_HARDWARE:
  784. pcIcon = patchcanvas.ICON_HARDWARE
  785. elif clientIcon == PATCHBAY_ICON_CARLA:
  786. pass
  787. elif clientIcon == PATCHBAY_ICON_DISTRHO:
  788. pcIcon = patchcanvas.ICON_DISTRHO
  789. elif clientIcon == PATCHBAY_ICON_FILE:
  790. pcIcon = patchcanvas.ICON_FILE
  791. patchcanvas.addGroup(clientId, clientName, pcSplit, pcIcon)
  792. QTimer.singleShot(self.fMiniCanvasUpdateTimeout, self.ui.miniCanvasPreview.update)
  793. if pluginId < 0:
  794. return
  795. if pluginId >= self.fPluginCount:
  796. print("sorry, can't map this plugin to canvas client", pluginId, self.fPluginCount)
  797. return
  798. patchcanvas.setGroupAsPlugin(clientId, pluginId, bool(self.host.get_plugin_info(pluginId)['hints'] & PLUGIN_HAS_CUSTOM_UI))
  799. @pyqtSlot(int)
  800. def slot_handlePatchbayClientRemovedCallback(self, clientId):
  801. patchcanvas.removeGroup(clientId)
  802. QTimer.singleShot(self.fMiniCanvasUpdateTimeout, self.ui.miniCanvasPreview.update)
  803. @pyqtSlot(int, str)
  804. def slot_handlePatchbayClientRenamedCallback(self, clientId, newClientName):
  805. patchcanvas.renameGroup(clientId, newClientName)
  806. QTimer.singleShot(self.fMiniCanvasUpdateTimeout, self.ui.miniCanvasPreview.update)
  807. @pyqtSlot(int, int, int)
  808. def slot_handlePatchbayClientDataChangedCallback(self, clientId, clientIcon, pluginId):
  809. pcIcon = patchcanvas.ICON_APPLICATION
  810. if clientIcon == PATCHBAY_ICON_PLUGIN:
  811. pcIcon = patchcanvas.ICON_PLUGIN
  812. if clientIcon == PATCHBAY_ICON_HARDWARE:
  813. pcIcon = patchcanvas.ICON_HARDWARE
  814. elif clientIcon == PATCHBAY_ICON_CARLA:
  815. pass
  816. elif clientIcon == PATCHBAY_ICON_DISTRHO:
  817. pcIcon = patchcanvas.ICON_DISTRHO
  818. elif clientIcon == PATCHBAY_ICON_FILE:
  819. pcIcon = patchcanvas.ICON_FILE
  820. patchcanvas.setGroupIcon(clientId, pcIcon)
  821. QTimer.singleShot(self.fMiniCanvasUpdateTimeout, self.ui.miniCanvasPreview.update)
  822. if pluginId < 0:
  823. return
  824. if pluginId >= self.fPluginCount:
  825. print("sorry, can't map this plugin to canvas client", pluginId, self.fPluginCount)
  826. return
  827. patchcanvas.setGroupAsPlugin(clientId, pluginId, bool(self.host.get_plugin_info(pluginId)['hints'] & PLUGIN_HAS_CUSTOM_UI))
  828. @pyqtSlot(int, int, int, str)
  829. def slot_handlePatchbayPortAddedCallback(self, clientId, portId, portFlags, portName):
  830. if portFlags & PATCHBAY_PORT_IS_INPUT:
  831. portMode = patchcanvas.PORT_MODE_INPUT
  832. else:
  833. portMode = patchcanvas.PORT_MODE_OUTPUT
  834. if portFlags & PATCHBAY_PORT_TYPE_AUDIO:
  835. portType = patchcanvas.PORT_TYPE_AUDIO_JACK
  836. isAlternate = False
  837. elif portFlags & PATCHBAY_PORT_TYPE_CV:
  838. portType = patchcanvas.PORT_TYPE_AUDIO_JACK
  839. isAlternate = True
  840. elif portFlags & PATCHBAY_PORT_TYPE_MIDI:
  841. portType = patchcanvas.PORT_TYPE_MIDI_JACK
  842. isAlternate = False
  843. else:
  844. portType = patchcanvas.PORT_TYPE_NULL
  845. isAlternate = False
  846. patchcanvas.addPort(clientId, portId, portName, portMode, portType, isAlternate)
  847. QTimer.singleShot(self.fMiniCanvasUpdateTimeout, self.ui.miniCanvasPreview.update)
  848. @pyqtSlot(int, int)
  849. def slot_handlePatchbayPortRemovedCallback(self, groupId, portId):
  850. patchcanvas.removePort(groupId, portId)
  851. QTimer.singleShot(self.fMiniCanvasUpdateTimeout, self.ui.miniCanvasPreview.update)
  852. @pyqtSlot(int, int, str)
  853. def slot_handlePatchbayPortRenamedCallback(self, groupId, portId, newPortName):
  854. patchcanvas.renamePort(groupId, portId, newPortName)
  855. QTimer.singleShot(self.fMiniCanvasUpdateTimeout, self.ui.miniCanvasPreview.update)
  856. @pyqtSlot(int, int, int, int, int)
  857. def slot_handlePatchbayConnectionAddedCallback(self, connectionId, groupOutId, portOutId, groupInId, portInId):
  858. patchcanvas.connectPorts(connectionId, groupOutId, portOutId, groupInId, portInId)
  859. QTimer.singleShot(self.fMiniCanvasUpdateTimeout, self.ui.miniCanvasPreview.update)
  860. @pyqtSlot(int, int, int)
  861. def slot_handlePatchbayConnectionRemovedCallback(self, connectionId, portOutId, portInId):
  862. patchcanvas.disconnectPorts(connectionId)
  863. QTimer.singleShot(self.fMiniCanvasUpdateTimeout, self.ui.miniCanvasPreview.update)
  864. # --------------------------------------------------------------------------------------------------------
  865. # Settings
  866. def setEngineSettings(self):
  867. settings = QSettings("falkTX", "Carla2")
  868. # ----------------------------------------------------------------------------------------------------
  869. # main settings
  870. setHostSettings(self.host)
  871. # ----------------------------------------------------------------------------------------------------
  872. # plugin paths
  873. LADSPA_PATH = toList(settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH))
  874. DSSI_PATH = toList(settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH))
  875. LV2_PATH = toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH))
  876. VST2_PATH = toList(settings.value(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH))
  877. VST3_PATH = toList(settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH))
  878. AU_PATH = toList(settings.value(CARLA_KEY_PATHS_AU, CARLA_DEFAULT_AU_PATH))
  879. GIG_PATH = toList(settings.value(CARLA_KEY_PATHS_GIG, CARLA_DEFAULT_GIG_PATH))
  880. SF2_PATH = toList(settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH))
  881. SFZ_PATH = toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH))
  882. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LADSPA, splitter.join(LADSPA_PATH))
  883. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_DSSI, splitter.join(DSSI_PATH))
  884. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LV2, splitter.join(LV2_PATH))
  885. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST2, splitter.join(VST2_PATH))
  886. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST3, splitter.join(VST3_PATH))
  887. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_AU, splitter.join(AU_PATH))
  888. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_GIG, splitter.join(GIG_PATH))
  889. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SF2, splitter.join(SF2_PATH))
  890. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SFZ, splitter.join(SFZ_PATH))
  891. # ----------------------------------------------------------------------------------------------------
  892. # don't continue if plugin
  893. if self.host.isPlugin:
  894. return "Plugin"
  895. # ----------------------------------------------------------------------------------------------------
  896. # driver and device settings
  897. # driver name
  898. try:
  899. audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, type=str)
  900. except:
  901. audioDriver = CARLA_DEFAULT_AUDIO_DRIVER
  902. # driver options
  903. try:
  904. audioDevice = settings.value("%s%s/Device" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), "", type=str)
  905. except:
  906. audioDevice = ""
  907. try:
  908. audioNumPeriods = settings.value("%s%s/NumPeriods" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), CARLA_DEFAULT_AUDIO_NUM_PERIODS, type=int)
  909. except:
  910. audioNumPeriods = CARLA_DEFAULT_AUDIO_NUM_PERIODS
  911. try:
  912. audioBufferSize = settings.value("%s%s/BufferSize" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), CARLA_DEFAULT_AUDIO_BUFFER_SIZE, type=int)
  913. except:
  914. audioBufferSize = CARLA_DEFAULT_AUDIO_BUFFER_SIZE
  915. try:
  916. audioSampleRate = settings.value("%s%s/SampleRate" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), CARLA_DEFAULT_AUDIO_SAMPLE_RATE, type=int)
  917. except:
  918. audioSampleRate = CARLA_DEFAULT_AUDIO_SAMPLE_RATE
  919. self.host.set_engine_option(ENGINE_OPTION_AUDIO_DEVICE, 0, audioDevice)
  920. self.host.set_engine_option(ENGINE_OPTION_AUDIO_NUM_PERIODS, audioNumPeriods, "")
  921. self.host.set_engine_option(ENGINE_OPTION_AUDIO_BUFFER_SIZE, audioBufferSize, "")
  922. self.host.set_engine_option(ENGINE_OPTION_AUDIO_SAMPLE_RATE, audioSampleRate, "")
  923. # ----------------------------------------------------------------------------------------------------
  924. # fix things if needed
  925. if audioDriver != "JACK" and self.host.transportMode == ENGINE_TRANSPORT_MODE_JACK:
  926. self.host.transportMode = ENGINE_TRANSPORT_MODE_INTERNAL
  927. self.host.set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, ENGINE_TRANSPORT_MODE_INTERNAL, "")
  928. # ----------------------------------------------------------------------------------------------------
  929. # return selected driver name
  930. return audioDriver
  931. def saveSettings(self):
  932. settings = QSettings()
  933. settings.setValue("Geometry", self.saveGeometry())
  934. #settings.setValue("SplitterState", self.ui.splitter.saveState())
  935. settings.setValue("ShowToolbar", self.ui.toolBar.isVisible())
  936. diskFolders = []
  937. for i in range(self.ui.cb_disk.count()):
  938. diskFolders.append(self.ui.cb_disk.itemData(i))
  939. settings.setValue("DiskFolders", diskFolders)
  940. settings.setValue("ShowMeters", self.ui.act_settings_show_meters.isChecked())
  941. settings.setValue("ShowKeyboard", self.ui.act_settings_show_keyboard.isChecked())
  942. settings.setValue("HorizontalScrollBarValue", self.ui.graphicsView.horizontalScrollBar().value())
  943. settings.setValue("VerticalScrollBarValue", self.ui.graphicsView.verticalScrollBar().value())
  944. def loadSettings(self, firstTime):
  945. settings = QSettings()
  946. if firstTime:
  947. self.restoreGeometry(settings.value("Geometry", ""))
  948. showToolbar = settings.value("ShowToolbar", True, type=bool)
  949. self.ui.act_settings_show_toolbar.setChecked(showToolbar)
  950. self.ui.toolBar.setVisible(showToolbar)
  951. #if settings.contains("SplitterState"):
  952. #self.ui.splitter.restoreState(settings.value("SplitterState", ""))
  953. #else:
  954. #self.ui.splitter.setSizes([210, 99999])
  955. diskFolders = toList(settings.value("DiskFolders", [HOME]))
  956. self.ui.cb_disk.setItemData(0, HOME)
  957. for i in range(len(diskFolders)):
  958. if i == 0: continue
  959. folder = diskFolders[i]
  960. self.ui.cb_disk.addItem(os.path.basename(folder), folder)
  961. #if MACOS and not settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, True, type=bool):
  962. # self.setUnifiedTitleAndToolBarOnMac(True)
  963. showMeters = settings.value("ShowMeters", False, type=bool)
  964. self.ui.act_settings_show_meters.setChecked(showMeters)
  965. self.ui.peak_in.setVisible(showMeters)
  966. self.ui.peak_out.setVisible(showMeters)
  967. showKeyboard = settings.value("ShowKeyboard", not(MACOS or WINDOWS), type=bool)
  968. self.ui.act_settings_show_keyboard.setChecked(showKeyboard)
  969. self.ui.scrollArea.setVisible(showKeyboard)
  970. QTimer.singleShot(100, self.slot_restoreCanvasScrollbarValues)
  971. # TODO - complete this
  972. self.fSavedSettings = {
  973. CARLA_KEY_MAIN_PROJECT_FOLDER: settings.value(CARLA_KEY_MAIN_PROJECT_FOLDER, CARLA_DEFAULT_MAIN_PROJECT_FOLDER, type=str),
  974. CARLA_KEY_MAIN_REFRESH_INTERVAL: settings.value(CARLA_KEY_MAIN_REFRESH_INTERVAL, CARLA_DEFAULT_MAIN_REFRESH_INTERVAL, type=int),
  975. CARLA_KEY_MAIN_USE_CUSTOM_SKINS: settings.value(CARLA_KEY_MAIN_USE_CUSTOM_SKINS, CARLA_DEFAULT_MAIN_USE_CUSTOM_SKINS, type=bool),
  976. CARLA_KEY_CANVAS_THEME: settings.value(CARLA_KEY_CANVAS_THEME, CARLA_DEFAULT_CANVAS_THEME, type=str),
  977. CARLA_KEY_CANVAS_SIZE: settings.value(CARLA_KEY_CANVAS_SIZE, CARLA_DEFAULT_CANVAS_SIZE, type=str),
  978. CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS: settings.value(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS, type=bool),
  979. CARLA_KEY_CANVAS_USE_BEZIER_LINES: settings.value(CARLA_KEY_CANVAS_USE_BEZIER_LINES, CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES, type=bool),
  980. CARLA_KEY_CANVAS_EYE_CANDY: settings.value(CARLA_KEY_CANVAS_EYE_CANDY, CARLA_DEFAULT_CANVAS_EYE_CANDY, type=int),
  981. CARLA_KEY_CANVAS_USE_OPENGL: settings.value(CARLA_KEY_CANVAS_USE_OPENGL, CARLA_DEFAULT_CANVAS_USE_OPENGL, type=bool),
  982. CARLA_KEY_CANVAS_ANTIALIASING: settings.value(CARLA_KEY_CANVAS_ANTIALIASING, CARLA_DEFAULT_CANVAS_ANTIALIASING, type=int),
  983. CARLA_KEY_CANVAS_HQ_ANTIALIASING: settings.value(CARLA_KEY_CANVAS_HQ_ANTIALIASING, CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING, type=bool),
  984. CARLA_KEY_CUSTOM_PAINTING: (settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, True, type=bool) and
  985. settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, "Black", type=str).lower() == "black")
  986. }
  987. self.fMiniCanvasUpdateTimeout = 1000 if self.fSavedSettings[CARLA_KEY_CANVAS_EYE_CANDY] == patchcanvas.EYECANDY_FULL else 0
  988. self.setEngineSettings()
  989. self.restartTimersIfNeeded()
  990. # --------------------------------------------------------------------------------------------------------
  991. # Settings (helpers)
  992. @pyqtSlot()
  993. def slot_restoreCanvasScrollbarValues(self):
  994. settings = QSettings()
  995. self.ui.graphicsView.horizontalScrollBar().setValue(settings.value("HorizontalScrollBarValue", self.ui.graphicsView.horizontalScrollBar().maximum()/2, type=int))
  996. self.ui.graphicsView.verticalScrollBar().setValue(settings.value("VerticalScrollBarValue", self.ui.graphicsView.verticalScrollBar().maximum()/2, type=int))
  997. # --------------------------------------------------------------------------------------------------------
  998. # Settings (menu actions)
  999. @pyqtSlot(bool)
  1000. def slot_showCanvasMeters(self, yesNo):
  1001. self.ui.peak_in.setVisible(yesNo)
  1002. self.ui.peak_out.setVisible(yesNo)
  1003. QTimer.singleShot(0, self.slot_miniCanvasCheckAll)
  1004. @pyqtSlot(bool)
  1005. def slot_showCanvasKeyboard(self, yesNo):
  1006. self.ui.scrollArea.setVisible(yesNo)
  1007. QTimer.singleShot(0, self.slot_miniCanvasCheckAll)
  1008. @pyqtSlot()
  1009. def slot_configureCarla(self):
  1010. dialog = CarlaSettingsW(self, self.host, True, hasGL)
  1011. if not dialog.exec_():
  1012. return
  1013. self.loadSettings(False)
  1014. patchcanvas.clear()
  1015. self.setupCanvas()
  1016. self.slot_miniCanvasCheckAll()
  1017. if self.host.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK and self.host.isPlugin:
  1018. pass
  1019. elif self.host.is_engine_running():
  1020. self.host.patchbay_refresh(self.fExternalPatchbay)
  1021. # --------------------------------------------------------------------------------------------------------
  1022. # About (menu actions)
  1023. @pyqtSlot()
  1024. def slot_aboutCarla(self):
  1025. CarlaAboutW(self, self.host).exec_()
  1026. @pyqtSlot()
  1027. def slot_aboutJuce(self):
  1028. JuceAboutW(self).exec_()
  1029. @pyqtSlot()
  1030. def slot_aboutQt(self):
  1031. QApplication.instance().aboutQt()
  1032. # --------------------------------------------------------------------------------------------------------
  1033. # Disk (menu actions)
  1034. @pyqtSlot(int)
  1035. def slot_diskFolderChanged(self, index):
  1036. if index < 0:
  1037. return
  1038. elif index == 0:
  1039. filename = HOME
  1040. self.ui.b_disk_remove.setEnabled(False)
  1041. else:
  1042. filename = self.ui.cb_disk.itemData(index)
  1043. self.ui.b_disk_remove.setEnabled(True)
  1044. self.fDirModel.setRootPath(filename)
  1045. self.ui.fileTreeView.setRootIndex(self.fDirModel.index(filename))
  1046. @pyqtSlot()
  1047. def slot_diskFolderAdd(self):
  1048. newPath = QFileDialog.getExistingDirectory(self, self.tr("New Folder"), "", QFileDialog.ShowDirsOnly)
  1049. if newPath:
  1050. if newPath[-1] == os.sep:
  1051. newPath = newPath[:-1]
  1052. self.ui.cb_disk.addItem(os.path.basename(newPath), newPath)
  1053. self.ui.cb_disk.setCurrentIndex(self.ui.cb_disk.count()-1)
  1054. self.ui.b_disk_remove.setEnabled(True)
  1055. @pyqtSlot()
  1056. def slot_diskFolderRemove(self):
  1057. index = self.ui.cb_disk.currentIndex()
  1058. if index <= 0:
  1059. return
  1060. self.ui.cb_disk.removeItem(index)
  1061. if self.ui.cb_disk.currentIndex() == 0:
  1062. self.ui.b_disk_remove.setEnabled(False)
  1063. @pyqtSlot(QModelIndex)
  1064. def slot_fileTreeDoubleClicked(self, modelIndex):
  1065. filename = self.fDirModel.filePath(modelIndex)
  1066. if not self.host.load_file(filename):
  1067. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"),
  1068. self.tr("Failed to load file"),
  1069. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  1070. # --------------------------------------------------------------------------------------------------------
  1071. # Canvas scrollbars
  1072. @pyqtSlot(int)
  1073. def slot_horizontalScrollBarChanged(self, value):
  1074. maximum = self.ui.graphicsView.horizontalScrollBar().maximum()
  1075. if maximum == 0:
  1076. xp = 0
  1077. else:
  1078. xp = float(value) / maximum
  1079. self.ui.miniCanvasPreview.setViewPosX(xp)
  1080. self.updateCanvasInitialPos()
  1081. @pyqtSlot(int)
  1082. def slot_verticalScrollBarChanged(self, value):
  1083. maximum = self.ui.graphicsView.verticalScrollBar().maximum()
  1084. if maximum == 0:
  1085. yp = 0
  1086. else:
  1087. yp = float(value) / maximum
  1088. self.ui.miniCanvasPreview.setViewPosY(yp)
  1089. self.updateCanvasInitialPos()
  1090. # --------------------------------------------------------------------------------------------------------
  1091. # Canvas keyboard
  1092. @pyqtSlot(int)
  1093. def slot_noteOn(self, note):
  1094. for pluginId in self.fSelectedPlugins:
  1095. self.host.send_midi_note(pluginId, 0, note, 100)
  1096. pedit = self.getPluginEditDialog(pluginId)
  1097. pedit.noteOn(0, note, 100)
  1098. @pyqtSlot(int)
  1099. def slot_noteOff(self, note):
  1100. for pluginId in self.fSelectedPlugins:
  1101. self.host.send_midi_note(pluginId, 0, note, 0)
  1102. pedit = self.getPluginEditDialog(pluginId)
  1103. pedit.noteOff(0, note)
  1104. # --------------------------------------------------------------------------------------------------------
  1105. # Canvas keyboard (host callbacks)
  1106. @pyqtSlot(int, int, int, int)
  1107. def slot_handleNoteOnCallback(self, pluginId, channel, note, velocity):
  1108. if pluginId in self.fSelectedPlugins:
  1109. self.ui.keyboard.sendNoteOn(note, False)
  1110. @pyqtSlot(int, int, int)
  1111. def slot_handleNoteOffCallback(self, pluginId, channel, note):
  1112. if pluginId in self.fSelectedPlugins:
  1113. self.ui.keyboard.sendNoteOff(note, False)
  1114. # --------------------------------------------------------------------------------------------------------
  1115. # MiniCanvas stuff
  1116. @pyqtSlot()
  1117. def slot_miniCanvasCheckAll(self):
  1118. self.slot_miniCanvasCheckSize()
  1119. self.slot_horizontalScrollBarChanged(self.ui.graphicsView.horizontalScrollBar().value())
  1120. self.slot_verticalScrollBarChanged(self.ui.graphicsView.verticalScrollBar().value())
  1121. @pyqtSlot()
  1122. def slot_miniCanvasCheckSize(self):
  1123. if self.fCanvasWidth == 0 or self.fCanvasHeight == 0:
  1124. return
  1125. if self.ui.tabWidget.currentIndex() == 1:
  1126. width = self.ui.graphicsView.width()
  1127. height = self.ui.graphicsView.height()
  1128. else:
  1129. self.ui.tabWidget.blockSignals(True)
  1130. self.ui.tabWidget.setCurrentIndex(1)
  1131. width = self.ui.graphicsView.width()
  1132. height = self.ui.graphicsView.height()
  1133. self.ui.tabWidget.setCurrentIndex(0)
  1134. self.ui.tabWidget.blockSignals(False)
  1135. self.ui.miniCanvasPreview.setViewSize(float(width)/self.fCanvasWidth, float(height)/self.fCanvasHeight)
  1136. @pyqtSlot(float, float)
  1137. def slot_miniCanvasMoved(self, xp, yp):
  1138. hsb = self.ui.graphicsView.horizontalScrollBar()
  1139. vsb = self.ui.graphicsView.verticalScrollBar()
  1140. hsb.setValue(xp * hsb.maximum())
  1141. vsb.setValue(yp * vsb.maximum())
  1142. self.updateCanvasInitialPos()
  1143. # --------------------------------------------------------------------------------------------------------
  1144. # Rack stuff
  1145. @pyqtSlot(int)
  1146. def slot_currentRowChanged(self, row):
  1147. self.fCurrentRow = row
  1148. if self.fLastSelectedItem is not None:
  1149. self.fLastSelectedItem.setSelected(False)
  1150. if row < 0 or row >= self.fPluginCount or self.fPluginList[row] is None:
  1151. self.fLastSelectedItem = None
  1152. return
  1153. pitem = self.fPluginList[row]
  1154. pitem.getWidget().setSelected(True)
  1155. self.fLastSelectedItem = pitem.getWidget()
  1156. # --------------------------------------------------------------------------------------------------------
  1157. # Timers
  1158. def startTimers(self):
  1159. if self.fIdleTimerFast == 0:
  1160. self.fIdleTimerFast = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL])
  1161. if self.fIdleTimerSlow == 0:
  1162. self.fIdleTimerSlow = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]*4)
  1163. def restartTimersIfNeeded(self):
  1164. if self.fIdleTimerFast != 0:
  1165. self.killTimer(self.fIdleTimerFast)
  1166. self.fIdleTimerFast = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL])
  1167. if self.fIdleTimerSlow != 0:
  1168. self.killTimer(self.fIdleTimerSlow)
  1169. self.fIdleTimerSlow = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]*4)
  1170. def killTimers(self):
  1171. if self.fIdleTimerFast != 0:
  1172. self.killTimer(self.fIdleTimerFast)
  1173. self.fIdleTimerFast = 0
  1174. if self.fIdleTimerSlow != 0:
  1175. self.killTimer(self.fIdleTimerSlow)
  1176. self.fIdleTimerSlow = 0
  1177. # --------------------------------------------------------------------------------------------------------
  1178. # Misc
  1179. @pyqtSlot(int)
  1180. def slot_tabChanged(self, index):
  1181. if index != 1:
  1182. return
  1183. self.ui.graphicsView.setFocus()
  1184. @pyqtSlot(int)
  1185. def slot_handleReloadAllCallback(self, pluginId):
  1186. if pluginId >= self.fPluginCount:
  1187. return
  1188. pitem = self.fPluginList[pluginId]
  1189. if pitem is None:
  1190. return
  1191. self.ui.listWidget.setCurrentRow(-1)
  1192. self.fCurrentRow = -1
  1193. self.fLastSelectedItem = None
  1194. pitem.recreateWidget()
  1195. # --------------------------------------------------------------------------------------------------------
  1196. @pyqtSlot(int, int, int, float, str)
  1197. def slot_handleDebugCallback(self, pluginId, value1, value2, value3, valueStr):
  1198. print("DEBUG:", pluginId, value1, value2, value3, valueStr)
  1199. @pyqtSlot(str)
  1200. def slot_handleInfoCallback(self, info):
  1201. QMessageBox.information(self, "Information", info)
  1202. @pyqtSlot(str)
  1203. def slot_handleErrorCallback(self, error):
  1204. QMessageBox.critical(self, "Error", error)
  1205. @pyqtSlot()
  1206. def slot_handleQuitCallback(self):
  1207. pass # TODO
  1208. # --------------------------------------------------------------------------------------------------------
  1209. @pyqtSlot()
  1210. def slot_handleSIGUSR1(self):
  1211. print("Got SIGUSR1 -> Saving project now")
  1212. self.slot_fileSave()
  1213. @pyqtSlot()
  1214. def slot_handleSIGTERM(self):
  1215. print("Got SIGTERM -> Closing now")
  1216. self.close()
  1217. # --------------------------------------------------------------------------------------------------------
  1218. # Internal stuff
  1219. def getExtraPtr(self, plugin):
  1220. ptype = plugin['type']
  1221. if ptype == PLUGIN_LADSPA:
  1222. uniqueId = plugin['uniqueId']
  1223. self.maybeLoadRDFs()
  1224. for rdfItem in self.fLadspaRdfList:
  1225. if rdfItem.UniqueID == uniqueId:
  1226. return pointer(rdfItem)
  1227. elif ptype in (PLUGIN_GIG, PLUGIN_SF2):
  1228. if plugin['name'].lower().endswith(" (16 outputs)"):
  1229. return self._true
  1230. return None
  1231. def maybeLoadRDFs(self):
  1232. if not self.fLadspaRdfNeedsUpdate:
  1233. return
  1234. self.fLadspaRdfNeedsUpdate = False
  1235. self.fLadspaRdfList = []
  1236. if not haveLRDF:
  1237. return
  1238. settingsDir = os.path.join(HOME, ".config", "falkTX")
  1239. frLadspaFile = os.path.join(settingsDir, "ladspa_rdf.db")
  1240. if os.path.exists(frLadspaFile):
  1241. frLadspa = open(frLadspaFile, 'r')
  1242. try:
  1243. self.fLadspaRdfList = ladspa_rdf.get_c_ladspa_rdfs(json.load(frLadspa))
  1244. except:
  1245. pass
  1246. frLadspa.close()
  1247. # --------------------------------------------------------------------------------------------------------
  1248. def getPluginItem(self, pluginId):
  1249. if pluginId >= self.fPluginCount:
  1250. return None
  1251. pitem = self.fPluginList[pluginId]
  1252. if pitem is None:
  1253. return None
  1254. #if False:
  1255. #return CarlaRackItem(self, 0, False)
  1256. return pitem
  1257. def getPluginEditDialog(self, pluginId):
  1258. if pluginId >= self.fPluginCount:
  1259. return None
  1260. pitem = self.fPluginList[pluginId]
  1261. if pitem is None:
  1262. return None
  1263. if False:
  1264. return PluginEdit(self, self.host, 0)
  1265. return pitem.getEditDialog()
  1266. def getPluginSlotWidget(self, pluginId):
  1267. if pluginId >= self.fPluginCount:
  1268. return None
  1269. pitem = self.fPluginList[pluginId]
  1270. if pitem is None:
  1271. return None
  1272. #if False:
  1273. #return AbstractPluginSlot()
  1274. return pitem.getWidget()
  1275. # --------------------------------------------------------------------------------------------------------
  1276. # show/hide event
  1277. def showEvent(self, event):
  1278. QMainWindow.showEvent(self, event)
  1279. # set our gui as parent for all plugins UIs
  1280. winIdStr = "%x" % self.winId()
  1281. self.host.set_engine_option(ENGINE_OPTION_FRONTEND_WIN_ID, 0, winIdStr)
  1282. def hideEvent(self, event):
  1283. # disable parent
  1284. self.host.set_engine_option(ENGINE_OPTION_FRONTEND_WIN_ID, 0, "0")
  1285. QMainWindow.hideEvent(self, event)
  1286. # --------------------------------------------------------------------------------------------------------
  1287. # resize event
  1288. def fixCanvasPreviewSize(self):
  1289. self.ui.patchbay.resize(self.ui.rack.size())
  1290. self.slot_miniCanvasCheckSize()
  1291. def resizeEvent(self, event):
  1292. QMainWindow.resizeEvent(self, event)
  1293. if self.ui.tabWidget.currentIndex() != 1:
  1294. size = self.ui.rack.size()
  1295. self.ui.patchbay.resize(size)
  1296. self.slot_miniCanvasCheckSize()
  1297. # --------------------------------------------------------------------------------------------------------
  1298. # timer event
  1299. def idleFast(self):
  1300. self.host.engine_idle()
  1301. self.fPanelTime.refreshTransport()
  1302. if self.fPluginCount == 0 or self.fCurrentlyRemovingAllPlugins:
  1303. return
  1304. for pitem in self.fPluginList:
  1305. if pitem is None:
  1306. break
  1307. pitem.getWidget().idleFast()
  1308. for pluginId in self.fSelectedPlugins:
  1309. self.fPeaksCleared = False
  1310. if self.ui.peak_in.isVisible():
  1311. self.ui.peak_in.displayMeter(1, self.host.get_input_peak_value(pluginId, True))
  1312. self.ui.peak_in.displayMeter(2, self.host.get_input_peak_value(pluginId, False))
  1313. if self.ui.peak_out.isVisible():
  1314. self.ui.peak_out.displayMeter(1, self.host.get_output_peak_value(pluginId, True))
  1315. self.ui.peak_out.displayMeter(2, self.host.get_output_peak_value(pluginId, False))
  1316. return
  1317. if self.fPeaksCleared:
  1318. return
  1319. self.fPeaksCleared = True
  1320. self.ui.peak_in.displayMeter(1, 0.0, True)
  1321. self.ui.peak_in.displayMeter(2, 0.0, True)
  1322. self.ui.peak_out.displayMeter(1, 0.0, True)
  1323. self.ui.peak_out.displayMeter(2, 0.0, True)
  1324. def idleSlow(self):
  1325. if self.fPluginCount == 0 or self.fCurrentlyRemovingAllPlugins:
  1326. return
  1327. for pitem in self.fPluginList:
  1328. if pitem is None:
  1329. break
  1330. pitem.getWidget().idleSlow()
  1331. def timerEvent(self, event):
  1332. if event.timerId() == self.fIdleTimerFast:
  1333. self.idleFast()
  1334. elif event.timerId() == self.fIdleTimerSlow:
  1335. self.idleSlow()
  1336. QMainWindow.timerEvent(self, event)
  1337. # --------------------------------------------------------------------------------------------------------
  1338. # paint event
  1339. #def paintEvent(self, event):
  1340. #QMainWindow.paintEvent(self, event)
  1341. #if MACOS or not self.fSavedSettings[CARLA_KEY_CUSTOM_PAINTING]:
  1342. #return
  1343. #painter = QPainter(self)
  1344. #painter.setBrush(QColor(36, 36, 36))
  1345. #painter.setPen(QColor(62, 62, 62))
  1346. #painter.drawRect(1, self.height()/2, self.width()-3, self.height()-self.height()/2-1)
  1347. # --------------------------------------------------------------------------------------------------------
  1348. # close event
  1349. def closeEvent(self, event):
  1350. self.killTimers()
  1351. self.saveSettings()
  1352. if self.host.is_engine_running() and not self.host.isPlugin:
  1353. self.slot_engineStop(True)
  1354. QMainWindow.closeEvent(self, event)
  1355. # ------------------------------------------------------------------------------------------------
  1356. # Canvas callback
  1357. def canvasCallback(action, value1, value2, valueStr):
  1358. host = gCarla.gui.host
  1359. if action == patchcanvas.ACTION_GROUP_INFO:
  1360. pass
  1361. elif action == patchcanvas.ACTION_GROUP_RENAME:
  1362. pass
  1363. elif action == patchcanvas.ACTION_GROUP_SPLIT:
  1364. groupId = value1
  1365. patchcanvas.splitGroup(groupId)
  1366. gCarla.gui.ui.miniCanvasPreview.update()
  1367. elif action == patchcanvas.ACTION_GROUP_JOIN:
  1368. groupId = value1
  1369. patchcanvas.joinGroup(groupId)
  1370. gCarla.gui.ui.miniCanvasPreview.update()
  1371. elif action == patchcanvas.ACTION_PORT_INFO:
  1372. pass
  1373. elif action == patchcanvas.ACTION_PORT_RENAME:
  1374. pass
  1375. elif action == patchcanvas.ACTION_PORTS_CONNECT:
  1376. gOut, pOut, gIn, pIn = [int(i) for i in valueStr.split(":")]
  1377. if not host.patchbay_connect(gOut, pOut, gIn, pIn):
  1378. print("Connection failed:", host.get_last_error())
  1379. elif action == patchcanvas.ACTION_PORTS_DISCONNECT:
  1380. connectionId = value1
  1381. if not host.patchbay_disconnect(connectionId):
  1382. print("Disconnect failed:", host.get_last_error())
  1383. elif action == patchcanvas.ACTION_PLUGIN_CLONE:
  1384. pluginId = value1
  1385. if not host.clone_plugin(pluginId):
  1386. CustomMessageBox(gCarla.gui, QMessageBox.Warning, gCarla.gui.tr("Error"), gCarla.gui.tr("Operation failed"),
  1387. host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  1388. elif action == patchcanvas.ACTION_PLUGIN_EDIT:
  1389. pluginId = value1
  1390. dialog = gCarla.gui.getPluginEditDialog(pluginId)
  1391. if dialog is None:
  1392. return
  1393. dialog.show()
  1394. elif action == patchcanvas.ACTION_PLUGIN_RENAME:
  1395. pluginId = value1
  1396. newName = valueStr
  1397. if not host.rename_plugin(pluginId, newName):
  1398. CustomMessageBox(gCarla.gui, QMessageBox.Warning, gCarla.gui.tr("Error"), gCarla.gui.tr("Operation failed"),
  1399. host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  1400. elif action == patchcanvas.ACTION_PLUGIN_REMOVE:
  1401. pluginId = value1
  1402. if not host.remove_plugin(pluginId):
  1403. CustomMessageBox(gCarla.gui, QMessageBox.Warning, gCarla.gui.tr("Error"), gCarla.gui.tr("Operation failed"),
  1404. host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  1405. elif action == patchcanvas.ACTION_PLUGIN_SHOW_UI:
  1406. pluginId = value1
  1407. host.show_custom_ui(pluginId, True)
  1408. # ------------------------------------------------------------------------------------------------------------
  1409. # Engine callback
  1410. def engineCallback(host, action, pluginId, value1, value2, value3, valueStr):
  1411. # kdevelop likes this :)
  1412. if False: host = CarlaHostMeta()
  1413. if action == ENGINE_CALLBACK_ENGINE_STARTED:
  1414. host.processMode = value1
  1415. host.transportMode = value2
  1416. elif action == ENGINE_CALLBACK_PROCESS_MODE_CHANGED:
  1417. host.processMode = value1
  1418. elif action == ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED:
  1419. host.transportMode = value1
  1420. valueStr = charPtrToString(valueStr)
  1421. if action == ENGINE_CALLBACK_DEBUG:
  1422. host.DebugCallback.emit(pluginId, value1, value2, value3, valueStr)
  1423. elif action == ENGINE_CALLBACK_PLUGIN_ADDED:
  1424. host.PluginAddedCallback.emit(pluginId, valueStr)
  1425. elif action == ENGINE_CALLBACK_PLUGIN_REMOVED:
  1426. host.PluginRemovedCallback.emit(pluginId)
  1427. elif action == ENGINE_CALLBACK_PLUGIN_RENAMED:
  1428. host.PluginRenamedCallback.emit(pluginId, valueStr)
  1429. elif action == ENGINE_CALLBACK_PLUGIN_UNAVAILABLE:
  1430. host.PluginUnavailableCallback.emit(pluginId, valueStr)
  1431. elif action == ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  1432. host.ParameterValueChangedCallback.emit(pluginId, value1, value3)
  1433. elif action == ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
  1434. host.ParameterDefaultChangedCallback.emit(pluginId, value1, value3)
  1435. elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED:
  1436. host.ParameterMidiCcChangedCallback.emit(pluginId, value1, value2)
  1437. elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
  1438. host.ParameterMidiChannelChangedCallback.emit(pluginId, value1, value2)
  1439. elif action == ENGINE_CALLBACK_PROGRAM_CHANGED:
  1440. host.ProgramChangedCallback.emit(pluginId, value1)
  1441. elif action == ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
  1442. host.MidiProgramChangedCallback.emit(pluginId, value1)
  1443. elif action == ENGINE_CALLBACK_OPTION_CHANGED:
  1444. host.OptionChangedCallback.emit(pluginId, value1, bool(value2))
  1445. elif action == ENGINE_CALLBACK_UI_STATE_CHANGED:
  1446. host.UiStateChangedCallback.emit(pluginId, value1)
  1447. elif action == ENGINE_CALLBACK_NOTE_ON:
  1448. host.NoteOnCallback.emit(pluginId, value1, value2, int(value3))
  1449. elif action == ENGINE_CALLBACK_NOTE_OFF:
  1450. host.NoteOffCallback.emit(pluginId, value1, value2)
  1451. elif action == ENGINE_CALLBACK_UPDATE:
  1452. host.UpdateCallback.emit(pluginId)
  1453. elif action == ENGINE_CALLBACK_RELOAD_INFO:
  1454. host.ReloadInfoCallback.emit(pluginId)
  1455. elif action == ENGINE_CALLBACK_RELOAD_PARAMETERS:
  1456. host.ReloadParametersCallback.emit(pluginId)
  1457. elif action == ENGINE_CALLBACK_RELOAD_PROGRAMS:
  1458. host.ReloadProgramsCallback.emit(pluginId)
  1459. elif action == ENGINE_CALLBACK_RELOAD_ALL:
  1460. host.ReloadAllCallback.emit(pluginId)
  1461. elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED:
  1462. host.PatchbayClientAddedCallback.emit(pluginId, value1, value2, valueStr)
  1463. elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED:
  1464. host.PatchbayClientRemovedCallback.emit(pluginId)
  1465. elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED:
  1466. host.PatchbayClientRenamedCallback.emit(pluginId, valueStr)
  1467. elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED:
  1468. host.PatchbayClientDataChangedCallback.emit(pluginId, value1, value2)
  1469. elif action == ENGINE_CALLBACK_PATCHBAY_PORT_ADDED:
  1470. host.PatchbayPortAddedCallback.emit(pluginId, value1, value2, valueStr)
  1471. elif action == ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED:
  1472. host.PatchbayPortRemovedCallback.emit(pluginId, value1)
  1473. elif action == ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED:
  1474. host.PatchbayPortRenamedCallback.emit(pluginId, value1, valueStr)
  1475. elif action == ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED:
  1476. gOut, pOut, gIn, pIn = [int(i) for i in valueStr.split(":")] # FIXME
  1477. host.PatchbayConnectionAddedCallback.emit(pluginId, gOut, pOut, gIn, pIn)
  1478. elif action == ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED:
  1479. host.PatchbayConnectionRemovedCallback.emit(pluginId, value1, value2)
  1480. elif action == ENGINE_CALLBACK_ENGINE_STARTED:
  1481. host.EngineStartedCallback.emit(value1, value2, valueStr)
  1482. elif action == ENGINE_CALLBACK_ENGINE_STOPPED:
  1483. host.EngineStoppedCallback.emit()
  1484. elif action == ENGINE_CALLBACK_PROCESS_MODE_CHANGED:
  1485. host.ProcessModeChangedCallback.emit(value1)
  1486. elif action == ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED:
  1487. host.TransportModeChangedCallback.emit(value1)
  1488. elif action == ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
  1489. host.BufferSizeChangedCallback.emit(value1)
  1490. elif action == ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
  1491. host.SampleRateChangedCallback.emit(value3)
  1492. elif action == ENGINE_CALLBACK_IDLE:
  1493. QApplication.instance().processEvents()
  1494. elif action == ENGINE_CALLBACK_INFO:
  1495. host.InfoCallback.emit(valueStr)
  1496. elif action == ENGINE_CALLBACK_ERROR:
  1497. host.ErrorCallback.emit(valueStr)
  1498. elif action == ENGINE_CALLBACK_QUIT:
  1499. host.QuitCallback.emit()
  1500. # ------------------------------------------------------------------------------------------------------------
  1501. # File callback
  1502. def fileCallback(ptr, action, isDir, title, filter):
  1503. ret = ("", "") if config_UseQt5 else ""
  1504. if action == FILE_CALLBACK_DEBUG:
  1505. pass
  1506. elif action == FILE_CALLBACK_OPEN:
  1507. ret = QFileDialog.getOpenFileName(gCarla.gui, charPtrToString(title), "", charPtrToString(filter) ) #, QFileDialog.ShowDirsOnly if isDir else 0x0)
  1508. elif action == FILE_CALLBACK_SAVE:
  1509. ret = QFileDialog.getSaveFileName(gCarla.gui, charPtrToString(title), "", charPtrToString(filter), QFileDialog.ShowDirsOnly if isDir else 0x0)
  1510. if config_UseQt5:
  1511. ret = ret[0]
  1512. if not ret:
  1513. return None
  1514. # FIXME
  1515. global fileRet
  1516. fileRet = c_char_p(ret.encode("utf-8"))
  1517. retval = cast(byref(fileRet), POINTER(c_uintptr))
  1518. return retval.contents.value
  1519. # ------------------------------------------------------------------------------------------------------------
  1520. # Init host
  1521. def initHost(initName, libPrefixOrPluginClass, isControl, isPlugin, failError):
  1522. if isPlugin:
  1523. PluginClass = libPrefixOrPluginClass
  1524. libPrefix = None
  1525. else:
  1526. PluginClass = None
  1527. libPrefix = libPrefixOrPluginClass
  1528. pathBinaries, pathResources = getPaths(libPrefix)
  1529. # --------------------------------------------------------------------------------------------------------
  1530. # Fail if binary dir is not found
  1531. if not os.path.exists(pathBinaries):
  1532. if failError:
  1533. QMessageBox.critical(None, "Error", "Failed to find the carla binaries, cannot continue")
  1534. sys.exit(1)
  1535. return
  1536. # --------------------------------------------------------------------------------------------------------
  1537. # Set Carla library name
  1538. libname = "libcarla_%s2.%s" % ("control" if isControl else "standalone", DLL_EXTENSION)
  1539. utilsname = "libcarla_utils.%s" % (DLL_EXTENSION)
  1540. # --------------------------------------------------------------------------------------------------------
  1541. # Print info
  1542. print("Carla %s started, status:" % VERSION)
  1543. print(" Python version: %s" % sys.version.split(" ",1)[0])
  1544. print(" Qt version: %s" % qVersion())
  1545. print(" PyQt version: %s" % PYQT_VERSION_STR)
  1546. print(" Binary dir: %s" % pathBinaries)
  1547. print(" Resources dir: %s" % pathResources)
  1548. # --------------------------------------------------------------------------------------------------------
  1549. # Init host
  1550. if failError:
  1551. # no try
  1552. host = PluginClass() if isPlugin else CarlaHostQtDLL(os.path.join(pathBinaries, libname))
  1553. else:
  1554. try:
  1555. host = PluginClass() if isPlugin else CarlaHostQtDLL(os.path.join(pathBinaries, libname))
  1556. except:
  1557. host = CarlaHostQtNull()
  1558. host.isControl = isControl
  1559. host.isPlugin = isPlugin
  1560. host.set_engine_callback(lambda h,a,p,v1,v2,v3,vs: engineCallback(host,a,p,v1,v2,v3,vs))
  1561. host.set_file_callback(fileCallback)
  1562. # If it's a plugin the paths are already set
  1563. if not isPlugin:
  1564. host.pathBinaries = pathBinaries
  1565. host.pathResources = pathResources
  1566. host.set_engine_option(ENGINE_OPTION_PATH_BINARIES, 0, pathBinaries)
  1567. host.set_engine_option(ENGINE_OPTION_PATH_RESOURCES, 0, pathResources)
  1568. if not isControl:
  1569. host.set_engine_option(ENGINE_OPTION_NSM_INIT, os.getpid(), initName)
  1570. # --------------------------------------------------------------------------------------------------------
  1571. # Init utils
  1572. gCarla.utils = CarlaUtils(os.path.join(pathBinaries, utilsname))
  1573. gCarla.utils.set_process_name(initName)
  1574. #gCarla.utils.set_locale_C()
  1575. # --------------------------------------------------------------------------------------------------------
  1576. # Done
  1577. return host
  1578. # ------------------------------------------------------------------------------------------------------------
  1579. # Load host settings
  1580. def loadHostSettings(host):
  1581. # kdevelop likes this :)
  1582. if False: host = CarlaHostMeta()
  1583. settings = QSettings("falkTX", "Carla2")
  1584. # bool values
  1585. try:
  1586. host.forceStereo = settings.value(CARLA_KEY_ENGINE_FORCE_STEREO, CARLA_DEFAULT_FORCE_STEREO, type=bool)
  1587. except:
  1588. host.forceStereo = CARLA_DEFAULT_FORCE_STEREO
  1589. try:
  1590. host.preferPluginBridges = settings.value(CARLA_KEY_ENGINE_PREFER_PLUGIN_BRIDGES, CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES, type=bool)
  1591. except:
  1592. host.preferPluginBridges = CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES
  1593. try:
  1594. host.preferUIBridges = settings.value(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, CARLA_DEFAULT_PREFER_UI_BRIDGES, type=bool)
  1595. except:
  1596. host.preferUIBridges = CARLA_DEFAULT_PREFER_UI_BRIDGES
  1597. try:
  1598. host.uisAlwaysOnTop = settings.value(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, CARLA_DEFAULT_UIS_ALWAYS_ON_TOP, type=bool)
  1599. except:
  1600. host.uisAlwaysOnTop = CARLA_DEFAULT_UIS_ALWAYS_ON_TOP
  1601. # int values
  1602. try:
  1603. host.maxParameters = settings.value(CARLA_KEY_ENGINE_MAX_PARAMETERS, CARLA_DEFAULT_MAX_PARAMETERS, type=int)
  1604. except:
  1605. host.maxParameters = CARLA_DEFAULT_MAX_PARAMETERS
  1606. try:
  1607. host.uiBridgesTimeout = settings.value(CARLA_KEY_ENGINE_UI_BRIDGES_TIMEOUT, CARLA_DEFAULT_UI_BRIDGES_TIMEOUT, type=int)
  1608. except:
  1609. host.uiBridgesTimeout = CARLA_DEFAULT_UI_BRIDGES_TIMEOUT
  1610. if host.isPlugin:
  1611. return
  1612. # enums
  1613. try:
  1614. host.transportMode = settings.value(CARLA_KEY_ENGINE_TRANSPORT_MODE, CARLA_DEFAULT_TRANSPORT_MODE, type=int)
  1615. except:
  1616. host.transportMode = CARLA_DEFAULT_TRANSPORT_MODE
  1617. if not host.processModeForced:
  1618. try:
  1619. host.processMode = settings.value(CARLA_KEY_ENGINE_PROCESS_MODE, CARLA_DEFAULT_PROCESS_MODE, type=int)
  1620. except:
  1621. host.processMode = CARLA_DEFAULT_PROCESS_MODE
  1622. host.nextProcessMode = host.processMode
  1623. # --------------------------------------------------------------------------------------------------------
  1624. # fix things if needed
  1625. if host.processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS and LADISH_APP_NAME:
  1626. print("LADISH detected but using multiple clients (not allowed), forcing single client now")
  1627. host.nextProcessMode = host.processMode = ENGINE_PROCESS_MODE_SINGLE_CLIENT
  1628. # ------------------------------------------------------------------------------------------------------------
  1629. # Set host settings
  1630. def setHostSettings(host):
  1631. # kdevelop likes this :)
  1632. if False: host = CarlaHostMeta()
  1633. # TEST
  1634. #host.preventBadBehaviour = True
  1635. host.set_engine_option(ENGINE_OPTION_FORCE_STEREO, host.forceStereo, "")
  1636. host.set_engine_option(ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, host.preferPluginBridges, "")
  1637. host.set_engine_option(ENGINE_OPTION_PREFER_UI_BRIDGES, host.preferUIBridges, "")
  1638. host.set_engine_option(ENGINE_OPTION_UIS_ALWAYS_ON_TOP, host.uisAlwaysOnTop, "")
  1639. host.set_engine_option(ENGINE_OPTION_MAX_PARAMETERS, host.maxParameters, "")
  1640. host.set_engine_option(ENGINE_OPTION_UI_BRIDGES_TIMEOUT, host.uiBridgesTimeout, "")
  1641. host.set_engine_option(ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR, host.preventBadBehaviour, "")
  1642. if host.isPlugin:
  1643. return
  1644. host.set_engine_option(ENGINE_OPTION_PROCESS_MODE, host.nextProcessMode, "")
  1645. host.set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, host.transportMode, "")
  1646. # ------------------------------------------------------------------------------------------------------------